Merge "Raise exception when no IPs found" into stable/queens

This commit is contained in:
Zuul 2019-10-12 04:41:17 +00:00 committed by Gerrit Code Review
commit 67dd88c04d
2 changed files with 9 additions and 0 deletions

View File

@ -210,6 +210,9 @@ class TripleoInventory(object):
for n in names]
# Create a group per hostname to map hostname to IP
ips = role_net_ip_map[role][self.host_network]
if not ips:
raise Exception("No IPs found for %s role on %s network"
% (role, self.host_network))
hosts = {}
for idx, name in enumerate(shortnames):
hosts[name] = {}

View File

@ -154,6 +154,12 @@ class TestInventory(base.TestCase):
self.assertTrue(self.hclient.called_once_with('overcloud',
'KeystoneURL'))
def test_no_ips(self):
for output in self.outputs_data['outputs']:
if output['output_key'] == 'RoleNetIpMap':
output['output_value'] = dict(Controller=dict(ctlplane=[]))
self.assertRaises(Exception, self.inventory.list) # noqa: H202
def test_outputs_invalid_key_raises_keyerror(self):
self.assertRaises(KeyError, lambda: self.outputs['Invalid'])