summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthew.hodgins <matthew.hodgins@calxeda.com>2013-12-12 12:58:44 -0600
committermatthew.hodgins <matthew.hodgins@calxeda.com>2013-12-12 12:58:44 -0600
commit702ed4653d7c87fe2d140972994ba4d1aa806927 (patch)
tree29c8f2218e92eb9853df04e82ae754faaadbae43
parent3e9bc7ffbe1185c54d760f246433938dce54f6ce (diff)
downloadcxmanage-702ed4653d7c87fe2d140972994ba4d1aa806927.tar.gz
CXMAN-274 guard against bad return from get networks
Signed-off-by: matthew.hodgins <matthew.hodgins@calxeda.com>
-rw-r--r--cxmanage_api/fabric.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/cxmanage_api/fabric.py b/cxmanage_api/fabric.py
index 96ac9f8..ad2f883 100644
--- a/cxmanage_api/fabric.py
+++ b/cxmanage_api/fabric.py
@@ -333,9 +333,15 @@ class Fabric(object):
'fabric_config_get_networks'
)
regex = re.compile('\d+ Network (\w+), private=(\d)')
- for line in open(filename, 'r').readlines():
- name, private = regex.findall(line)[0]
- results[name] = (int(private) != 0)
+ contents = open(filename, 'r').readlines()
+ for line in contents:
+ try:
+ name, private = regex.findall(line)[0]
+ results[name] = (int(private) != 0)
+ except IndexError:
+ raise CommandFailedException(
+ 'Unable to parse networks: %s' % '\n'.join(contents)
+ )
return results