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).
``nova-manage cell_v2 list_cells [--verbose]``
Lists the v2 cells in the deployment. By default only the cell name and
uuid are shown. Use the --verbose option to see transport url and database
connection details.
By default the cell name, uuid, disabled state, masked transport URL and
database connection details are shown. Use the --verbose option to see
transport URL and database connection with their sensitive details.
``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

View File

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

View File

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