OVO creation for RouterL3AgentBinding

This patch introduces OVO for RouterL3AgentBinding

Change-Id: Ibd37513bc1357a088266a41e0b1182d8802fc151
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
Co-Authored-By: Mohit Malik <mohit.malik@intel.com>
This commit is contained in:
Anindita Das 2016-08-26 05:54:52 +00:00
parent 4d7a0e099b
commit d605920325
4 changed files with 82 additions and 0 deletions

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 oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import fields as obj_fields
from neutron.db.models import l3agent
from neutron.objects import base
from neutron.objects import common_types
@obj_base.VersionedObjectRegistry.register
class RouterL3AgentBinding(base.NeutronDbObject):
# Version 1.0: Initial version
VERSION = '1.0'
db_model = l3agent.RouterL3AgentBinding
primary_keys = ['router_id', 'l3_agent_id']
fields = {
'router_id': common_types.UUIDField(),
'l3_agent_id': common_types.UUIDField(),
'binding_index': obj_fields.IntegerField(
default=l3agent.LOWEST_BINDING_INDEX),
}

View File

@ -33,6 +33,7 @@ from neutron.db import _model_query as model_query
from neutron.db.models import l3 as l3_model
from neutron.db import standard_attr
from neutron import objects
from neutron.objects import agent
from neutron.objects import base
from neutron.objects import common_types
from neutron.objects.db import api as obj_db_api
@ -1358,6 +1359,11 @@ class BaseDbObjectTestCase(_BaseObjectTestCase,
self._securitygroup.create()
return self._securitygroup
def _create_test_agent(self):
attrs = self.get_random_object_fields(obj_cls=agent.Agent)
self._agent = agent.Agent(self.context, **attrs)
self._agent.create()
def _create_test_port(self, network):
self._port = self._create_port(network_id=network['id'])

View File

@ -0,0 +1,40 @@
# Copyright (c) 2016 Intel Corporation.
#
# 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 import l3agent
from neutron.tests.unit.objects import test_base
from neutron.tests.unit import testlib_api
class RouterL3AgentBindingIfaceObjTestCase(test_base.BaseObjectIfaceTestCase):
_test_class = l3agent.RouterL3AgentBinding
class RouterL3AgentBindingDbObjTestCase(test_base.BaseDbObjectTestCase,
testlib_api.SqlTestCase):
_test_class = l3agent.RouterL3AgentBinding
def setUp(self):
super(RouterL3AgentBindingDbObjTestCase, self).setUp()
self._create_test_router()
def getter():
self._create_test_agent()
return self._agent['id']
self.update_obj_fields(
{'router_id': self._router.id,
'l3_agent_id': getter})

View File

@ -66,6 +66,7 @@ object_data = {
'QosPolicy': '1.4-50460f619c34428ec5651916e938e5a0',
'Route': '1.0-a9883a63b416126f9e345523ec09483b',
'RouterExtraAttributes': '1.0-ef8d61ae2864f0ec9af0ab7939cab318',
'RouterL3AgentBinding': '1.0-c5ba6c95e3a4c1236a55f490cd67da82',
'RouterRoute': '1.0-07fc5337c801fb8c6ccfbcc5afb45907',
'SecurityGroup': '1.0-e26b90c409b31fd2e3c6fcec402ac0b9',
'SecurityGroupRule': '1.0-e9b8dace9d48b936c62ad40fe1f339d5',