Merge "Conntrack Helper - OVO and db script"
This commit is contained in:
commit
dfc2586fb1
@ -11,6 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.objects import conntrack_helper
|
||||
from neutron.objects.logapi import logging_resource as log_object
|
||||
from neutron.objects import network
|
||||
from neutron.objects import port_forwarding
|
||||
@ -32,6 +33,7 @@ SUBNET = subnet.Subnet.obj_name()
|
||||
SECURITYGROUP = securitygroup.SecurityGroup.obj_name()
|
||||
SECURITYGROUPRULE = securitygroup.SecurityGroupRule.obj_name()
|
||||
PORTFORWARDING = port_forwarding.PortForwarding.obj_name()
|
||||
CONNTRACKHELPER = conntrack_helper.ConntrackHelper.obj_name()
|
||||
|
||||
|
||||
_VALID_CLS = (
|
||||
@ -45,6 +47,7 @@ _VALID_CLS = (
|
||||
securitygroup.SecurityGroupRule,
|
||||
log_object.Log,
|
||||
port_forwarding.PortForwarding,
|
||||
conntrack_helper.ConntrackHelper,
|
||||
)
|
||||
|
||||
_TYPE_TO_CLS_MAP = {cls.obj_name(): cls for cls in _VALID_CLS}
|
||||
|
@ -1 +1 @@
|
||||
9bfad3f1e780
|
||||
63fd95af7dcd
|
||||
|
@ -0,0 +1,49 @@
|
||||
# Copyright (c) 2019 Red Hat, Inc.
|
||||
#
|
||||
# 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 alembic import op
|
||||
from neutron_lib.db import constants as db_const
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
"""conntrack helper
|
||||
|
||||
Revision ID: 63fd95af7dcd
|
||||
Revises: 9bfad3f1e780
|
||||
Create Date: 2019-03-26 15:37:20.996070
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '63fd95af7dcd'
|
||||
down_revision = '9bfad3f1e780'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table(
|
||||
'conntrack_helpers',
|
||||
sa.Column('id', sa.String(length=db_const.UUID_FIELD_SIZE),
|
||||
nullable=False, primary_key=True),
|
||||
sa.Column('router_id', sa.String(length=db_const.UUID_FIELD_SIZE),
|
||||
nullable=False),
|
||||
sa.Column('protocol', sa.String(length=40), nullable=False),
|
||||
sa.Column('port', sa.Integer(), nullable=False),
|
||||
sa.Column('helper', sa.String(length=64), nullable=False),
|
||||
sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.UniqueConstraint(
|
||||
'router_id', 'protocol', 'port', 'helper',
|
||||
name='uniq_conntrack_helpers0router_id0protocol0port0helper')
|
||||
)
|
45
neutron/db/models/conntrack_helper.py
Normal file
45
neutron/db/models/conntrack_helper.py
Normal file
@ -0,0 +1,45 @@
|
||||
# Copyright (c) 2019 Red Hat, Inc.
|
||||
#
|
||||
# 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_lib.db import model_base
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
|
||||
from neutron.db.models import l3
|
||||
from neutron_lib.db import constants as db_const
|
||||
|
||||
|
||||
class ConntrackHelper(model_base.BASEV2, model_base.HasId):
|
||||
|
||||
__tablename__ = 'conntrack_helpers'
|
||||
|
||||
router_id = sa.Column(sa.String(db_const.UUID_FIELD_SIZE),
|
||||
sa.ForeignKey('routers.id', ondelete="CASCADE"),
|
||||
nullable=False)
|
||||
protocol = sa.Column(sa.String(40), nullable=False)
|
||||
port = sa.Column(sa.Integer, nullable=False)
|
||||
helper = sa.Column(sa.String(64), nullable=False)
|
||||
|
||||
__table_args__ = (
|
||||
sa.UniqueConstraint(
|
||||
router_id, protocol, port, helper,
|
||||
name='uniq_conntrack_helpers0router_id0protocol0port0helper'),
|
||||
)
|
||||
|
||||
router = orm.relationship(l3.Router, load_on_pending=True,
|
||||
backref=orm.backref("conntrack_helpers",
|
||||
lazy='subquery',
|
||||
uselist=True,
|
||||
cascade='delete'))
|
||||
revises_on_change = ('router', )
|
38
neutron/objects/conntrack_helper.py
Normal file
38
neutron/objects/conntrack_helper.py
Normal file
@ -0,0 +1,38 @@
|
||||
# Copyright (c) 2019 Red Hat, Inc.
|
||||
#
|
||||
# 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 fields as obj_fields
|
||||
|
||||
from neutron.db.models import conntrack_helper as models
|
||||
from neutron.objects import base
|
||||
from neutron.objects import common_types
|
||||
|
||||
|
||||
@base.NeutronObjectRegistry.register
|
||||
class ConntrackHelper(base.NeutronDbObject):
|
||||
# Version 1.0: Initial version
|
||||
VERSION = '1.0'
|
||||
|
||||
db_model = models.ConntrackHelper
|
||||
|
||||
fields = {
|
||||
'id': common_types.UUIDField(),
|
||||
'router_id': common_types.UUIDField(),
|
||||
'protocol': common_types.IpProtocolEnumField(),
|
||||
'port': common_types.PortRangeField(),
|
||||
'helper': obj_fields.StringField(),
|
||||
}
|
||||
|
||||
primary_keys = ['id']
|
||||
foreign_keys = {'Routers': {'router_id': 'id'}}
|
33
neutron/tests/unit/objects/test_conntrack_helper.py
Normal file
33
neutron/tests/unit/objects/test_conntrack_helper.py
Normal file
@ -0,0 +1,33 @@
|
||||
# Copyright (c) 2019 Red Hat, Inc.
|
||||
#
|
||||
# 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 conntrack_helper
|
||||
from neutron.tests.unit.objects import test_base as obj_test_base
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
|
||||
class ConntrackHelperObjectTestCase(obj_test_base.BaseObjectIfaceTestCase):
|
||||
|
||||
_test_class = conntrack_helper.ConntrackHelper
|
||||
|
||||
|
||||
class ConntrackHelperDbObjectTestCase(obj_test_base.BaseDbObjectTestCase,
|
||||
testlib_api.SqlTestCase):
|
||||
|
||||
_test_class = conntrack_helper.ConntrackHelper
|
||||
|
||||
def setUp(self):
|
||||
super(ConntrackHelperDbObjectTestCase, self).setUp()
|
||||
self.update_obj_fields(
|
||||
{'router_id': lambda: self._create_test_router_id()})
|
@ -30,6 +30,7 @@ object_data = {
|
||||
'Agent': '1.1-64b670752d57b3c7602cb136e0338507',
|
||||
'AllowedAddressPair': '1.0-9f9186b6f952fbf31d257b0458b852c0',
|
||||
'AutoAllocatedTopology': '1.0-74642e58c53bf3610dc224c59f81b242',
|
||||
'ConntrackHelper': '1.0-b1a50cfe18178db50c7f206e75613f4b',
|
||||
'DefaultSecurityGroup': '1.0-971520cb2e0ec06d747885a0cf78347f',
|
||||
'DistributedPortBinding': '1.0-39c0d17b281991dcb66716fee5a8bef2',
|
||||
'DNSNameServer': '1.0-bf87a85327e2d812d1666ede99d9918b',
|
||||
|
@ -172,6 +172,7 @@ neutron.objects =
|
||||
AllowedAddressPair = neutron.objects.port.extensions.allowedaddresspairs:AllowedAddressPair
|
||||
Agent = neutron.objects.agent:Agent
|
||||
AutoAllocatedTopology = neutron.objects.auto_allocate:AutoAllocatedTopology
|
||||
ConntrackHelper = neutron.objects.conntrack_helper:ConntrackHelper
|
||||
PortDataPlaneStatus = neutron.objects.port.extensions.data_plane_status:PortDataPlaneStatus
|
||||
DefaultSecurityGroup = neutron.objects.securitygroup:DefaultSecurityGroup
|
||||
DistributedPortBinding = neutron.objects.ports:DistributedPortBinding
|
||||
|
Loading…
Reference in New Issue
Block a user