From: Kevin Benton Date: Mon, 19 Aug 2013 16:34:36 +0000 (-0700) Subject: Add extra_dhcp_opt extension to BigSwitch/Floodlight plugin X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=209c0e0a0d92199ce44f8c787c2582aa41fb27d7;p=openstack-build%2Fneutron-build.git Add extra_dhcp_opt extension to BigSwitch/Floodlight plugin Adds support for the DHCP options extenion to the BigSwitch/Floodlight plugin. Fixes: bug #1206655 Change-Id: Ida30ca44ecbb9d1208303e47519427a4111f6025 --- diff --git a/neutron/plugins/bigswitch/plugin.py b/neutron/plugins/bigswitch/plugin.py index 98d21157e..78c02466a 100644 --- a/neutron/plugins/bigswitch/plugin.py +++ b/neutron/plugins/bigswitch/plugin.py @@ -63,7 +63,9 @@ from neutron import context as qcontext from neutron.db import api as db from neutron.db import db_base_plugin_v2 from neutron.db import dhcp_rpc_base +from neutron.db import extradhcpopt_db from neutron.db import l3_db +from neutron.extensions import extra_dhcp_opt as edo_ext from neutron.extensions import l3 from neutron.extensions import portbindings from neutron.openstack.common import log as logging @@ -332,9 +334,11 @@ class RpcProxy(dhcp_rpc_base.DhcpRpcCallbackMixin): class NeutronRestProxyV2(db_base_plugin_v2.NeutronDbPluginV2, - routerrule_db.RouterRule_db_mixin): + routerrule_db.RouterRule_db_mixin, + extradhcpopt_db.ExtraDhcpOptMixin): - supported_extension_aliases = ["router", "binding", "router_rules"] + supported_extension_aliases = ["router", "binding", "router_rules", + "extra_dhcp_opt"] def __init__(self, server_timeout=None): LOG.info(_('NeutronRestProxy: Starting plugin. Version=%s'), @@ -561,11 +565,13 @@ class NeutronRestProxyV2(db_base_plugin_v2.NeutronDbPluginV2, # Update DB port["port"]["admin_state_up"] = False + dhcp_opts = port['port'].get(edo_ext.EXTRADHCPOPTS, []) new_port = super(NeutronRestProxyV2, self).create_port(context, port) if (portbindings.HOST_ID in port['port'] and 'id' in new_port): porttracker_db.put_port_hostid(context, new_port['id'], port['port'][portbindings.HOST_ID]) + self._process_port_create_extra_dhcp_opts(context, new_port, dhcp_opts) new_port = self._extend_port_dict_binding(context, new_port) net = super(NeutronRestProxyV2, self).get_network(context, new_port["network_id"]) @@ -658,6 +664,7 @@ class NeutronRestProxyV2(db_base_plugin_v2.NeutronDbPluginV2, # Update DB new_port = super(NeutronRestProxyV2, self).update_port(context, port_id, port) + self._update_extra_dhcp_opts_on_port(context, port_id, port, new_port) if (portbindings.HOST_ID in port['port'] and 'id' in new_port): porttracker_db.put_port_hostid(context, new_port['id'], diff --git a/neutron/tests/unit/bigswitch/test_router_db.py b/neutron/tests/unit/bigswitch/test_router_db.py index c17681fb9..cc044bddb 100644 --- a/neutron/tests/unit/bigswitch/test_router_db.py +++ b/neutron/tests/unit/bigswitch/test_router_db.py @@ -31,6 +31,7 @@ from neutron.manager import NeutronManager from neutron.openstack.common.notifier import api as notifier_api from neutron.openstack.common.notifier import test_notifier from neutron.plugins.bigswitch.extensions import routerrule +from neutron.tests.unit import test_extension_extradhcpopts as test_extradhcp from neutron.tests.unit import test_l3_plugin @@ -112,6 +113,17 @@ class RouterRulesTestExtensionManager(object): return [] +class DHCPOptsTestCase(test_extradhcp.TestExtraDhcpOpt): + + def setUp(self, plugin=None): + self.httpPatch = patch('httplib.HTTPConnection', create=True, + new=HTTPConnectionMock) + self.httpPatch.start() + self.addCleanup(self.httpPatch.stop) + p_path = 'neutron.plugins.bigswitch.plugin.NeutronRestProxyV2' + super(test_extradhcp.ExtraDhcpOptDBTestCase, self).setUp(plugin=p_path) + + class RouterDBTestCase(test_l3_plugin.L3NatDBTestCase): def setUp(self):