commit 97844d91397010d5d3011ee9858c33291df355c1 Author: Jan Tluka jtluka@redhat.com Date: Fri Oct 4 16:17:36 2013 +0200
Fix query for libvirt_domain in non-virt scenarios
When using non-virtual machines the controller would fail with following error:
Traceback (most recent call last): File "./lnst-ctl", line 93, in get_recipe_result defined_aliases, overriden_aliases) File "./lnst-ctl", line 74, in process_recipe overriden_aliases=overriden_aliases) File "/mnt/testarea/lnst/lnst/Controller/NetTestController.py", line 60, in __init__ check_process_running("libvirtd"), pool_checks) File "/mnt/testarea/lnst/lnst/Controller/SlavePool.py", line 47, in __init__ self.add_dir(pool_dir) File "/mnt/testarea/lnst/lnst/Controller/SlavePool.py", line 55, in add_dir res.append(self.add_file("%s/%s" % (pool_dir, dirent))) File "/mnt/testarea/lnst/lnst/Controller/SlavePool.py", line 96, in add_file pm["libvirt_domain"] == rm["libvirt_domain"]: KeyError: 'libvirt_domain'
This was introduced by commit 2ed4e1e80de597309833a2b144682a63fcea3e74
Bare metal systems in pool do not have this parameter and therefore parsing their slavemachine xml would fail.
As a first step I've split the hostname and libvirt_domain param check as they are not tied together.
Next, the fix first checks whether the optional parameter libvirt_domain exists then it checks it's value. I've tested this patch on our regression-test machine.
Fixes issue #47.
Signed-off-by: Jiri Pirko jiri@resnulli.us
lnst/Controller/SlavePool.py | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) --- diff --git a/lnst/Controller/SlavePool.py b/lnst/Controller/SlavePool.py index 77ee1b5..4162e16 100644 --- a/lnst/Controller/SlavePool.py +++ b/lnst/Controller/SlavePool.py @@ -92,12 +92,17 @@ class SlavePool: for pm_id, m in self._pool.iteritems(): pm = m["params"] rm = machine_spec["params"] - if pm["hostname"] == rm["hostname"] or \ - pm["libvirt_domain"] == rm["libvirt_domain"]: + if pm["hostname"] == rm["hostname"]: msg = "You have the same machine listed twice in " \ "your pool ('%s' and '%s')." % (m_id, pm_id) raise SlaveMachineError(msg)
+ if "libvirt_domain" in rm and "libvirt_domain" in pm and \ + pm["libvirt_domain"] == rm["libvirt_domain"]: + msg = "You have the same libvirt_domain listed twice in " \ + "your pool ('%s' and '%s')." % (m_id, pm_id) + raise SlaveMachineError(msg) + if self._pool_checks: available = False
lnst-developers@lists.fedorahosted.org