Duplicate MAC addresses in slavemachine files are silently ignored and could cause
unpredictable behaviour. This patch adds a check for MAC duplicity.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst/Controller/SlavePool.py | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/lnst/Controller/SlavePool.py b/lnst/Controller/SlavePool.py
index 67ccd63..5f94b07 100644
--- a/lnst/Controller/SlavePool.py
+++ b/lnst/Controller/SlavePool.py
@@ -208,11 +208,20 @@ class SlavePool:
if_id = iface["id"]
iface_spec = self._process_iface_xml_data(m_id, iface)
- if if_id not in machine_spec["interfaces"]:
- machine_spec["interfaces"][if_id] = iface_spec
- else:
+ # validity check, MAC and id must be unique
+ if if_id in machine_spec["interfaces"]:
msg = "Duplicate interface id '%s'." % if_id
raise SlaveMachineError(msg, iface)
+
+ if_hwaddr = iface_spec["params"]["hwaddr"]
+ hwaddr_dups = [ k for k, v in
machine_spec["interfaces"].iteritems()\
+ if v["params"]["hwaddr"] == if_hwaddr
]
+ if len(hwaddr_dups) > 0:
+ msg = "Duplicate MAC address %s for interface '%s' and
'%s'."\
+ % (if_hwaddr, if_id, hwaddr_dups[0])
+ raise SlaveMachineError(msg, iface)
+
+ machine_spec["interfaces"][if_id] = iface_spec
else:
if "libvirt_domain" not in machine_spec["params"]:
msg = "Machine '%s' has no testing interfaces. " \
--
2.7.4
Show replies by date