Skip to content

Commit dbc5dfa

Browse files
committed
db: Remove cell APIs
These are no longer needed. We can't actually remove the 'cells' table yet (that has to wait another release or two) but a TODO is added to ensure this eventually happens. The 'CellExists' and 'CellNotFound' exceptions, which were only raised by these APIs, are removed. Part of blueprint remove-cells-v1 Change-Id: Ibc402b446c9b92ce03a1dd98f41ec6cf5db20642 Signed-off-by: Stephen Finucane <[email protected]>
1 parent 7166482 commit dbc5dfa

File tree

5 files changed

+3
-178
lines changed

5 files changed

+3
-178
lines changed

nova/db/api.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,33 +1521,6 @@ def pci_device_update(context, node_id, address, value):
15211521
return IMPL.pci_device_update(context, node_id, address, value)
15221522

15231523

1524-
###################
1525-
1526-
def cell_create(context, values):
1527-
"""Create a new child Cell entry."""
1528-
return IMPL.cell_create(context, values)
1529-
1530-
1531-
def cell_update(context, cell_name, values):
1532-
"""Update a child Cell entry."""
1533-
return IMPL.cell_update(context, cell_name, values)
1534-
1535-
1536-
def cell_delete(context, cell_name):
1537-
"""Delete a child Cell."""
1538-
return IMPL.cell_delete(context, cell_name)
1539-
1540-
1541-
def cell_get(context, cell_name):
1542-
"""Get a specific child Cell."""
1543-
return IMPL.cell_get(context, cell_name)
1544-
1545-
1546-
def cell_get_all(context):
1547-
"""Get all child Cells."""
1548-
return IMPL.cell_get_all(context)
1549-
1550-
15511524
####################
15521525

15531526

nova/db/sqlalchemy/api.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4577,51 +4577,6 @@ def console_get(context, console_id, instance_uuid=None):
45774577
return result
45784578

45794579

4580-
##################
4581-
4582-
4583-
@pick_context_manager_writer
4584-
def cell_create(context, values):
4585-
cell = models.Cell()
4586-
cell.update(values)
4587-
try:
4588-
cell.save(context.session)
4589-
except db_exc.DBDuplicateEntry:
4590-
raise exception.CellExists(name=values['name'])
4591-
return cell
4592-
4593-
4594-
def _cell_get_by_name_query(context, cell_name):
4595-
return model_query(context, models.Cell).filter_by(name=cell_name)
4596-
4597-
4598-
@pick_context_manager_writer
4599-
def cell_update(context, cell_name, values):
4600-
cell_query = _cell_get_by_name_query(context, cell_name)
4601-
if not cell_query.update(values):
4602-
raise exception.CellNotFound(cell_name=cell_name)
4603-
cell = cell_query.first()
4604-
return cell
4605-
4606-
4607-
@pick_context_manager_writer
4608-
def cell_delete(context, cell_name):
4609-
return _cell_get_by_name_query(context, cell_name).soft_delete()
4610-
4611-
4612-
@pick_context_manager_reader
4613-
def cell_get(context, cell_name):
4614-
result = _cell_get_by_name_query(context, cell_name).first()
4615-
if not result:
4616-
raise exception.CellNotFound(cell_name=cell_name)
4617-
return result
4618-
4619-
4620-
@pick_context_manager_reader
4621-
def cell_get_all(context):
4622-
return model_query(context, models.Cell, read_deleted="no").all()
4623-
4624-
46254580
########################
46264581
# User-provided metadata
46274582

nova/db/sqlalchemy/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ def _extra_keys(self):
340340

341341
# OpenStack compute cell name. This will only be set at the top of
342342
# the cells tree and it'll be a full cell name such as 'api!hop1!hop2'
343+
# TODO(stephenfin): Remove this
343344
cell_name = Column(String(255))
344345

345346
# NOTE(pumaranikar): internal_id attribute is no longer used (bug 1441242)
@@ -1088,6 +1089,8 @@ class InstanceTypeExtraSpecs(BASE, NovaBase, models.SoftDeleteMixin):
10881089
'InstanceTypeExtraSpecs.deleted == 0)')
10891090

10901091

