BigSwitch: Add address pair support to plugin
Adds support for the address pair extension to the BigSwitch/restproxy plugin. Implements: blueprint bsn-address-pairs Change-Id: If03e8752155bcb8b21f5a427c54640c5b63f77f3
This commit is contained in:
parent
4d4520d860
commit
6999fcb93d
@ -0,0 +1,58 @@
|
|||||||
|
# Copyright 2014 OpenStack Foundation
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
"""bsn_addresspairs
|
||||||
|
|
||||||
|
Revision ID: fcac4c42e2cc
|
||||||
|
Revises: 2eeaf963a447
|
||||||
|
Create Date: 2014-02-23 12:56:00.402855
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = 'fcac4c42e2cc'
|
||||||
|
down_revision = '2eeaf963a447'
|
||||||
|
|
||||||
|
# Change to ['*'] if this migration applies to all plugins
|
||||||
|
|
||||||
|
migration_for_plugins = [
|
||||||
|
'neutron.plugins.bigswitch.plugin.NeutronRestProxyV2'
|
||||||
|
]
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
from neutron.db import migration
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade(active_plugins=None, options=None):
|
||||||
|
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||||
|
return
|
||||||
|
|
||||||
|
op.create_table(
|
||||||
|
'allowedaddresspairs',
|
||||||
|
sa.Column('port_id', sa.String(length=36), nullable=False),
|
||||||
|
sa.Column('mac_address', sa.String(length=32), nullable=False),
|
||||||
|
sa.Column('ip_address', sa.String(length=64), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(['port_id'], ['ports.id'], ondelete='CASCADE'),
|
||||||
|
sa.PrimaryKeyConstraint('port_id', 'mac_address', 'ip_address'),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade(active_plugins=None, options=None):
|
||||||
|
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||||
|
return
|
||||||
|
|
||||||
|
op.drop_table('allowedaddresspairs')
|
@ -61,6 +61,7 @@ from neutron.common import topics
|
|||||||
from neutron import context as qcontext
|
from neutron import context as qcontext
|
||||||
from neutron.db import agents_db
|
from neutron.db import agents_db
|
||||||
from neutron.db import agentschedulers_db
|
from neutron.db import agentschedulers_db
|
||||||
|
from neutron.db import allowedaddresspairs_db as addr_pair_db
|
||||||
from neutron.db import api as db
|
from neutron.db import api as db
|
||||||
from neutron.db import db_base_plugin_v2
|
from neutron.db import db_base_plugin_v2
|
||||||
from neutron.db import dhcp_rpc_base
|
from neutron.db import dhcp_rpc_base
|
||||||
@ -70,6 +71,7 @@ from neutron.db import l3_db
|
|||||||
from neutron.db import models_v2
|
from neutron.db import models_v2
|
||||||
from neutron.db import securitygroups_db as sg_db
|
from neutron.db import securitygroups_db as sg_db
|
||||||
from neutron.db import securitygroups_rpc_base as sg_rpc_base
|
from neutron.db import securitygroups_rpc_base as sg_rpc_base
|
||||||
|
from neutron.extensions import allowedaddresspairs as addr_pair
|
||||||
from neutron.extensions import external_net
|
from neutron.extensions import external_net
|
||||||
from neutron.extensions import extra_dhcp_opt as edo_ext
|
from neutron.extensions import extra_dhcp_opt as edo_ext
|
||||||
from neutron.extensions import l3
|
from neutron.extensions import l3
|
||||||
@ -414,6 +416,7 @@ class NeutronRestProxyV2Base(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
|
|
||||||
|
|
||||||
class NeutronRestProxyV2(NeutronRestProxyV2Base,
|
class NeutronRestProxyV2(NeutronRestProxyV2Base,
|
||||||
|
addr_pair_db.AllowedAddressPairsMixin,
|
||||||
extradhcpopt_db.ExtraDhcpOptMixin,
|
extradhcpopt_db.ExtraDhcpOptMixin,
|
||||||
agentschedulers_db.DhcpAgentSchedulerDbMixin,
|
agentschedulers_db.DhcpAgentSchedulerDbMixin,
|
||||||
sg_rpc_base.SecurityGroupServerRpcMixin):
|
sg_rpc_base.SecurityGroupServerRpcMixin):
|
||||||
@ -421,7 +424,7 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
|
|||||||
_supported_extension_aliases = ["external-net", "router", "binding",
|
_supported_extension_aliases = ["external-net", "router", "binding",
|
||||||
"router_rules", "extra_dhcp_opt", "quotas",
|
"router_rules", "extra_dhcp_opt", "quotas",
|
||||||
"dhcp_agent_scheduler", "agent",
|
"dhcp_agent_scheduler", "agent",
|
||||||
"security-group"]
|
"security-group", "allowed-address-pairs"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_extension_aliases(self):
|
def supported_extension_aliases(self):
|
||||||
@ -629,6 +632,10 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
|
|||||||
host_id = port['port'][portbindings.HOST_ID]
|
host_id = port['port'][portbindings.HOST_ID]
|
||||||
porttracker_db.put_port_hostid(context, new_port['id'],
|
porttracker_db.put_port_hostid(context, new_port['id'],
|
||||||
host_id)
|
host_id)
|
||||||
|
new_port[addr_pair.ADDRESS_PAIRS] = (
|
||||||
|
self._process_create_allowed_address_pairs(
|
||||||
|
context, new_port,
|
||||||
|
port['port'].get(addr_pair.ADDRESS_PAIRS)))
|
||||||
self._process_port_create_extra_dhcp_opts(context, new_port,
|
self._process_port_create_extra_dhcp_opts(context, new_port,
|
||||||
dhcp_opts)
|
dhcp_opts)
|
||||||
new_port = self._extend_port_dict_binding(context, new_port)
|
new_port = self._extend_port_dict_binding(context, new_port)
|
||||||
@ -698,9 +705,16 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
|
|||||||
# Update DB
|
# Update DB
|
||||||
new_port = super(NeutronRestProxyV2,
|
new_port = super(NeutronRestProxyV2,
|
||||||
self).update_port(context, port_id, port)
|
self).update_port(context, port_id, port)
|
||||||
|
ctrl_update_required = False
|
||||||
|
if addr_pair.ADDRESS_PAIRS in port['port']:
|
||||||
|
ctrl_update_required |= (
|
||||||
|
self.update_address_pairs_on_port(context, port_id, port,
|
||||||
|
orig_port, new_port))
|
||||||
|
if 'fixed_ips' in port['port']:
|
||||||
|
self._check_fixed_ips_and_address_pairs_no_overlap(
|
||||||
|
context, new_port)
|
||||||
self._update_extra_dhcp_opts_on_port(context, port_id, port,
|
self._update_extra_dhcp_opts_on_port(context, port_id, port,
|
||||||
new_port)
|
new_port)
|
||||||
ctrl_update_required = False
|
|
||||||
old_host_id = porttracker_db.get_port_hostid(context,
|
old_host_id = porttracker_db.get_port_hostid(context,
|
||||||
orig_port['id'])
|
orig_port['id'])
|
||||||
if (portbindings.HOST_ID in port['port']
|
if (portbindings.HOST_ID in port['port']
|
||||||
|
@ -27,6 +27,7 @@ from neutron.tests.unit.bigswitch import fake_server
|
|||||||
from neutron.tests.unit.bigswitch import test_base
|
from neutron.tests.unit.bigswitch import test_base
|
||||||
from neutron.tests.unit import test_api_v2
|
from neutron.tests.unit import test_api_v2
|
||||||
import neutron.tests.unit.test_db_plugin as test_plugin
|
import neutron.tests.unit.test_db_plugin as test_plugin
|
||||||
|
import neutron.tests.unit.test_extension_allowedaddresspairs as test_addr_pair
|
||||||
|
|
||||||
|
|
||||||
class BigSwitchProxyPluginV2TestCase(test_base.BigSwitchTestBase,
|
class BigSwitchProxyPluginV2TestCase(test_base.BigSwitchTestBase,
|
||||||
@ -280,3 +281,8 @@ class TestBigSwitchProxySync(BigSwitchProxyPluginV2TestCase):
|
|||||||
plugin_obj = NeutronManager.get_plugin()
|
plugin_obj = NeutronManager.get_plugin()
|
||||||
result = plugin_obj._send_all_data()
|
result = plugin_obj._send_all_data()
|
||||||
self.assertEqual(result[0], 200)
|
self.assertEqual(result[0], 200)
|
||||||
|
|
||||||
|
|
||||||
|
class TestBigSwitchAddressPairs(BigSwitchProxyPluginV2TestCase,
|
||||||
|
test_addr_pair.TestAllowedAddressPairs):
|
||||||
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user