Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx> --- client/tests/kvm/kvm_preprocessing.py | 14 ++--- client/tests/kvm/kvm_vm.py | 58 ++++++++++---------- client/tests/kvm/tests/pci_hotplug.py | 4 +- client/tests/kvm/tests/physical_resources_check.py | 8 ++-- client/tests/kvm/tests/unittest.py | 4 +- client/tests/kvm/tests/whql_submission.py | 30 +++++----- 6 files changed, 57 insertions(+), 61 deletions(-) diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py index 90382cc..25c4e5f 100644 --- a/client/tests/kvm/kvm_preprocessing.py +++ b/client/tests/kvm/kvm_preprocessing.py @@ -183,13 +183,11 @@ def process(test, params, env, image_func, vm_func): @param vm_func: A function to call for each VM. """ # Get list of VMs specified for this test - vm_names = kvm_utils.get_sub_dict_names(params, "vms") - for vm_name in vm_names: - vm_params = kvm_utils.get_sub_dict(params, vm_name) + for vm_name in params.objects("vms"): + vm_params = params.object_params(vm_name) # Get list of images specified for this VM - image_names = kvm_utils.get_sub_dict_names(vm_params, "images") - for image_name in image_names: - image_params = kvm_utils.get_sub_dict(vm_params, image_name) + for image_name in vm_params.objects("images"): + image_params = vm_params.object_params(image_name) # Call image_func for each image image_func(test, image_params) # Call vm_func for each vm @@ -226,7 +224,7 @@ def preprocess(test, params, env): env["tcpdump"].get_output())) # Destroy and remove VMs that are no longer needed in the environment - requested_vms = kvm_utils.get_sub_dict_names(params, "vms") + requested_vms = params.objects("vms") for key in env.keys(): vm = env[key] if not kvm_utils.is_vm(vm): @@ -372,7 +370,7 @@ def postprocess_on_error(test, params, env): @param params: A dict containing all VM and image parameters. @param env: The environment (a dict-like object). """ - params.update(kvm_utils.get_sub_dict(params, "on_error")) + params.update(params.object_params("on_error")) def _update_address_cache(address_cache, line): diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index a8bee6c..fb272fe 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -381,8 +381,8 @@ class VM: # Add the VM's name qemu_cmd += add_name(help, name) # Add monitors - for monitor_name in kvm_utils.get_sub_dict_names(params, "monitors"): - monitor_params = kvm_utils.get_sub_dict(params, monitor_name) + for monitor_name in params.objects("monitors"): + monitor_params = params.object_params(monitor_name) monitor_filename = vm.get_monitor_filename(monitor_name) if monitor_params.get("monitor_type") == "qmp": qemu_cmd += add_qmp_monitor(help, monitor_filename) @@ -392,8 +392,8 @@ class VM: # Add serial console redirection qemu_cmd += add_serial(help, vm.get_serial_console_filename()) - for image_name in kvm_utils.get_sub_dict_names(params, "images"): - image_params = kvm_utils.get_sub_dict(params, image_name) + for image_name in params.objects("images"): + image_params = params.object_params(image_name) if image_params.get("boot_drive") == "no": continue qemu_cmd += add_drive(help, @@ -407,15 +407,15 @@ class VM: image_params.get("image_boot") == "yes") redirs = [] - for redir_name in kvm_utils.get_sub_dict_names(params, "redirs"): - redir_params = kvm_utils.get_sub_dict(params, redir_name) + for redir_name in params.objects("redirs"): + redir_params = params.object_params(redir_name) guest_port = int(redir_params.get("guest_port")) host_port = vm.redirs.get(guest_port) redirs += [(host_port, guest_port)] vlan = 0 - for nic_name in kvm_utils.get_sub_dict_names(params, "nics"): - nic_params = kvm_utils.get_sub_dict(params, nic_name) + for nic_name in params.objects("nics"): + nic_params = params.object_params(nic_name) try: netdev_id = vm.netdev_id[vlan] except IndexError: @@ -450,9 +450,8 @@ class VM: if smp: qemu_cmd += add_smp(help, smp) - cdroms = kvm_utils.get_sub_dict_names(params, "cdroms") - for cdrom in cdroms: - cdrom_params = kvm_utils.get_sub_dict(params, cdrom) + for cdrom in params.objects("cdroms"): + cdrom_params = params.object_params(cdrom) iso = cdrom_params.get("cdrom") if iso: qemu_cmd += add_cdrom(help, kvm_utils.get_path(root_dir, iso), @@ -552,8 +551,8 @@ class VM: root_dir = self.root_dir # Verify the md5sum of the ISO images - for cdrom in kvm_utils.get_sub_dict_names(params, "cdroms"): - cdrom_params = kvm_utils.get_sub_dict(params, cdrom) + for cdrom in params.objects("cdroms"): + cdrom_params = params.object_params(cdrom) iso = cdrom_params.get("cdrom") if iso: iso = kvm_utils.get_path(root_dir, iso) @@ -593,17 +592,17 @@ class VM: try: # Handle port redirections - redir_names = kvm_utils.get_sub_dict_names(params, "redirs") + redir_names = params.objects("redirs") host_ports = kvm_utils.find_free_ports(5000, 6000, len(redir_names)) self.redirs = {} for i in range(len(redir_names)): - redir_params = kvm_utils.get_sub_dict(params, redir_names[i]) + redir_params = params.object_params(redir_names[i]) guest_port = int(redir_params.get("guest_port")) self.redirs[guest_port] = host_ports[i] # Generate netdev IDs for all NICs self.netdev_id = [] - for nic in kvm_utils.get_sub_dict_names(params, "nics"): + for nic in params.objects("nics"): self.netdev_id.append(kvm_utils.generate_random_id()) # Find available VNC port, if needed @@ -617,10 +616,10 @@ class VM: f.close() # Generate or copy MAC addresses for all NICs - num_nics = len(kvm_utils.get_sub_dict_names(params, "nics")) + num_nics = len(params.objects("nics")) for vlan in range(num_nics): - nic_name = kvm_utils.get_sub_dict_names(params, "nics")[vlan] - nic_params = kvm_utils.get_sub_dict(params, nic_name) + nic_name = params.objects("nics")[vlan] + nic_params = params.object_params(nic_name) if nic_params.get("nic_mac", None): mac = nic_params.get("nic_mac") kvm_utils.set_mac_address(self.instance, vlan, mac) @@ -705,9 +704,8 @@ class VM: # Establish monitor connections self.monitors = [] - for monitor_name in kvm_utils.get_sub_dict_names(params, - "monitors"): - monitor_params = kvm_utils.get_sub_dict(params, monitor_name) + for monitor_name in params.objects("monitors"): + monitor_params = params.object_params(monitor_name) # Wait for monitor connection to succeed end_time = time.time() + timeout while time.time() < end_time: @@ -853,7 +851,7 @@ class VM: os.unlink(self.migration_file) except OSError: pass - num_nics = len(kvm_utils.get_sub_dict_names(self.params, "nics")) + num_nics = len(self.params.objects("nics")) for vlan in range(num_nics): self.free_mac_address(vlan) @@ -912,7 +910,7 @@ class VM: params). """ return [self.get_monitor_filename(m) for m in - kvm_utils.get_sub_dict_names(self.params, "monitors")] + self.params.objects("monitors")] def get_serial_console_filename(self): @@ -938,9 +936,9 @@ class VM: @param index: Index of the NIC whose address is requested. """ - nics = kvm_utils.get_sub_dict_names(self.params, "nics") + nics = self.params.objects("nics") nic_name = nics[index] - nic_params = kvm_utils.get_sub_dict(self.params, nic_name) + nic_params = self.params.object_params(nic_name) if nic_params.get("nic_mode") == "tap": mac = self.get_mac_address(index) if not mac: @@ -973,8 +971,8 @@ class VM: @return: If port redirection is used, return the host port redirected to guest port port. Otherwise return port. """ - nic_name = kvm_utils.get_sub_dict_names(self.params, "nics")[nic_index] - nic_params = kvm_utils.get_sub_dict(self.params, nic_name) + nic_name = self.params.objects("nics")[nic_index] + nic_params = self.params.object_params(nic_name) if nic_params.get("nic_mode") == "tap": return port else: @@ -990,9 +988,9 @@ class VM: @param nic_index: Index of the NIC """ - nics = kvm_utils.get_sub_dict_names(self.params, "nics") + nics = self.params.objects("nics") nic_name = nics[nic_index] - nic_params = kvm_utils.get_sub_dict(self.params, nic_name) + nic_params = self.params.object_params(nic_name) if nic_params.get("nic_ifname"): return nic_params.get("nic_ifname") else: diff --git a/client/tests/kvm/tests/pci_hotplug.py b/client/tests/kvm/tests/pci_hotplug.py index 727ee62..27b81de 100644 --- a/client/tests/kvm/tests/pci_hotplug.py +++ b/client/tests/kvm/tests/pci_hotplug.py @@ -51,7 +51,7 @@ def run_pci_hotplug(test, params, env): if test_type == "nic": pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % tested_model elif test_type == "block": - image_params = kvm_utils.get_sub_dict(params, "stg") + image_params = params.object_params("stg") image_filename = kvm_vm.get_image_filename(image_params, test.bindir) pci_add_cmd = ("pci_add pci_addr=auto storage file=%s,if=%s" % @@ -73,7 +73,7 @@ def run_pci_hotplug(test, params, env): pci_add_cmd = "device_add id=%s,driver=%s" % (id, tested_model) elif test_type == "block": - image_params = kvm_utils.get_sub_dict(params, "stg") + image_params = params.object_params("stg") image_filename = kvm_vm.get_image_filename(image_params, test.bindir) if tested_model == "virtio": diff --git a/client/tests/kvm/tests/physical_resources_check.py b/client/tests/kvm/tests/physical_resources_check.py index 0630ac8..3234da7 100644 --- a/client/tests/kvm/tests/physical_resources_check.py +++ b/client/tests/kvm/tests/physical_resources_check.py @@ -51,7 +51,7 @@ def run_physical_resources_check(test, params, env): # Define a function for checking number of hard drivers & NICs def check_num(devices, info_cmd, check_str): f_fail = 0 - expected_num = kvm_utils.get_sub_dict_names(params, devices).__len__() + expected_num = params.objects(devices).__len__() try: o = vm.monitor.info(info_cmd) except kvm_monitor.MonitorError, e: @@ -78,9 +78,9 @@ def run_physical_resources_check(test, params, env): # Define a function for checking hard drives & NICs' model def chk_fmt_model(device, fmt_model, info_cmd, str): f_fail = 0 - devices = kvm_utils.get_sub_dict_names(params, device) + devices = params.objects(device) for chk_device in devices: - expected = kvm_utils.get_sub_dict(params, chk_device).get(fmt_model) + expected = params.object_params(chk_device).get(fmt_model) if not expected: expected = "rtl8139" try: @@ -123,7 +123,7 @@ def run_physical_resources_check(test, params, env): found_mac_addresses = re.findall("macaddr=(\S+)", o) logging.debug("Found MAC adresses: %s" % found_mac_addresses) - num_nics = len(kvm_utils.get_sub_dict_names(params, "nics")) + num_nics = len(params.objects("nics")) for nic_index in range(num_nics): mac = vm.get_mac_address(nic_index) if not string.lower(mac) in found_mac_addresses: diff --git a/client/tests/kvm/tests/unittest.py b/client/tests/kvm/tests/unittest.py index 54e5f73..67686e3 100644 --- a/client/tests/kvm/tests/unittest.py +++ b/client/tests/kvm/tests/unittest.py @@ -36,8 +36,8 @@ def run_unittest(test, params, env): unittest_cfg) logging.debug('Unit test list: %s' % test_list) - if params.get('test_list', None): - test_list = kvm_utils.get_sub_dict_names(params, 'test_list') + if params.get('test_list'): + test_list = params.get('test_list').split() logging.info('Original test list overriden by user') logging.info('User defined unit test list: %s' % test_list) diff --git a/client/tests/kvm/tests/whql_submission.py b/client/tests/kvm/tests/whql_submission.py index 2d01e30..ae71942 100644 --- a/client/tests/kvm/tests/whql_submission.py +++ b/client/tests/kvm/tests/whql_submission.py @@ -21,13 +21,13 @@ def run_whql_submission(test, params, env): # Log into all client VMs vms = [] sessions = [] - for vm_name in kvm_utils.get_sub_dict_names(params, "vms"): + for vm_name in params.objects("vms"): vms.append(kvm_test_utils.get_living_vm(env, vm_name)) sessions.append(kvm_test_utils.wait_for_login(vms[-1], 0, 240)) # Make sure all NICs of all client VMs are up for vm in vms: - nics = kvm_utils.get_sub_dict_names(vm.params, "nics") + nics = vm.params.objects("nics") for nic_index in range(len(nics)): s = kvm_test_utils.wait_for_login(vm, nic_index, 600) s.close() @@ -77,7 +77,7 @@ def run_whql_submission(test, params, env): # Check the NICs again for vm in vms: - nics = kvm_utils.get_sub_dict_names(vm.params, "nics") + nics = vm.params.objects("nics") for nic_index in range(len(nics)): s = kvm_test_utils.wait_for_login(vm, nic_index, 600) s.close() @@ -122,8 +122,8 @@ def run_whql_submission(test, params, env): # Set submission DeviceData find_prompt("DeviceData name:") - for dd in kvm_utils.get_sub_dict_names(params, "device_data"): - dd_params = kvm_utils.get_sub_dict(params, dd) + for dd in params.objects("device_data"): + dd_params = params.object_params(dd) if dd_params.get("dd_name") and dd_params.get("dd_data"): server_session.sendline(dd_params.get("dd_name")) server_session.sendline(dd_params.get("dd_data")) @@ -131,29 +131,29 @@ def run_whql_submission(test, params, env): # Set submission descriptors find_prompt("Descriptor path:") - for desc in kvm_utils.get_sub_dict_names(params, "descriptors"): - desc_params = kvm_utils.get_sub_dict(params, desc) + for desc in params.objects("descriptors"): + desc_params = params.object_params(desc) if desc_params.get("desc_path"): server_session.sendline(desc_params.get("desc_path")) server_session.sendline() # Set machine dimensions for each client machine - for vm_name in kvm_utils.get_sub_dict_names(params, "vms"): - vm_params = kvm_utils.get_sub_dict(params, vm_name) + for vm_name in params.objects("vms"): + vm_params = params.object_params(vm_name) find_prompt(r"Dimension name\b.*:") - for dp in kvm_utils.get_sub_dict_names(vm_params, "dimensions"): - dp_params = kvm_utils.get_sub_dict(vm_params, dp) + for dp in vm_params.objects("dimensions"): + dp_params = vm_params.object_params(dp) if dp_params.get("dim_name") and dp_params.get("dim_value"): server_session.sendline(dp_params.get("dim_name")) server_session.sendline(dp_params.get("dim_value")) server_session.sendline() # Set extra parameters for tests that require them (e.g. NDISTest) - for vm_name in kvm_utils.get_sub_dict_names(params, "vms"): - vm_params = kvm_utils.get_sub_dict(params, vm_name) + for vm_name in params.objects("vms"): + vm_params = params.object_params(vm_name) find_prompt(r"Parameter name\b.*:") - for dp in kvm_utils.get_sub_dict_names(vm_params, "device_params"): - dp_params = kvm_utils.get_sub_dict(vm_params, dp) + for dp in vm_params.objects("device_params"): + dp_params = vm_params.object_params(dp) if dp_params.get("dp_name") and dp_params.get("dp_regex"): server_session.sendline(dp_params.get("dp_name")) server_session.sendline(dp_params.get("dp_regex")) -- 1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html