Skip to content

Commit a4792bb

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "db: Remove cell APIs"
2 parents 2ea6e6f + dbc5dfa commit a4792bb

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
@@ -4581,51 +4581,6 @@ def console_get(context, console_id, instance_uuid=None):
45814581
return result
45824582

45834583

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

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
@@ -1282,14 +1282,6 @@ class FlavorExtraSpecUpdateCreateFailed(NovaException):
12821282
"after %(retries)d retries.")
12831283

12841284

1285-
class CellNotFound(NotFound):
1286-
msg_fmt = _("Cell %(cell_name)s doesn't exist.")
1287-
1288-
1289-
class CellExists(NovaException):
1290-
msg_fmt = _("Cell with name %(name)s already exists.")
1291-
1292-
12931285
class CellTimeout(NotFound):
12941286
msg_fmt = _("Timeout waiting for response from cell")
12951287

nova/tests/unit/db/test_db_api.py

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

79257925

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

0 commit comments

Comments
 (0)