Relocate GRE Db models
Change-Id: I00afedc08c9ed7ab03ead9ef4bee94a80f50bb75 Partial-Bug: #1597913
This commit is contained in:
parent
c96f48162a
commit
d7e6ce8a6e
|
@ -54,7 +54,6 @@ from neutron.db import tag_db # noqa
|
|||
from neutron.ipam.drivers.neutrondb_ipam import db_models # noqa
|
||||
from neutron.plugins.ml2.drivers import type_flat # noqa
|
||||
from neutron.plugins.ml2.drivers import type_geneve # noqa
|
||||
from neutron.plugins.ml2.drivers import type_gre # noqa
|
||||
from neutron.plugins.ml2.drivers import type_vlan # noqa
|
||||
from neutron.plugins.ml2.drivers import type_vxlan # noqa
|
||||
from neutron.plugins.ml2 import models as ml2_models # noqa
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
# Copyright (c) 2013 OpenStack Foundation
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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 sqlalchemy as sa
|
||||
from sqlalchemy import sql
|
||||
|
||||
from neutron.db import model_base
|
||||
|
||||
|
||||
class GreAllocation(model_base.BASEV2):
|
||||
|
||||
__tablename__ = 'ml2_gre_allocations'
|
||||
|
||||
gre_id = sa.Column(sa.Integer, nullable=False, primary_key=True,
|
||||
autoincrement=False)
|
||||
allocated = sa.Column(sa.Boolean, nullable=False, default=False,
|
||||
server_default=sql.false(), index=True)
|
||||
|
||||
|
||||
class GreEndpoints(model_base.BASEV2):
|
||||
"""Represents tunnel endpoint in RPC mode."""
|
||||
|
||||
__tablename__ = 'ml2_gre_endpoints'
|
||||
__table_args__ = (
|
||||
sa.UniqueConstraint('host',
|
||||
name='unique_ml2_gre_endpoints0host'),
|
||||
model_base.BASEV2.__table_args__
|
||||
)
|
||||
ip_address = sa.Column(sa.String(64), primary_key=True)
|
||||
host = sa.Column(sa.String(255), nullable=True)
|
||||
|
||||
def __repr__(self):
|
||||
return "<GreTunnelEndpoint(%s)>" % self.ip_address
|
|
@ -13,14 +13,15 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import sys
|
||||
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import sql
|
||||
|
||||
from neutron._i18n import _, _LE
|
||||
from neutron.db import model_base
|
||||
from neutron.common import _deprecate
|
||||
from neutron.db.models.plugins.ml2 import gre_allocation_endpoints as gre_model
|
||||
from neutron.plugins.common import constants as p_const
|
||||
from neutron.plugins.ml2.drivers import type_tunnel
|
||||
|
||||
|
@ -37,37 +38,11 @@ gre_opts = [
|
|||
cfg.CONF.register_opts(gre_opts, "ml2_type_gre")
|
||||
|
||||
|
||||
class GreAllocation(model_base.BASEV2):
|
||||
|
||||
__tablename__ = 'ml2_gre_allocations'
|
||||
|
||||
gre_id = sa.Column(sa.Integer, nullable=False, primary_key=True,
|
||||
autoincrement=False)
|
||||
allocated = sa.Column(sa.Boolean, nullable=False, default=False,
|
||||
server_default=sql.false(), index=True)
|
||||
|
||||
|
||||
class GreEndpoints(model_base.BASEV2):
|
||||
"""Represents tunnel endpoint in RPC mode."""
|
||||
|
||||
__tablename__ = 'ml2_gre_endpoints'
|
||||
__table_args__ = (
|
||||
sa.UniqueConstraint('host',
|
||||
name='unique_ml2_gre_endpoints0host'),
|
||||
model_base.BASEV2.__table_args__
|
||||
)
|
||||
ip_address = sa.Column(sa.String(64), primary_key=True)
|
||||
host = sa.Column(sa.String(255), nullable=True)
|
||||
|
||||
def __repr__(self):
|
||||
return "<GreTunnelEndpoint(%s)>" % self.ip_address
|
||||
|
||||
|
||||
class GreTypeDriver(type_tunnel.EndpointTunnelTypeDriver):
|
||||
|
||||
def __init__(self):
|
||||
super(GreTypeDriver, self).__init__(
|
||||
GreAllocation, GreEndpoints)
|
||||
gre_model.GreAllocation, gre_model.GreEndpoints)
|
||||
|
||||
def get_type(self):
|
||||
return p_const.TYPE_GRE
|
||||
|
@ -93,3 +68,9 @@ class GreTypeDriver(type_tunnel.EndpointTunnelTypeDriver):
|
|||
def get_mtu(self, physical_network=None):
|
||||
mtu = super(GreTypeDriver, self).get_mtu(physical_network)
|
||||
return mtu - p_const.GRE_ENCAP_OVERHEAD if mtu else 0
|
||||
|
||||
|
||||
# WARNING: THESE MUST BE THE LAST TWO LINES IN THIS MODULE
|
||||
_OLD_REF = sys.modules[__name__]
|
||||
sys.modules[__name__] = _deprecate._DeprecateSubset(globals(), gre_model)
|
||||
# WARNING: THESE MUST BE THE LAST TWO LINES IN THIS MODULE
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron.db.models.plugins.ml2 import gre_allocation_endpoints as gre_model
|
||||
from neutron.plugins.common import constants as p_const
|
||||
from neutron.plugins.ml2.drivers import type_gre
|
||||
from neutron.tests.unit.plugins.ml2.drivers import base_type_tunnel
|
||||
|
@ -27,12 +28,12 @@ HOST_TWO = 'fake_host_two'
|
|||
|
||||
|
||||
def _add_allocation(session, gre_id, allocated=False):
|
||||
allocation = type_gre.GreAllocation(gre_id=gre_id, allocated=allocated)
|
||||
allocation = gre_model.GreAllocation(gre_id=gre_id, allocated=allocated)
|
||||
allocation.save(session)
|
||||
|
||||
|
||||
def _get_allocation(session, gre_id):
|
||||
return session.query(type_gre.GreAllocation).filter_by(
|
||||
return session.query(gre_model.GreAllocation).filter_by(
|
||||
gre_id=gre_id).one()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue