Merge "Prevent delete cell0 in nova-manage command"
This commit is contained in:
commit
6f66119153
@ -1464,11 +1464,17 @@ class CellV2Commands(object):
|
|||||||
def delete_cell(self, cell_uuid):
|
def delete_cell(self, cell_uuid):
|
||||||
"""Delete an empty cell by the given uuid.
|
"""Delete an empty cell by the given uuid.
|
||||||
|
|
||||||
|
If the cell is cell0 this command will return a non-zero exit code.
|
||||||
|
|
||||||
If the cell is not found by uuid or it is not empty (it has host or
|
If the cell is not found by uuid or it is not empty (it has host or
|
||||||
instance mappings) this command will return a non-zero exit code.
|
instance mappings) this command will return a non-zero exit code.
|
||||||
|
|
||||||
Returns 0 if the empty cell is found and deleted successfully.
|
Returns 0 if the empty cell is found and deleted successfully.
|
||||||
"""
|
"""
|
||||||
|
if cell_uuid == objects.CellMapping.CELL0_UUID:
|
||||||
|
print(_('Cell 0 can not be deleted.'))
|
||||||
|
return 5
|
||||||
|
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
# Find the CellMapping given the uuid.
|
# Find the CellMapping given the uuid.
|
||||||
try:
|
try:
|
||||||
|
@ -1484,6 +1484,12 @@ class CellV2CommandsTestCase(test.NoDBTestCase):
|
|||||||
self.assertEqual('Cell with uuid %s was not found.' % cell_uuid,
|
self.assertEqual('Cell with uuid %s was not found.' % cell_uuid,
|
||||||
output)
|
output)
|
||||||
|
|
||||||
|
def test_delete_cell_cell0(self):
|
||||||
|
cell_uuid = objects.CellMapping.CELL0_UUID
|
||||||
|
self.assertEqual(5, self.commands.delete_cell(cell_uuid))
|
||||||
|
output = self.output.getvalue().strip()
|
||||||
|
self.assertEqual('Cell 0 can not be deleted.', output)
|
||||||
|
|
||||||
def test_delete_cell_host_mappings_exist(self):
|
def test_delete_cell_host_mappings_exist(self):
|
||||||
"""Tests trying to delete a cell which has host mappings."""
|
"""Tests trying to delete a cell which has host mappings."""
|
||||||
cell_uuid = uuidutils.generate_uuid()
|
cell_uuid = uuidutils.generate_uuid()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user