Merge "Make simple_cell_setup work when multiple nodes are present"
This commit is contained in:
commit
d23fb5ff9f
@ -1353,13 +1353,13 @@ class CellV2Commands(object):
|
||||
if not compute_nodes:
|
||||
print(_('No hosts found to map to cell, exiting.'))
|
||||
return None
|
||||
missing_nodes = []
|
||||
missing_nodes = set()
|
||||
for compute_node in compute_nodes:
|
||||
try:
|
||||
host_mapping = objects.HostMapping.get_by_host(
|
||||
ctxt, compute_node.host)
|
||||
except exception.HostMappingNotFound:
|
||||
missing_nodes.append(compute_node)
|
||||
missing_nodes.add(compute_node.host)
|
||||
else:
|
||||
if verbose:
|
||||
print(_(
|
||||
@ -1387,9 +1387,9 @@ class CellV2Commands(object):
|
||||
database_connection=CONF.database.connection)
|
||||
cell_mapping.create()
|
||||
# Pull the hosts from the cell database and create the host mappings
|
||||
for compute_node in missing_nodes:
|
||||
for compute_host in missing_nodes:
|
||||
host_mapping = objects.HostMapping(
|
||||
ctxt, host=compute_node.host, cell_mapping=cell_mapping)
|
||||
ctxt, host=compute_host, cell_mapping=cell_mapping)
|
||||
host_mapping.create()
|
||||
if verbose:
|
||||
print(cell_mapping_uuid)
|
||||
|
@ -887,6 +887,12 @@ class CellV2CommandsTestCase(test.TestCase):
|
||||
host = 'host%s' % i
|
||||
compute_node = objects.ComputeNode(ctxt, host=host, **values)
|
||||
compute_node.create()
|
||||
|
||||
# NOTE(danms): Create a second node on one compute to make sure
|
||||
# we handle that case
|
||||
compute_node = objects.ComputeNode(ctxt, host='host0', **values)
|
||||
compute_node.create()
|
||||
|
||||
# Only create 2 existing HostMappings out of 3
|
||||
for i in range(2):
|
||||
host = 'host%s' % i
|
||||
@ -903,7 +909,7 @@ class CellV2CommandsTestCase(test.TestCase):
|
||||
# Verify the output
|
||||
output = sys.stdout.getvalue().strip()
|
||||
expected = ''
|
||||
for i in range(2):
|
||||
for i in [0, 1, 0]:
|
||||
expected += ('Host host%s is already mapped to cell %s\n' %
|
||||
(i, cell_mapping_uuid))
|
||||
# The expected CellMapping UUID for the last host should be the same
|
||||
|
Loading…
x
Reference in New Issue
Block a user