commit 3d16d397d3c31ce12d119730b7168a00ceabdd27
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Sep 6 14:14:47 2013 +0200
SlavePool: check corner cases
This commit adds checks for two corner cases in machine pool matching:
* recipe contains an isolated machine
* recipe describes a network topology with a network that contains just
* a single machine
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/SlavePool.py | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/lnst/Controller/SlavePool.py b/lnst/Controller/SlavePool.py
index a6eb794..cd9e508 100644
--- a/lnst/Controller/SlavePool.py
+++ b/lnst/Controller/SlavePool.py
@@ -325,15 +325,21 @@ class SetupMapper:
if dev_info["network"] == net_name:
devs_in_net.append(dev_id)
+ net_in_use = False
for neighbour in net:
n_m_id = neighbour[0]
n_dev_id = neighbour[1]
if n_m_id != m_id:
+ net_in_use = True
for dev_in_net in devs_in_net:
nc = (n_m_id, net_name, dev_in_net)
if not nc in topology[m_id]:
topology[m_id].append(nc)
+ if not net_in_use:
+ msg = "Network '%s' contains only one machine!" %
net_name
+ raise SlaveMachineError(msg)
+
return topology
@staticmethod
@@ -586,6 +592,11 @@ class SetupMapper:
template_topology = self._get_topology(template_machines)
pool_topology = self._get_topology(pool_machines)
+ for m, cons in template_topology.iteritems():
+ if len(cons) == 0:
+ msg = "Isolated machine in template topology: '%s'" %
m
+ raise SlaveMachineError(msg)
+
if self._map_setup(template_topology, pool_topology):
machine_map = [(tm, pm, self._iface_map[tm]) \
for tm, pm in self._machine_map]
Show replies by date