Merge "db: Remove cell APIs"
This commit is contained in:
commit
a4792bba40
nova
@ -1521,33 +1521,6 @@ def pci_device_update(context, node_id, address, value):
|
||||
return IMPL.pci_device_update(context, node_id, address, value)
|
||||
|
||||
|
||||
###################
|
||||
|
||||
def cell_create(context, values):
|
||||
"""Create a new child Cell entry."""
|
||||
return IMPL.cell_create(context, values)
|
||||
|
||||
|
||||
def cell_update(context, cell_name, values):
|
||||
"""Update a child Cell entry."""
|
||||
return IMPL.cell_update(context, cell_name, values)
|
||||
|
||||
|
||||
def cell_delete(context, cell_name):
|
||||
"""Delete a child Cell."""
|
||||
return IMPL.cell_delete(context, cell_name)
|
||||
|
||||
|
||||
def cell_get(context, cell_name):
|
||||
"""Get a specific child Cell."""
|
||||
return IMPL.cell_get(context, cell_name)
|
||||
|
||||
|
||||
def cell_get_all(context):
|
||||
"""Get all child Cells."""
|
||||
return IMPL.cell_get_all(context)
|
||||
|
||||
|
||||
####################
|
||||
|
||||
|
||||
|
@ -4581,51 +4581,6 @@ def console_get(context, console_id, instance_uuid=None):
|
||||
return result
|
||||
|
||||
|
||||
##################
|
||||
|
||||
|
||||
@pick_context_manager_writer
|
||||
def cell_create(context, values):
|
||||
cell = models.Cell()
|
||||
cell.update(values)
|
||||
try:
|
||||
cell.save(context.session)
|
||||
except db_exc.DBDuplicateEntry:
|
||||
raise exception.CellExists(name=values['name'])
|
||||
return cell
|
||||
|
||||
|
||||
def _cell_get_by_name_query(context, cell_name):
|
||||
return model_query(context, models.Cell).filter_by(name=cell_name)
|
||||
|
||||
|
||||
@pick_context_manager_writer
|
||||
def cell_update(context, cell_name, values):
|
||||
cell_query = _cell_get_by_name_query(context, cell_name)
|
||||
if not cell_query.update(values):
|
||||
raise exception.CellNotFound(cell_name=cell_name)
|
||||
cell = cell_query.first()
|
||||
return cell
|
||||
|
||||
|
||||
@pick_context_manager_writer
|
||||
def cell_delete(context, cell_name):
|
||||
return _cell_get_by_name_query(context, cell_name).soft_delete()
|
||||
|
||||
|
||||
@pick_context_manager_reader
|
||||
def cell_get(context, cell_name):
|
||||
result = _cell_get_by_name_query(context, cell_name).first()
|
||||
if not result:
|
||||
raise exception.CellNotFound(cell_name=cell_name)
|
||||
return result
|
||||
|
||||
|
||||
@pick_context_manager_reader
|
||||
def cell_get_all(context):
|
||||
return model_query(context, models.Cell, read_deleted="no").all()
|
||||
|
||||
|
||||
########################
|
||||
# User-provided metadata
|
||||
|
||||
|
@ -340,6 +340,7 @@ class Instance(BASE, NovaBase, models.SoftDeleteMixin):
|
||||
|
||||
# OpenStack compute cell name. This will only be set at the top of
|
||||
# the cells tree and it'll be a full cell name such as 'api!hop1!hop2'
|
||||
# TODO(stephenfin): Remove this
|
||||
cell_name = Column(String(255))
|
||||
|
||||
# NOTE(pumaranikar): internal_id attribute is no longer used (bug 1441242)
|
||||
@ -1088,6 +1089,8 @@ class InstanceTypeExtraSpecs(BASE, NovaBase, models.SoftDeleteMixin):
|
||||
'InstanceTypeExtraSpecs.deleted == 0)')
|
||||
|
||||
|
||||
# TODO(stephenfin): Remove this in the U release or later, once we're sure we
|
||||
# won't want it back (it's for cells v1, so we won't)
|
||||
class Cell(BASE, NovaBase, models.SoftDeleteMixin):
|
||||
"""Represents parent and child cells of this cell. Cells can
|
||||
have multiple parents and children, so there could be any number
|
||||
|
@ -1282,14 +1282,6 @@ class FlavorExtraSpecUpdateCreateFailed(NovaException):
|
||||
"after %(retries)d retries.")
|
||||
|
||||
|
||||
class CellNotFound(NotFound):
|
||||
msg_fmt = _("Cell %(cell_name)s doesn't exist.")
|
||||
|
||||
|
||||
class CellExists(NovaException):
|
||||
msg_fmt = _("Cell with name %(name)s already exists.")
|
||||
|
||||
|
||||
class CellTimeout(NotFound):
|
||||
msg_fmt = _("Timeout waiting for response from cell")
|
||||
|
||||
|
@ -7923,104 +7923,6 @@ class ConsoleTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
uuidsentinel.uuid2)
|
||||
|
||||
|
||||
class CellTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
_ignored_keys = ['id', 'deleted', 'deleted_at', 'created_at', 'updated_at']
|
||||
|
||||
def setUp(self):
|
||||
super(CellTestCase, self).setUp()
|
||||
self.ctxt = context.get_admin_context()
|
||||
|
||||
def _get_cell_base_values(self):
|
||||
return {
|
||||
'name': 'myname',
|
||||
'api_url': 'apiurl',
|
||||
'transport_url': 'transporturl',
|
||||
'weight_offset': 0.5,
|
||||
'weight_scale': 1.5,
|
||||
'is_parent': True,
|
||||
}
|
||||
|
||||
def _cell_value_modify(self, value, step):
|
||||
if isinstance(value, six.string_types):
|
||||
return value + str(step)
|
||||
elif isinstance(value, float):
|
||||
return value + step + 0.6
|
||||
elif isinstance(value, bool):
|
||||
return bool(step % 2)
|
||||
elif isinstance(value, int):
|
||||
return value + step
|
||||
|
||||
def _create_cells(self):
|
||||
test_values = []
|
||||
for x in range(1, 4):
|
||||
modified_val = {k: self._cell_value_modify(v, x)
|
||||
for k, v in self._get_cell_base_values().items()}
|
||||
db.cell_create(self.ctxt, modified_val)
|
||||
test_values.append(modified_val)
|
||||
return test_values
|
||||
|
||||
def test_cell_create(self):
|
||||
cell = db.cell_create(self.ctxt, self._get_cell_base_values())
|
||||
self.assertIsNotNone(cell['id'])
|
||||
self._assertEqualObjects(cell, self._get_cell_base_values(),
|
||||
ignored_keys=self._ignored_keys)
|
||||
|
||||
def test_cell_update(self):
|
||||
db.cell_create(self.ctxt, self._get_cell_base_values())
|
||||
new_values = {
|
||||
'api_url': 'apiurl1',
|
||||
'transport_url': 'transporturl1',
|
||||
'weight_offset': 0.6,
|
||||
'weight_scale': 1.6,
|
||||
'is_parent': False,
|
||||
}
|
||||
test_cellname = self._get_cell_base_values()['name']
|
||||
updated_cell = db.cell_update(self.ctxt, test_cellname, new_values)
|
||||
self._assertEqualObjects(updated_cell, new_values,
|
||||
ignored_keys=self._ignored_keys + ['name'])
|
||||
|
||||
def test_cell_delete(self):
|
||||
new_cells = self._create_cells()
|
||||
for cell in new_cells:
|
||||
test_cellname = cell['name']
|
||||
db.cell_delete(self.ctxt, test_cellname)
|
||||
self.assertRaises(exception.CellNotFound, db.cell_get, self.ctxt,
|
||||
test_cellname)
|
||||
|
||||
def test_cell_get(self):
|
||||
new_cells = self._create_cells()
|
||||
for cell in new_cells:
|
||||
cell_get = db.cell_get(self.ctxt, cell['name'])
|
||||
self._assertEqualObjects(cell_get, cell,
|
||||
ignored_keys=self._ignored_keys)
|
||||
|
||||
def test_cell_get_all(self):
|
||||
new_cells = self._create_cells()
|
||||
cells = db.cell_get_all(self.ctxt)
|
||||
self.assertEqual(len(new_cells), len(cells))
|
||||
cells_byname = {newcell['name']: newcell
|
||||
for newcell in new_cells}
|
||||
for cell in cells:
|
||||
self._assertEqualObjects(cell, cells_byname[cell['name']],
|
||||
self._ignored_keys)
|
||||
|
||||
def test_cell_get_not_found(self):
|
||||
self._create_cells()
|
||||
self.assertRaises(exception.CellNotFound, db.cell_get, self.ctxt,
|
||||
'cellnotinbase')
|
||||
|
||||
def test_cell_update_not_found(self):
|
||||
self._create_cells()
|
||||
self.assertRaises(exception.CellNotFound, db.cell_update, self.ctxt,
|
||||
'cellnotinbase', self._get_cell_base_values())
|
||||
|
||||
def test_cell_create_exists(self):
|
||||
db.cell_create(self.ctxt, self._get_cell_base_values())
|
||||
self.assertRaises(exception.CellExists, db.cell_create,
|
||||
self.ctxt, self._get_cell_base_values())
|
||||
|
||||
|
||||
class ConsolePoolTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
def setUp(self):
|
||||
super(ConsolePoolTestCase, self).setUp()
|
||||
|
Loading…
x
Reference in New Issue
Block a user