Merge "Modify nova-manage cell_v2 list_cells to display "disabled" column"

This commit is contained in:
Zuul 2018-03-26 13:11:28 +00:00 committed by Gerrit Code Review
commit 7672472998
3 changed files with 23 additions and 20 deletions

View File

@ -214,9 +214,9 @@ Nova Cells v2
given time (currently only ironic). given time (currently only ironic).
``nova-manage cell_v2 list_cells [--verbose]`` ``nova-manage cell_v2 list_cells [--verbose]``
Lists the v2 cells in the deployment. By default only the cell name and By default the cell name, uuid, disabled state, masked transport URL and
uuid are shown. Use the --verbose option to see transport url and database database connection details are shown. Use the --verbose option to see
connection details. transport URL and database connection with their sensitive details.
``nova-manage cell_v2 delete_cell [--force] --cell_uuid <cell_uuid>`` ``nova-manage cell_v2 delete_cell [--force] --cell_uuid <cell_uuid>``
Delete a cell by the given uuid. Returns 0 if the empty cell is found and Delete a cell by the given uuid. Returns 0 if the empty cell is found and

View File

@ -1416,14 +1416,16 @@ class CellV2Commands(object):
def list_cells(self, verbose=False): def list_cells(self, verbose=False):
"""Lists the v2 cells in the deployment. """Lists the v2 cells in the deployment.
By default only the cell name and uuid are shown. Use the --verbose By default the cell name, uuid, disabled state, masked transport
option to see transport URL and database connection details. URL and database connection details are shown. Use the --verbose
option to see transport URL and database connection with their
sensitive details.
""" """
cell_mappings = objects.CellMappingList.get_all( cell_mappings = objects.CellMappingList.get_all(
context.get_admin_context()) context.get_admin_context())
field_names = [_('Name'), _('UUID'), _('Transport URL'), field_names = [_('Name'), _('UUID'), _('Transport URL'),
_('Database Connection')] _('Database Connection'), _('Disabled')]
t = prettytable.PrettyTable(field_names) t = prettytable.PrettyTable(field_names)
for cell in sorted(cell_mappings, key=lambda _cell: _cell.name): for cell in sorted(cell_mappings, key=lambda _cell: _cell.name):
@ -1434,6 +1436,7 @@ class CellV2Commands(object):
fields.extend([ fields.extend([
mask_passwd_in_url(cell.transport_url), mask_passwd_in_url(cell.transport_url),
mask_passwd_in_url(cell.database_connection)]) mask_passwd_in_url(cell.database_connection)])
fields.extend([cell.disabled])
t.add_row(fields) t.add_row(fields)
print(t) print(t)
return 0 return 0

View File

@ -1769,12 +1769,12 @@ class CellV2CommandsTestCase(test.NoDBTestCase):
self.assertEqual(0, self.commands.list_cells()) self.assertEqual(0, self.commands.list_cells())
output = self.output.getvalue().strip() output = self.output.getvalue().strip()
self.assertEqual('''\ self.assertEqual('''\
+-------+--------------------------------------+---------------------------+-----------------------------+ +-------+--------------------------------------+---------------------------+-----------------------------+----------+
| Name | UUID | Transport URL | Database Connection | | Name | UUID | Transport URL | Database Connection | Disabled |
+-------+--------------------------------------+---------------------------+-----------------------------+ +-------+--------------------------------------+---------------------------+-----------------------------+----------+
| cell0 | %(uuid_map0)s | none://user1:****@host1/ | fake://user1:****@host1/db0 | | cell0 | %(uuid_map0)s | none://user1:****@host1/ | fake://user1:****@host1/db0 | False |
| cell1 | %(uuid_map1)s | none://user1@host1/vhost1 | fake://user1@host1/db0 | | cell1 | %(uuid_map1)s | none://user1@host1/vhost1 | fake://user1@host1/db0 | False |
+-------+--------------------------------------+---------------------------+-----------------------------+''' % # noqa +-------+--------------------------------------+---------------------------+-----------------------------+----------+''' % # noqa
{"uuid_map0": uuidsentinel.map0, {"uuid_map0": uuidsentinel.map0,
"uuid_map1": uuidsentinel.map1}, "uuid_map1": uuidsentinel.map1},
output) output)
@ -1789,7 +1789,7 @@ class CellV2CommandsTestCase(test.NoDBTestCase):
cell_mapping1 = objects.CellMapping( cell_mapping1 = objects.CellMapping(
context=ctxt, uuid=uuidsentinel.map1, context=ctxt, uuid=uuidsentinel.map1,
database_connection='fake:///dblon', transport_url='fake:///mqlon', database_connection='fake:///dblon', transport_url='fake:///mqlon',
name='london') name='london', disabled=True)
cell_mapping1.create() cell_mapping1.create()
cell_mapping2 = objects.CellMapping( cell_mapping2 = objects.CellMapping(
context=ctxt, uuid=uuidsentinel.map2, context=ctxt, uuid=uuidsentinel.map2,
@ -1799,13 +1799,13 @@ class CellV2CommandsTestCase(test.NoDBTestCase):
self.assertEqual(0, self.commands.list_cells(verbose=True)) self.assertEqual(0, self.commands.list_cells(verbose=True))
output = self.output.getvalue().strip() output = self.output.getvalue().strip()
self.assertEqual('''\ self.assertEqual('''\
+--------+--------------------------------------+---------------+---------------------+ +--------+--------------------------------------+---------------+---------------------+----------+
| Name | UUID | Transport URL | Database Connection | | Name | UUID | Transport URL | Database Connection | Disabled |
+--------+--------------------------------------+---------------+---------------------+ +--------+--------------------------------------+---------------+---------------------+----------+
| cell0 | %(uuid_map0)s | none:/// | fake:///db0 | | cell0 | %(uuid_map0)s | none:/// | fake:///db0 | False |
| dallas | %(uuid_map2)s | fake:///mqdal | fake:///dbdal | | dallas | %(uuid_map2)s | fake:///mqdal | fake:///dbdal | False |
| london | %(uuid_map1)s | fake:///mqlon | fake:///dblon | | london | %(uuid_map1)s | fake:///mqlon | fake:///dblon | True |
+--------+--------------------------------------+---------------+---------------------+''' % # noqa +--------+--------------------------------------+---------------+---------------------+----------+''' % # noqa
{"uuid_map0": uuidsentinel.map0, {"uuid_map0": uuidsentinel.map0,
"uuid_map1": uuidsentinel.map1, "uuid_map1": uuidsentinel.map1,
"uuid_map2": uuidsentinel.map2}, "uuid_map2": uuidsentinel.map2},