Merge "Make inventory plugin errors visible"

This commit is contained in:
Jenkins 2015-07-10 11:28:39 +00:00 committed by Gerrit Code Review
commit c5837dcc79

View File

@ -326,14 +326,14 @@ def main():
config = _parse_config()
if not config.list:
print("ERROR: This program must be executed in list mode.")
LOG.error("This program must be executed in list mode.")
exit(1)
(groups, hostvars) = _prepare_inventory()
if 'BIFROST_INVENTORY_SOURCE' not in os.environ:
print('ERROR: Please define a BIFROST_INVENTORY_SOURCE environment '
'variable with a comma separated list of data sources')
LOG.error('Please define a BIFROST_INVENTORY_SOURCE environment'
'variable with a comma separated list of data sources')
exit(1)
try:
@ -345,7 +345,7 @@ def main():
groups,
hostvars)
except Exception as e:
LOG.debug("File does not appear to be JSON or YAML - %s" % e)
LOG.error("File does not appear to be JSON or YAML - %s" % e)
try:
(groups, hostvars) = _process_baremetal_csv(
data_source,
@ -354,24 +354,24 @@ def main():
except Exception as e:
LOG.debug("CSV fallback processing failed, "
"received: &s" % e)
print("ERROR: BIFROST_INVENTORY_SOURCE does not "
"define a file that could be processed: "
"Tried JSON, YAML, and CSV formats")
LOG.error("BIFROST_INVENTORY_SOURCE does not define "
"a file that could be processed: "
"Tried JSON, YAML, and CSV formats")
exit(1)
elif "ironic" in data_source:
if SHADE_LOADED:
(groups, hostvars) = _process_shade(groups, hostvars)
else:
print("ERROR: BIFROST_INVENTORY_SOURCE is set to ironic "
"however the shade library failed to load, and may "
"not be present.")
LOG.error("BIFROST_INVENTORY_SOURCE is set to ironic "
"however the shade library failed to load, and may "
"not be present.")
exit(1)
else:
print('ERROR: BIFROST_INVENTORY_SOURCE does not define a file')
LOG.error('BIFROST_INVENTORY_SOURCE does not define a file')
exit(1)
except Exception as error:
print('ERROR: Failed processing: %s' % error)
LOG.error('Failed processing: %s' % error)
exit(1)
# General Data Conversion