Merge "Force local connection for localhost"

This commit is contained in:
Zuul
2020-10-22 02:37:20 +00:00
committed by Gerrit Code Review
3 changed files with 5 additions and 2 deletions

View File

@@ -164,7 +164,7 @@ def _parse_config():
def _prepare_inventory():
hostvars = {}
hostvars = {"127.0.0.1": {"ansible_connection": "local"}}
groups = {}
groups.update({'baremetal': {'hosts': []}})
groups.update({'localhost': {'hosts': ["127.0.0.1"]}})

View File

@@ -53,6 +53,7 @@ class TestBifrostInventoryFunctional(base.TestCase):
"host_groups": ["baremetal", "nova"]}}""".replace('\n', '')
(groups, hostvars) = utils.bifrost_data_conversion(
yaml.safe_dump(json.loads(str(expected_hostvars))))
del hostvars['127.0.0.1']
self.assertDictEqual(json.loads(str(expected_hostvars)), hostvars)
def test_minimal_json(self):
@@ -66,4 +67,5 @@ ipmi_password":"ADMIN"}},"driver":"ipmi"}}""".replace('\n', '')
ipmi_password":"ADMIN"}},"driver":"ipmi","addressing_mode":
"dhcp","host_groups": ["baremetal"]}}""".replace('\n', '')
(groups, hostvars) = utils.bifrost_data_conversion(input_json)
del hostvars['127.0.0.1']
self.assertDictEqual(json.loads(str(expected_json)), hostvars)

View File

@@ -33,7 +33,8 @@ class TestBifrostInventoryUnit(base.TestCase):
(groups, hostvars) = inventory._prepare_inventory()
self.assertIn("baremetal", groups)
self.assertIn("localhost", groups)
self.assertDictEqual(hostvars, {})
self.assertDictEqual(
hostvars, {'127.0.0.1': {'ansible_connection': 'local'}})
localhost_value = dict(hosts=["127.0.0.1"])
self.assertDictEqual(localhost_value, groups['localhost'])