Merge "Improve bifrost inventory module"
This commit is contained in:
commit
e490f27ada
@ -171,15 +171,10 @@ def _process_baremetal_data(data_source, groups, hostvars):
|
||||
"""Process data through as pre-formatted data"""
|
||||
with open(data_source, 'rb') as file_object:
|
||||
try:
|
||||
file_data = json.load(file_object)
|
||||
file_data = yaml.safe_load(file_object)
|
||||
except Exception as e:
|
||||
LOG.debug("Attempting to parse JSON: %s" % e)
|
||||
try:
|
||||
file_object.seek(0)
|
||||
file_data = yaml.load(file_object)
|
||||
except Exception as e:
|
||||
LOG.debug("Attempting to parse YAML: %s" % e)
|
||||
raise Exception("Failed to parse JSON and YAML")
|
||||
LOG.debug("Failed to parse JSON or YAML: %s" % e)
|
||||
raise Exception("Failed to parse JSON or YAML")
|
||||
|
||||
for name in file_data:
|
||||
host = file_data[name]
|
||||
|
@ -208,7 +208,7 @@ unused,,00000000-0000-0000-0000-000000000002,hostname1,
|
||||
[{"mac": "00:01:02:03:04:05"}], "properties": {"ram": "8192",
|
||||
"cpu_arch": "x86_64", "disk_size": "512", "cpus": "1"}}}""".replace('\n', '')
|
||||
(groups, hostvars) = utils.bifrost_data_conversion(
|
||||
yaml.dump(json.loads(str(expected_hostvars))))
|
||||
yaml.safe_dump(json.loads(str(expected_hostvars))))
|
||||
self.assertDictEqual(json.loads(str(expected_hostvars)), hostvars)
|
||||
|
||||
def test_minimal_json(self):
|
||||
|
Loading…
Reference in New Issue
Block a user