diff --git a/doc/source/man/nova-manage.rst b/doc/source/man/nova-manage.rst index 67797f23b407..f6258c5e4b2b 100644 --- a/doc/source/man/nova-manage.rst +++ b/doc/source/man/nova-manage.rst @@ -165,10 +165,14 @@ Nova Cells v2 ``nova-manage cell_v2 update_cell --cell_uuid [--name ] [--transport-url ] [--database_connection ]`` - Updates the properties of a cell by the given uuid. If the cell is not - found by uuid, this command will return an exit code of 1. If the - properties cannot be set, this will return 2. Otherwise, the exit code - will be 0. + Updates the properties of a cell by the given uuid. If a + database_connection is not specified, it will attempt to use the one + defined by ``[database]/connection`` in the configuration file. If a + transport_url is not specified, it will attempt to use the one defined + by ``[DEFAULT]/transport_url`` in the configuration file. If the cell + is not found by uuid, this command will return an exit code of 1. If + the properties cannot be set, this will return 2. Otherwise, the exit + code will be 0. NOTE: Updating the transport_url or database_connection fields on a running system will NOT result in all nodes immediately using the diff --git a/nova/cmd/manage.py b/nova/cmd/manage.py index 3954a2594b03..9e4e74151e82 100644 --- a/nova/cmd/manage.py +++ b/nova/cmd/manage.py @@ -1506,7 +1506,8 @@ class CellV2Commands(object): @args('--database_connection', metavar='', dest='db_connection', help=_('Set the cell database_connection. NOTE that running nodes ' 'will not see the change until restart!')) - def update_cell(self, cell_uuid, name, transport_url, db_connection): + def update_cell(self, cell_uuid, name=None, transport_url=None, + db_connection=None): """Updates the properties of a cell by the given uuid. If the cell is not found by uuid, this command will return an exit @@ -1526,8 +1527,12 @@ class CellV2Commands(object): if name: cell_mapping.name = name + + transport_url = transport_url or CONF.transport_url if transport_url: cell_mapping.transport_url = transport_url + + db_connection = db_connection or CONF.database.connection if db_connection: cell_mapping.database_connection = db_connection diff --git a/nova/tests/unit/test_nova_manage.py b/nova/tests/unit/test_nova_manage.py index a6f6cd83f559..8d8e3df882f1 100644 --- a/nova/tests/unit/test_nova_manage.py +++ b/nova/tests/unit/test_nova_manage.py @@ -1564,6 +1564,22 @@ class CellV2CommandsTestCase(test.NoDBTestCase): output = self.output.getvalue().strip() self.assertEqual('', output) + def test_update_cell_success_defaults(self): + ctxt = context.get_admin_context() + objects.CellMapping(context=ctxt, uuid=uuidsentinel.cell1, + name='cell1', + transport_url='fake://mq', + database_connection='fake:///db').create() + self.assertEqual(0, self.commands.update_cell(uuidsentinel.cell1)) + cm = objects.CellMapping.get_by_uuid(ctxt, uuidsentinel.cell1) + self.assertEqual('cell1', cm.name) + expected_transport_url = CONF.transport_url or 'fake://mq' + self.assertEqual(expected_transport_url, cm.transport_url) + expected_db_connection = CONF.database.connection or 'fake:///db' + self.assertEqual(expected_db_connection, cm.database_connection) + output = self.output.getvalue().strip() + self.assertEqual('', output) + class TestNovaManageMain(test.NoDBTestCase): """Tests the nova-manage:main() setup code."""