objects: introduce object for extra dhcp options

This patch introduces a new versioned object for extra dhcp options. It
will be adopted in Neutron in Newton.

Change-Id: I45b54b80d994f7e7f06128f73256b94675db97b2
Partial-Bug: #1541928
This commit is contained in:
Martin Hickey 2016-01-27 14:25:44 +00:00
parent fbd0a2b5bd
commit ecde8a9ddb
7 changed files with 69 additions and 0 deletions

View File

View File

@ -0,0 +1,33 @@
# 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 import extradhcpopt_db as models
from neutron.objects import base
@obj_base.VersionedObjectRegistry.register
class ExtraDhcpOpt(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
db_model = models.ExtraDhcpOpt
fields = {
'id': obj_fields.UUIDField(),
'port_id': obj_fields.UUIDField(),
'opt_name': obj_fields.StringField(),
'opt_value': obj_fields.StringField(),
'ip_version': obj_fields.IntegerField(),
}

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.
from neutron.objects.port.extensions import extra_dhcp_opt
from neutron.tests.unit.objects import test_base as obj_test_base
from neutron.tests.unit import testlib_api
class ExtraDhcpOptIfaceObjectTestCase(obj_test_base.BaseObjectIfaceTestCase):
_test_class = extra_dhcp_opt.ExtraDhcpOpt
class ExtraDhcpOptDbObjectTestCase(obj_test_base.BaseDbObjectTestCase,
testlib_api.SqlTestCase):
_test_class = extra_dhcp_opt.ExtraDhcpOpt
def setUp(self):
super(ExtraDhcpOptDbObjectTestCase, self).setUp()
self._create_test_network()
self._create_test_port(self._network)
for obj in self.db_objs:
obj['port_id'] = self._port['id']
for obj in self.obj_fields:
obj['port_id'] = self._port['id']

View File

@ -26,6 +26,7 @@ from neutron.tests import tools
# NOTE: The hashes in this list should only be changed if they come with a
# corresponding version bump in the affected objects.
object_data = {
'ExtraDhcpOpt': '1.0-632f689cbeb36328995a7aed1d0a78d3',
'QosBandwidthLimitRule': '1.1-4e44a8f5c2895ab1278399f87b40a13d',
'QosDscpMarkingRule': '1.1-0313c6554b34fd10c753cb63d638256c',
'QosRuleType': '1.1-8a53fef4c6a43839d477a85b787d22ce',