commit 8cadf4b8d938107832eebfbb70957f672c5de146
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Feb 28 15:58:15 2014 +0100
NetTestController: always save config_only configuration
Until now we only saved config_only configuration if the run was
virtualized, this was so that we could nicely deconfigure dynamically
created network devices. This commit makes it so that the configuration
is stored for every config_only run, even if virtualization wasn't used.
This is not required for functionality since slaves will automatically
deconfigure themselves when needed, but it can be used to call
deconfiguration without running a different config_only run or run an
entire recipe.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/NetTestController.py | 40 +++++++++++++++++----------------
1 files changed, 21 insertions(+), 19 deletions(-)
---
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index c5e3fec..b2694c4 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -56,7 +56,7 @@ class NetTestController:
self._recipe_path = recipe_path
self._msg_dispatcher = MessageDispatcher(log_ctl)
- self._remove_virt_config()
+ self._remove_saved_machine_config()
sp = SlavePool(lnst_config.get_option('environment', 'pool_dirs'),
check_process_running("libvirtd"), pool_checks)
@@ -422,14 +422,15 @@ class NetTestController:
for bridge in self._network_bridges.itervalues():
bridge.cleanup()
- def _save_virt_config(self):
+ def _save_machine_config(self):
#saves current virtual configuration to a file, after pickling it
config_data = dict()
machines = config_data["machines"] = {}
for m in self._machines.itervalues():
machine = machines[m.get_hostname()] = dict()
- machine["libvirt_dom"] = m.get_libvirt_domain()
+ if m.get_libvirt_domain() != None:
+ machine["libvirt_dom"] = m.get_libvirt_domain()
machine["interfaces"] = []
for i in m._interfaces:
@@ -442,21 +443,22 @@ class NetTestController:
for bridge in self._network_bridges.itervalues():
bridges.append(bridge.get_name())
- with open("/tmp/.lnst_virt_conf", "wb") as f:
+ with open("/tmp/.lnst_machine_conf", "wb") as f:
pickled_data = cPickle.dump(config_data, f)
- def _remove_virt_config(self):
- #removes previously saved virtual configuration
+ def _remove_saved_machine_config(self):
+ #removes previously saved configuration
cfg = None
try:
- with open("/tmp/.lnst_virt_conf", "rb") as f:
+ with open("/tmp/.lnst_machine_conf", "rb") as f:
cfg = cPickle.load(f)
except:
+ logging.info("No previous configuration found.")
return
if cfg:
logging.info("Cleaning up leftover configuration from previous "\
- "virtualized config_only run.")
+ "config_only run.")
for hostname, machine in cfg["machines"].iteritems():
port = lnst_config.get_option("environment", "rpcport")
if test_tcp_connection(hostname, port):
@@ -474,14 +476,15 @@ class NetTestController:
break
rpc_con.close()
- libvirt_dom = machine["libvirt_dom"]
- domain_ctl = VirtDomainCtl(libvirt_dom)
- logging.info("Detaching dynamically created interfaces.")
- for i in machine["interfaces"]:
- try:
- domain_ctl.detach_interface(i)
- except:
- pass
+ if "libvirt_dom" in "machine":
+ libvirt_dom = machine["libvirt_dom"]
+ domain_ctl = VirtDomainCtl(libvirt_dom)
+ logging.info("Detaching dynamically created interfaces.")
+ for i in machine["interfaces"]:
+ try:
+ domain_ctl.detach_interface(i)
+ except:
+ pass
logging.info("Removing dynamically created bridges.")
for br in cfg["bridges"]:
@@ -491,7 +494,7 @@ class NetTestController:
except:
pass
- os.remove("/tmp/.lnst_virt_conf")
+ os.remove("/tmp/.lnst_machine_conf")
def match_setup(self):
self._prepare_provisioning()
@@ -509,8 +512,7 @@ class NetTestController:
raise
sp = self._slave_pool
- if sp.is_setup_virtual():
- self._save_virt_config()
+ self._save_machine_config()
self._cleanup_slaves(deconfigure=False)
return {"passed": True}