If a slavemachine xml file in pool directory contains xml that does not
start with <slavemachine> tag the controller fails with not very useful
info. This patch checks the first tag is valid and in case it's not the
controller will print the error along with the corrupted filename.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst/Controller/SlavePool.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lnst/Controller/SlavePool.py b/lnst/Controller/SlavePool.py
index e8baf83..7deb912 100644
--- a/lnst/Controller/SlavePool.py
+++ b/lnst/Controller/SlavePool.py
@@ -67,7 +67,12 @@ class SlavePool:
m_id = re.sub("\.[xX][mM][lL]$", "", basename)
- slavemachine = dom.getElementsByTagName("slavemachine")[0]
+ sm_tag = dom.getElementsByTagName("slavemachine")
+ if len(sm_tag) == 0:
+ msg = "File %s does not contain <slavemachine> tag." %
filepath
+ raise Exception(msg)
+
+ slavemachine = sm_tag[0]
xml_data = parser.parse(slavemachine)
machine_spec = self._process_machine_xml_data(m_id, xml_data)
--
1.8.1.4
Show replies by date