components/openstack/neutron/patches/01-dhcp-agent-add-solaris.patch
author Mike Sullivan <Mike.Sullivan@Oracle.COM>
Thu, 24 Sep 2015 23:16:46 -0700
changeset 4905 9567ece93afb
parent 3998 5bd484384122
child 5405 66fd59fecd68
permissions -rw-r--r--
Added tag s12-84 for changeset 4f05d46b7e44

Changes to the Neutron DHCP agent to port it to Solaris. These changes
will eventually be proposed upstream.

--- neutron-2014.2.2/neutron/agent/dhcp_agent.py.~1~	2015-02-05 07:45:33.000000000 -0800
+++ neutron-2014.2.2/neutron/agent/dhcp_agent.py	2015-02-25 00:44:00.464466509 -0800
@@ -14,6 +14,7 @@
 #    under the License.
 
 import os
+import platform
 import sys
 
 import eventlet
@@ -22,9 +23,7 @@ eventlet.monkey_patch()
 from oslo.config import cfg
 
 from neutron.agent.common import config
-from neutron.agent.linux import dhcp
 from neutron.agent.linux import external_process
-from neutron.agent.linux import interface
 from neutron.agent.linux import ovs_lib  # noqa
 from neutron.agent import rpc as agent_rpc
 from neutron.common import config as common_config
@@ -42,6 +41,9 @@ from neutron.openstack.common import ser
 from neutron import service as neutron_service
 
 LOG = logging.getLogger(__name__)
+# dynamic module import
+dhcp = None
+interface = None
 
 
 class DhcpAgent(manager.Manager):
@@ -609,6 +611,16 @@ def register_options():
     config.register_use_namespaces_opts_helper(cfg.CONF)
     config.register_agent_state_opts_helper(cfg.CONF)
     config.register_root_helper(cfg.CONF)
+    global dhcp
+    global interface
+    if platform.system() == "SunOS":
+        dhcp = importutils.import_module("neutron.agent.solaris.dhcp")
+        interface = \
+            importutils.import_module("neutron.agent.solaris.interface")
+    else:
+        dhcp = importutils.import_module("neutron.agent.linux.dhcp")
+        interface = \
+            importutils.import_module("neutron.agent.linux.interface")
     cfg.CONF.register_opts(dhcp.OPTS)
     cfg.CONF.register_opts(interface.OPTS)
 
--- neutron-2014.2.2/neutron/api/rpc/handlers/dhcp_rpc.py.~1~	2015-02-05 07:45:33.000000000 -0800
+++ neutron-2014.2.2/neutron/api/rpc/handlers/dhcp_rpc.py	2015-02-25 00:44:00.464738154 -0800
@@ -168,11 +168,13 @@ class DhcpRpcCallback(n_rpc.RpcCallback)
                 for fixed_ip in port['fixed_ips']:
                     if fixed_ip['subnet_id'] in dhcp_enabled_subnet_ids:
                         dhcp_enabled_subnet_ids.remove(fixed_ip['subnet_id'])
-                port['fixed_ips'].extend(
-                    [dict(subnet_id=s) for s in dhcp_enabled_subnet_ids])
-
-                retval = plugin.update_port(context, port['id'],
-                                            dict(port=port))
+                if dhcp_enabled_subnet_ids:
+                    port['fixed_ips'].extend(
+                        [dict(subnet_id=s) for s in dhcp_enabled_subnet_ids])
+                    retval = plugin.update_port(context, port['id'],
+                                                dict(port=port))
+                else:
+                    retval = port
 
         except n_exc.NotFound as e:
             LOG.warning(e)