]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add extra_dhcp_opt extension to BigSwitch/Floodlight plugin
authorKevin Benton <kevin.benton@bigswitch.com>
Mon, 19 Aug 2013 16:34:36 +0000 (09:34 -0700)
committerKevin Benton <kevin.benton@bigswitch.com>
Tue, 27 Aug 2013 09:16:42 +0000 (02:16 -0700)
Adds support for the DHCP options extenion to the
BigSwitch/Floodlight plugin.

Fixes: bug #1206655
Change-Id: Ida30ca44ecbb9d1208303e47519427a4111f6025

neutron/plugins/bigswitch/plugin.py
neutron/tests/unit/bigswitch/test_router_db.py

index 98d21157e7536c45925370d70581ab0c7097dbca..78c02466aa2adf58cd4efa621ee1781eee12e237 100644 (file)
@@ -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'],
index c17681fb9836f5314ea1fd3a4cd31725cec5e08a..cc044bddb1723371258fc2b83694d8cc82db1aca 100644 (file)
@@ -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):