OVO for Provisioning Block DB Model

This patch introduces OVO for Provisioning
Block DB Model.

Change-Id: I1ac68ad1acfa116c09e0adfa119db0b2cad125d4
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
This commit is contained in:
Shashank Kumar Shankar 2016-08-18 20:40:16 +00:00
parent 50f31386cf
commit 4c45d1ee80
4 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,32 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db.models import provisioning_block as pb_model
from neutron.objects import base
@obj_base.VersionedObjectRegistry.register
class ProvisioningBlock(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
db_model = pb_model.ProvisioningBlock
fields = {
'standard_attr_id': obj_fields.IntegerField(),
'entity': obj_fields.StringField()
}
primary_keys = ['standard_attr_id', 'entity']

View File

@ -34,6 +34,7 @@ from neutron.db import db_base_plugin_v2
from neutron.db import model_base
from neutron.db.models import external_net as ext_net_model
from neutron.db.models import l3 as l3_model
from neutron.db import standard_attr
from neutron import objects
from neutron.objects import base
from neutron.objects import common_types
@ -1209,6 +1210,17 @@ class BaseDbObjectTestCase(_BaseObjectTestCase,
def _create_test_port(self, network):
self._port = self._create_port(network_id=network['id'])
def _create_test_standard_attribute(self):
attrs = {
'id': tools.get_random_integer(),
'resource_type': tools.get_random_string(4),
'revision_number': tools.get_random_integer()
}
self._standard_attribute = obj_db_api.create_object(
self.context,
standard_attr.StandardAttribute,
attrs)
def _make_object(self, fields):
fields = get_non_synthetic_fields(self._test_class, fields)
return self._test_class(self.context,

View File

@ -47,6 +47,7 @@ object_data = {
'PortDNS': '1.0-201cf6d057fde75539c3d1f2bbf05902',
'PortSecurity': '1.0-b30802391a87945ee9c07582b4ff95e3',
'ProviderResourceAssociation': '1.0-05ab2d5a3017e5ce9dd381328f285f34',
'ProvisioningBlock': '1.0-c19d6d05bfa8143533471c1296066125',
'QosBandwidthLimitRule': '1.2-4e44a8f5c2895ab1278399f87b40a13d',
'QosDscpMarkingRule': '1.2-0313c6554b34fd10c753cb63d638256c',
'QosMinimumBandwidthRule': '1.2-314c3419f4799067cc31cc319080adff',

View File

@ -0,0 +1,35 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import itertools
from neutron.objects import provisioning_blocks
from neutron.tests.unit.objects import test_base as obj_test_base
from neutron.tests.unit import testlib_api
class ProvisioningBlockIfaceObjectTestCase(
obj_test_base.BaseObjectIfaceTestCase):
_test_class = provisioning_blocks.ProvisioningBlock
class ProvisioningBlockDbObjectTestCase(obj_test_base.BaseDbObjectTestCase,
testlib_api.SqlTestCase):
_test_class = provisioning_blocks.ProvisioningBlock
def setUp(self):
super(ProvisioningBlockDbObjectTestCase, self).setUp()
self._create_test_standard_attribute()
for obj in itertools.chain(self.db_objs, self.obj_fields, self.objs):
obj['standard_attr_id'] = self._standard_attribute['id']