@@ -51,7 +51,7 @@ class Crb(object):
CPU/PCI/NIC on the board and setup running environment for DPDK.
"""
- def __init__(self, crb, serializer, name, alt_session=True, dut_id=0):
+ def __init__(self, crb, serializer, dut_id=0, name=None, alt_session=True):
self.dut_id = dut_id
self.crb = crb
self.read_cache = False
@@ -62,10 +62,11 @@ class Dut(Crb):
CORE_LIST_CACHE_KEY = 'dut_core_list'
PCI_DEV_CACHE_KEY = 'dut_pci_dev_info'
- def __init__(self, crb, serializer, dut_id):
- self.NAME = 'dut' + LOG_NAME_SEP + '%s' % crb['My IP']
- super(Dut, self).__init__(crb, serializer, self.NAME, alt_session=True, dut_id=dut_id)
-
+ def __init__(self, crb, serializer, dut_id=0, name=None, alt_session=True):
+ if not name:
+ name = 'dut' + LOG_NAME_SEP + '%s' % crb['My IP']
+ self.NAME = name
+ super(Dut, self).__init__(crb, serializer, dut_id, name, alt_session)
self.host_init_flag = False
self.number_of_cores = 0
self.tester = None
@@ -60,8 +60,9 @@ class DPDKdut(Dut):
build, memory and kernel module.
"""
- def __init__(self, crb, serializer, dut_id):
- super(DPDKdut, self).__init__(crb, serializer, dut_id)
+ def __init__(self, crb, serializer, dut_id=0, name=None, alt_session=True):
+ super(DPDKdut, self).__init__(crb, serializer, dut_id, name,
+ alt_session)
self.testpmd = None
def set_target(self, target, bind_dev=True):
@@ -80,7 +80,7 @@ class Tester(Crb):
def __init__(self, crb, serializer):
self.NAME = 'tester'
self.scapy_session = None
- super(Tester, self).__init__(crb, serializer, self.NAME)
+ super(Tester, self).__init__(crb, serializer, name=self.NAME)
# check the python version of tester
check_crb_python_version(self)
@@ -104,7 +104,7 @@ class VirtBase(object):
"""
Get the virtual type, such as KVM, XEN or LIBVIRT.
"""
- NotImplemented
+ raise NotImplementedError
def has_virtual_ability(self):
"""
@@ -118,6 +118,30 @@ class VirtBase(object):
"""
NotImplemented
+ def get_vm_login(self):
+ """
+ Get VM credentials.
+ """
+ raise NotImplementedError
+
+ def add_vm_login(self):
+ """
+ Add VM credentials.
+ """
+ raise NotImplementedError
+
+ def _attach_vm(self):
+ """
+ Attach VM.
+ """
+ raise NotImplementedError
+
+ def _quick_start_vm(self):
+ """
+ Quick start VM.
+ """
+ raise NotImplementedError
+
def load_global_config(self):
"""
Load global configure in the path DTS_ROOT_PATH/conf.
@@ -230,7 +254,7 @@ class VirtBase(object):
"""
Get the VM IP.
"""
- NotImplemented
+ raise NotImplementedError
def get_pci_mappings(self):
"""
@@ -61,16 +61,16 @@ class VirtDut(DPDKdut):
"""
def __init__(self, hyper, crb, serializer, virttype, vm_name, suite, cpu_topo, dut_id):
+ self.vm_ip = crb['IP']
+ self.NAME = 'virtdut' + LOG_NAME_SEP + '%s' % self.vm_ip
+ # do not create addition alt_session
+ super(VirtDut, self).__init__(crb, serializer, dut_id,
+ self.NAME, alt_session=False)
self.vm_name = vm_name
self.hyper = hyper
self.cpu_topo = cpu_topo
- self.dut_id = dut_id
self.migration_vm = False
- self.vm_ip = crb['IP']
- self.NAME = 'virtdut' + LOG_NAME_SEP + '%s' % self.vm_ip
- # do not create addition alt_session
- super(Dut, self).__init__(crb, serializer, self.NAME, alt_session=False, dut_id=self.dut_id)
# load port config from suite cfg
self.suite = suite
@@ -70,6 +70,9 @@ class VirtResource(object):
# save allocated cores and related vm
self.allocated_info = {}
+ def __port_isused(self, pci):
+ return pci in self.used_ports
+
def __port_used(self, pci):
index = self.ports.index(pci)
self.used_ports[index] = pci
@@ -243,8 +246,8 @@ class VirtResource(object):
print("Port %s has been used!!!" % pci)
else:
if self.__port_on_socket(pci, socket) is True:
- self.__port_used(core)
- ports.append(core)
+ self.__port_used(pci)
+ ports.append(pci)
if vm not in self.allocated_info:
self.allocated_info[vm] = {}
@@ -347,7 +347,7 @@ class VirtScene(object):
elif cmd['type'] == 'host':
crb = self.host_dut
elif cmd['type'] == 'tester':
- crb = self.tester
+ crb = self.tester_dut
else:
crb = self.host_dut
@@ -390,11 +390,11 @@ class VirtScene(object):
def run_post_cmds(self):
for cmd in self.post_cmds:
if cmd['type'] == 'vm':
- crb = self.vm_dut
+ crb = None
elif cmd['type'] == 'host':
crb = self.host_dut
elif cmd['type'] == 'tester':
- crb = self.tester
+ crb = self.tester_dut
else:
crb = self.host_dut
@@ -456,7 +456,6 @@ class VirtScene(object):
topo = self.get_cputopo(scene_params)
try:
vm_dut = vm.start(load_config=False, set_target=False,
- auto_portmap=self.auto_portmap,
cpu_topo=topo)
if vm_dut is None:
raise Exception("Set up VM ENV failed!")
@@ -507,16 +506,18 @@ class VirtScene(object):
if __name__ == "__main__":
- class QEMUKvm():
+ class QEMUKvmTmp():
def __init__(self, dut, vm_name, suite_name):
print(vm_name)
print(suite_name)
def start(self):
- print(self.params)
+ print(self.__dict__)
return True
+ QEMUKvm = QEMUKvmTmp
+
class simple_dev(object):
def __init__(self, pci):