1092+
# TODO(stephenfin): Remove this in the U release or later, once we're sure we
1093+
# won't want it back (it's for cells v1, so we won't)
10911094
class Cell(BASE, NovaBase, models.SoftDeleteMixin):
10921095
"""Represents parent and child cells of this cell. Cells can
10931096
have multiple parents and children, so there could be any number

nova/exception.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,14 +1277,6 @@ class FlavorExtraSpecUpdateCreateFailed(NovaException):
12771277
"after %(retries)d retries.")
12781278

12791279

1280-
class CellNotFound(NotFound):
1281-
msg_fmt = _("Cell %(cell_name)s doesn't exist.")
1282-
1283-
1284-
class CellExists(NovaException):
1285-
msg_fmt = _("Cell with name %(name)s already exists.")
1286-
1287-
12881280
class CellTimeout(NotFound):
12891281
msg_fmt = _("Timeout waiting for response from cell")
12901282

nova/tests/unit/db/test_db_api.py

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -7909,104 +7909,6 @@ def test_console_get_not_found_instance(self):
79097909
uuidsentinel.uuid2)
79107910

79117911

7912-
class CellTestCase(test.TestCase, ModelsObjectComparatorMixin):
7913-
7914-
_ignored_keys = ['id', 'deleted', 'deleted_at', 'created_at', 'updated_at']
7915-
7916-
def setUp(self):
7917-
super(CellTestCase, self).setUp()
7918-
self.ctxt = context.get_admin_context()
7919-
7920-
def _get_cell_base_values(self):
7921-
return {
7922-
'name': 'myname',
7923-
'api_url': 'apiurl',
7924-
'transport_url': 'transporturl',
7925-
'weight_offset': 0.5,
7926-
'weight_scale': 1.5,
7927-
'is_parent': True,
7928-
}
7929-
7930-
def _cell_value_modify(self, value, step):
7931-
if isinstance(value, six.string_types):
7932-
return value + str(step)
7933-
elif isinstance(value, float):
7934-
return value + step + 0.6
7935-
elif isinstance(value, bool):
7936-
return bool(step % 2)
7937-
elif isinstance(value, int):
7938-
return value + step
7939-
7940-
def _create_cells(self):
7941-
test_values = []
7942-
for x in range(1, 4):
7943-
modified_val = {k: self._cell_value_modify(v, x)
7944-
for k, v in self._get_cell_base_values().items()}
7945-
db.cell_create(self.ctxt, modified_val)
7946-
test_values.append(modified_val)
7947-
return test_values
7948-
7949-
def test_cell_create(self):
7950-
cell = db.cell_create(self.ctxt, self._get_cell_base_values())
7951-
self.assertIsNotNone(cell['id'])
7952-
self._assertEqualObjects(cell, self._get_cell_base_values(),
7953-
ignored_keys=self._ignored_keys)
7954-
7955-
def test_cell_update(self):
7956-
db.cell_create(self.ctxt, self._get_cell_base_values())
7957-
new_values = {
7958-
'api_url': 'apiurl1',
7959-
'transport_url': 'transporturl1',
7960-
'weight_offset': 0.6,
7961-
'weight_scale': 1.6,
7962-
'is_parent': False,
7963-
}
7964-
test_cellname = self._get_cell_base_values()['name']
7965-
updated_cell = db.cell_update(self.ctxt, test_cellname, new_values)
7966-
self._assertEqualObjects(updated_cell, new_values,
7967-
ignored_keys=self._ignored_keys + ['name'])
7968-
7969-
def test_cell_delete(self):
7970-
new_cells = self._create_cells()
7971-
for cell in new_cells:
7972-
test_cellname = cell['name']
7973-
db.cell_delete(self.ctxt, test_cellname)
7974-
self.assertRaises(exception.CellNotFound, db.cell_get, self.ctxt,
7975-
test_cellname)
7976-
7977-
def test_cell_get(self):
7978-
new_cells = self._create_cells()
7979-
for cell in new_cells:
7980-
cell_get = db.cell_get(self.ctxt, cell['name'])
7981-
self._assertEqualObjects(cell_get, cell,
7982-
ignored_keys=self._ignored_keys)
7983-
7984-
def test_cell_get_all(self):
7985-
new_cells = self._create_cells()
7986-
cells = db.cell_get_all(self.ctxt)
7987-
self.assertEqual(len(new_cells), len(cells))
7988-
cells_byname = {newcell['name']: newcell
7989-
for newcell in new_cells}
7990-
for cell in cells:
7991-
self._assertEqualObjects(cell, cells_byname[cell['name']],
7992-
self._ignored_keys)
7993-
7994-
def test_cell_get_not_found(self):
7995-
self._create_cells()
7996-
self.assertRaises(exception.CellNotFound, db.cell_get, self.ctxt,
7997-
'cellnotinbase')
7998-
7999-
def test_cell_update_not_found(self):
8000-
self._create_cells()
8001-
self.assertRaises(exception.CellNotFound, db.cell_update, self.ctxt,
8002-
'cellnotinbase', self._get_cell_base_values())
8003-
8004-
def test_cell_create_exists(self):
8005-
db.cell_create(self.ctxt, self._get_cell_base_values())
8006-
self.assertRaises(exception.CellExists, db.cell_create,
8007-
self.ctxt, self._get_cell_base_values())
8008-
8009-
80107912
class ConsolePoolTestCase(test.TestCase, ModelsObjectComparatorMixin):
80117913
def setUp(self):
80127914
super(ConsolePoolTestCase, self).setUp()

0 commit comments

Comments
 (0)