Cells: Simple setup/migration command
This provides a single command for users to run if they're setting up cells on a new deployment, or migrating from non-cells and want a basic setup. Cell0 is setup on the same db host as the nova_api db. Change-Id: I73157128a3e24e49438caca1cbb19a9f5b5a7f7e
This commit is contained in:
parent
32b7526b3c
commit
a86d78f5f0
@ -1181,6 +1181,21 @@ class CellCommands(object):
|
||||
class CellV2Commands(object):
|
||||
"""Commands for managing cells v2."""
|
||||
|
||||
# TODO(melwitt): Remove this when the oslo.messaging function
|
||||
# for assembling a transport url from ConfigOpts is available
|
||||
@args('--transport-url', metavar='<transport url>', required=True,
|
||||
dest='transport_url',
|
||||
help='The transport url for the cell message queue')
|
||||
def simple_cell_setup(self, transport_url):
|
||||
cell_uuid = self._map_cell_and_hosts(transport_url)
|
||||
if cell_uuid is None:
|
||||
# There are no compute hosts which means no cell_mapping was
|
||||
# created. This should also mean that there are no instances.
|
||||
return 1
|
||||
self.map_cell0()
|
||||
self.map_instances(cell_uuid)
|
||||
return 0
|
||||
|
||||
@args('--database_connection',
|
||||
metavar='<database_connection>',
|
||||
help='The database connection url for cell0. '
|
||||
|
@ -1088,3 +1088,47 @@ class CellV2CommandsTestCase(test.TestCase):
|
||||
self.assertEqual('none:///', cell_mapping.transport_url)
|
||||
self.assertEqual('fake://netloc/nova_api_cell0',
|
||||
cell_mapping.database_connection)
|
||||
|
||||
def test_migrate_single_command(self):
|
||||
ctxt = context.RequestContext()
|
||||
CONF.set_default('connection',
|
||||
'fake://netloc/nova_api',
|
||||
group='api_database')
|
||||
values = {
|
||||
'vcpus': 4,
|
||||
'memory_mb': 4096,
|
||||
'local_gb': 1024,
|
||||
'vcpus_used': 2,
|
||||
'memory_mb_used': 2048,
|
||||
'local_gb_used': 512,
|
||||
'hypervisor_type': 'Hyper-Dan-VM-ware',
|
||||
'hypervisor_version': 1001,
|
||||
'cpu_info': 'Schmintel i786',
|
||||
}
|
||||
for i in range(3):
|
||||
host = 'host%s' % i
|
||||
compute_node = objects.ComputeNode(ctxt, host=host, **values)
|
||||
compute_node.create()
|
||||
|
||||
transport_url = "fake://guest:devstack@127.0.0.1:9999/"
|
||||
cell_uuid = uuidutils.generate_uuid()
|
||||
with mock.patch.object(uuidutils, 'generate_uuid',
|
||||
return_value=cell_uuid):
|
||||
self.commands.simple_cell_setup(transport_url)
|
||||
|
||||
# Check cell0 from default
|
||||
cell_mapping = objects.CellMapping.get_by_uuid(ctxt,
|
||||
objects.CellMapping.CELL0_UUID)
|
||||
self.assertEqual('cell0', cell_mapping.name)
|
||||
self.assertEqual('none:///', cell_mapping.transport_url)
|
||||
self.assertEqual('fake://netloc/nova_api_cell0',
|
||||
cell_mapping.database_connection)
|
||||
|
||||
# Verify the cell mapping
|
||||
cell_mapping = objects.CellMapping.get_by_uuid(ctxt, cell_uuid)
|
||||
self.assertEqual(transport_url, cell_mapping.transport_url)
|
||||
# Verify the host mappings
|
||||
for i in range(3):
|
||||
host = 'host%s' % i
|
||||
host_mapping = objects.HostMapping.get_by_host(ctxt, host)
|
||||
self.assertEqual(cell_mapping.uuid, host_mapping.cell_mapping.uuid)
|
||||
|
@ -0,0 +1,13 @@
|
||||
---
|
||||
upgrade:
|
||||
- A new nova-manage command has been added which will upgrade a deployment to
|
||||
cells v2. Running the command will setup a single cell containing the
|
||||
existing hosts and instances. No data or instances will be moved during
|
||||
this operation, but new data will be added to the nova_api database. New
|
||||
instances booted after this point will be placed into the cell. Please
|
||||
note that this does not mean that cells v2 is fully functional at this
|
||||
time, but this is a significant part of the effort to get there.
|
||||
The new command is
|
||||
"nova-manage cell_v2 simple_cell_setup --transport_url <transport_url>"
|
||||
where transport_url is the connection information for the current message
|
||||
queue used by Nova.
|
Loading…
Reference in New Issue
Block a user