From: Ondrej Lichtner <olichtne(a)redhat.com>
This commit modifies how we fallback to matching virtual machines when
normal matching fails.
First of all there is now a logging message informing the user about
this happening.
Next we need to check the interfaces of all the machines that are
requested by the recipe for parameters. Parameters are used for matching
and restricting possible interfaces, however this doesn't make sense
when matching virtual devices since these have no parameters to set. The
only exception is the parameter 'hwaddr' which can be used to specify
what mac address should the created interface have.
And finally I added a filter of the pool machines so that only virtual
machines with the parameter 'libvirt_domain' defined are considered when
matching virtual machines - this was a bug that went unnoticed since we
all use virtual machines all the time.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/SlavePool.py | 34 ++++++++++++++++++++++++++++------
1 file changed, 28 insertions(+), 6 deletions(-)
diff --git a/lnst/Controller/SlavePool.py b/lnst/Controller/SlavePool.py
index c50cbe6..686f20f 100644
--- a/lnst/Controller/SlavePool.py
+++ b/lnst/Controller/SlavePool.py
@@ -608,13 +608,35 @@ class SetupMapper:
mmap = self._format_map_dict(machine_map, network_map)
mmap["virtual"] = False
return mmap
- elif self._map_setup_virt(template_machines, pool_machines):
- machine_map = [(tm, pm, []) for tm, pm in self._machine_map]
- mmap = self._format_map_dict(machine_map, [])
- mmap["virtual"] = True
- return mmap
else:
- return None
+ logging.info("Match failed for normal machines, falling back "\
+ "to matching virtual machines.")
+
+ for m_id, m in template_machines.iteritems():
+ for if_id, interface in m["interfaces"].iteritems():
+ if "params" in interface:
+ for name, val in interface["params"].iteritems():
+ if name != "hwaddr":
+ msg = "Dynamically created interfaces "\
+ "only support the 'hwaddr' option.
"\
+ "'%s=%s' found on machine '%s'
"\
+ "interface '%s'" % (name, val,
+ m_id, if_id)
+ raise MapperError(msg)
+
+ #filter machine pool to only contain virtual machines
+ virt_pool_machines = {}
+ for m_id, m in pool_machines.iteritems():
+ if "params" in m and "libvirt_domain" in
m["params"]:
+ virt_pool_machines[m_id] = m
+
+ if self._map_setup_virt(template_machines, virt_pool_machines):
+ machine_map = [(tm, pm, []) for tm, pm in self._machine_map]
+ mmap = self._format_map_dict(machine_map, [])
+ mmap["virtual"] = True
+ return mmap
+ else:
+ return None
def _map_setup(self, template_topology, pool_topology):
--
1.8.3.1