From 49af409b0c43ec3d3f0479c21cef172e29e1cdfd Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Mon, 15 Jan 2018 14:25:46 +0000 Subject: Improve NSB Standalone XML generation Delayed the generation of the XML file until the last step. The following functions will return a XML string insted: - Libvirt.build_vm_xml - SriovContext._enable_interfaces - OvsDpdkContext._enable_interfaces The XML file will be written just before copying the file to the compute hosting the VMs. JIRA: YARDSTICK-939 Change-Id: Icc80f4741903bbe335db4ebccab395b72fa87e82 Signed-off-by: Rodolfo Alonso Hernandez --- yardstick/benchmark/contexts/standalone/ovs_dpdk.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'yardstick/benchmark/contexts/standalone/ovs_dpdk.py') diff --git a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py index ee0eb9e0d..30b685eec 100644 --- a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py +++ b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py @@ -359,7 +359,7 @@ class OvsDpdkContext(Context): self.networks = portlist LOG.info("Ports %s", self.networks) - def _enable_interfaces(self, index, vfs, cfg): + def _enable_interfaces(self, index, vfs, xml_str): vpath = self.ovs_properties.get("vpath", "/usr/local") vf = self.networks[vfs[0]] port_num = vf.get('port_num', 0) @@ -368,8 +368,8 @@ class OvsDpdkContext(Context): slot = index + port_num + 10 vf['vpci'] = \ "{}:{}:{:02x}.{}".format(vpci.domain, vpci.bus, slot, vpci.function) - model.Libvirt.add_ovs_interface( - vpath, port_num, vf['vpci'], vf['mac'], str(cfg)) + return model.Libvirt.add_ovs_interface( + vpath, port_num, vf['vpci'], vf['mac'], xml_str) def setup_ovs_dpdk_context(self): nodes = [] @@ -384,17 +384,16 @@ class OvsDpdkContext(Context): # 1. Check and delete VM if already exists model.Libvirt.check_if_vm_exists_and_delete(vm_name, self.connection) + xml_str, mac = model.Libvirt.build_vm_xml( + self.connection, self.vm_flavor, vm_name, index) - _, mac = model.Libvirt.build_vm_xml( - self.connection, self.vm_flavor, cfg, vm_name, index) # 2: Cleanup already available VMs - for vkey, vfs in collections.OrderedDict( - vnf["network_ports"]).items(): - if vkey == "mgmt": - continue - self._enable_interfaces(index, vfs, cfg) + for vfs in [vfs for vfs_name, vfs in vnf["network_ports"].items() + if vfs_name != 'mgmt']: + xml_str = self._enable_interfaces(index, vfs, xml_str) # copy xml to target... + model.Libvirt.write_file(cfg, xml_str) self.connection.put(cfg, cfg) # NOTE: launch through libvirt -- cgit 1.2.3-korg