Add disabled field to CellMapping object
This patch adds a new field disabled to the CellMapping object which would be used to represent the value in the disabled column of the cell_mappings table for each record. Related to blueprint cell-disable Change-Id: I1263c5b85f36f65860b9efcfa082948a866ad751
This commit is contained in:
parent
f9743f0c2a
commit
9377127eb8
|
@ -10,6 +10,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from oslo_utils import versionutils
|
||||||
from sqlalchemy.sql.expression import asc
|
from sqlalchemy.sql.expression import asc
|
||||||
|
|
||||||
from nova.db.sqlalchemy import api as db_api
|
from nova.db.sqlalchemy import api as db_api
|
||||||
|
@ -22,7 +23,8 @@ from nova.objects import fields
|
||||||
@base.NovaObjectRegistry.register
|
@base.NovaObjectRegistry.register
|
||||||
class CellMapping(base.NovaTimestampObject, base.NovaObject):
|
class CellMapping(base.NovaTimestampObject, base.NovaObject):
|
||||||
# Version 1.0: Initial version
|
# Version 1.0: Initial version
|
||||||
VERSION = '1.0'
|
# Version 1.1: Added disabled field
|
||||||
|
VERSION = '1.1'
|
||||||
|
|
||||||
CELL0_UUID = '00000000-0000-0000-0000-000000000000'
|
CELL0_UUID = '00000000-0000-0000-0000-000000000000'
|
||||||
|
|
||||||
|
@ -32,7 +34,15 @@ class CellMapping(base.NovaTimestampObject, base.NovaObject):
|
||||||
'name': fields.StringField(nullable=True),
|
'name': fields.StringField(nullable=True),
|
||||||
'transport_url': fields.StringField(),
|
'transport_url': fields.StringField(),
|
||||||
'database_connection': fields.StringField(),
|
'database_connection': fields.StringField(),
|
||||||
}
|
'disabled': fields.BooleanField(default=False),
|
||||||
|
}
|
||||||
|
|
||||||
|
def obj_make_compatible(self, primitive, target_version):
|
||||||
|
super(CellMapping, self).obj_make_compatible(primitive, target_version)
|
||||||
|
target_version = versionutils.convert_version_to_tuple(target_version)
|
||||||
|
if target_version < (1, 1):
|
||||||
|
if 'disabled' in primitive:
|
||||||
|
del primitive['disabled']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def identity(self):
|
def identity(self):
|
||||||
|
|
|
@ -346,7 +346,8 @@ class SingleCellSimple(fixtures.Fixture):
|
||||||
'uuid': uuidsentinel.cell1,
|
'uuid': uuidsentinel.cell1,
|
||||||
'name': 'onlycell',
|
'name': 'onlycell',
|
||||||
'transport_url': 'fake://nowhere/',
|
'transport_url': 'fake://nowhere/',
|
||||||
'database_connection': 'sqlite:///'}]
|
'database_connection': 'sqlite:///',
|
||||||
|
'disabled': False}]
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def _fake_target_cell(self, context, target_cell):
|
def _fake_target_cell(self, context, target_cell):
|
||||||
|
|
|
@ -29,7 +29,8 @@ def get_db_mapping(**updates):
|
||||||
'database_connection': 'sqlite:///',
|
'database_connection': 'sqlite:///',
|
||||||
'created_at': None,
|
'created_at': None,
|
||||||
'updated_at': None,
|
'updated_at': None,
|
||||||
}
|
'disabled': False,
|
||||||
|
}
|
||||||
db_mapping.update(updates)
|
db_mapping.update(updates)
|
||||||
return db_mapping
|
return db_mapping
|
||||||
|
|
||||||
|
@ -116,6 +117,14 @@ class _TestCellMappingObject(object):
|
||||||
cm = objects.CellMapping(uuid=uuids.cell1, name='foo')
|
cm = objects.CellMapping(uuid=uuids.cell1, name='foo')
|
||||||
self.assertEqual('%s(foo)' % uuids.cell1, cm.identity)
|
self.assertEqual('%s(foo)' % uuids.cell1, cm.identity)
|
||||||
|
|
||||||
|
def test_obj_make_compatible(self):
|
||||||
|
cell_mapping_obj = cell_mapping.CellMapping(context=self.context)
|
||||||
|
fake_cell_mapping_copy = dict(get_db_mapping())
|
||||||
|
self.assertIn('disabled', fake_cell_mapping_copy)
|
||||||
|
cell_mapping_obj.obj_make_compatible(fake_cell_mapping_copy, '1.0')
|
||||||
|
self.assertIn('uuid', fake_cell_mapping_copy)
|
||||||
|
self.assertNotIn('disabled', fake_cell_mapping_copy)
|
||||||
|
|
||||||
|
|
||||||
class TestCellMappingObject(test_objects._LocalTest,
|
class TestCellMappingObject(test_objects._LocalTest,
|
||||||
_TestCellMappingObject):
|
_TestCellMappingObject):
|
||||||
|
|
|
@ -1064,7 +1064,7 @@ object_data = {
|
||||||
'BlockDeviceMappingList': '1.17-1e568eecb91d06d4112db9fd656de235',
|
'BlockDeviceMappingList': '1.17-1e568eecb91d06d4112db9fd656de235',
|
||||||
'BuildRequest': '1.3-077dee42bed93f8a5b62be77657b7152',
|
'BuildRequest': '1.3-077dee42bed93f8a5b62be77657b7152',
|
||||||
'BuildRequestList': '1.0-cd95608eccb89fbc702c8b52f38ec738',
|
'BuildRequestList': '1.0-cd95608eccb89fbc702c8b52f38ec738',
|
||||||
'CellMapping': '1.0-7f1a7e85a22bbb7559fc730ab658b9bd',
|
'CellMapping': '1.1-5d652928000a5bc369d79d5bde7e497d',
|
||||||
'CellMappingList': '1.0-4ee0d9efdfd681fed822da88376e04d2',
|
'CellMappingList': '1.0-4ee0d9efdfd681fed822da88376e04d2',
|
||||||
'ComputeNode': '1.18-431fafd8ac4a5f3559bd9b1f1332cc22',
|
'ComputeNode': '1.18-431fafd8ac4a5f3559bd9b1f1332cc22',
|
||||||
'ComputeNodeList': '1.17-52f3b0962b1c86b98590144463ebb192',
|
'ComputeNodeList': '1.17-52f3b0962b1c86b98590144463ebb192',
|
||||||
|
|
Loading…
Reference in New Issue