components/openstack/neutron/patches/01-dhcp-agent-add-solaris.patch
changeset 5405 66fd59fecd68
parent 3998 5bd484384122
child 6031 1aaf20a19738
equal deleted inserted replaced
5404:55e409ba4e72 5405:66fd59fecd68
     1 Changes to the Neutron DHCP agent to port it to Solaris. These changes
     1 Changes to the Neutron DHCP agent to port it to Solaris. These changes
     2 will eventually be proposed upstream.
     2 will eventually be proposed upstream.
     3 
     3 
     4 --- neutron-2014.2.2/neutron/agent/dhcp_agent.py.~1~	2015-02-05 07:45:33.000000000 -0800
     4 --- neutron-2015.1.2/neutron/agent/dhcp_agent.py.~1~	2015-10-13 10:35:16.000000000 -0700
     5 +++ neutron-2014.2.2/neutron/agent/dhcp_agent.py	2015-02-25 00:44:00.464466509 -0800
     5 +++ neutron-2015.1.2/neutron/agent/dhcp_agent.py	2016-01-28 23:07:42.219218977 -0800
     6 @@ -14,6 +14,7 @@
     6 @@ -14,9 +14,11 @@
       
     7  #    License for the specific language governing permissions and limitations
     7  #    under the License.
     8  #    under the License.
     8  
     9  
     9  import os
       
    10 +import platform
    10 +import platform
    11  import sys
    11  import sys
    12  
    12  
    13  import eventlet
    13  from oslo_config import cfg
    14 @@ -22,9 +23,7 @@ eventlet.monkey_patch()
    14 +from oslo_utils import importutils
    15  from oslo.config import cfg
       
    16  
    15  
    17  from neutron.agent.common import config
    16  from neutron.agent.common import config
    18 -from neutron.agent.linux import dhcp
    17  from neutron.agent.dhcp import config as dhcp_config
    19  from neutron.agent.linux import external_process
    18 @@ -37,6 +39,12 @@ def register_options():
    20 -from neutron.agent.linux import interface
    19      cfg.CONF.register_opts(dhcp_config.DNSMASQ_OPTS)
    21  from neutron.agent.linux import ovs_lib  # noqa
    20      cfg.CONF.register_opts(metadata_config.DRIVER_OPTS)
    22  from neutron.agent import rpc as agent_rpc
    21      cfg.CONF.register_opts(metadata_config.SHARED_OPTS)
    23  from neutron.common import config as common_config
       
    24 @@ -42,6 +41,9 @@ from neutron.openstack.common import ser
       
    25  from neutron import service as neutron_service
       
    26  
       
    27  LOG = logging.getLogger(__name__)
       
    28 +# dynamic module import
       
    29 +dhcp = None
       
    30 +interface = None
       
    31  
       
    32  
       
    33  class DhcpAgent(manager.Manager):
       
    34 @@ -609,6 +611,16 @@ def register_options():
       
    35      config.register_use_namespaces_opts_helper(cfg.CONF)
       
    36      config.register_agent_state_opts_helper(cfg.CONF)
       
    37      config.register_root_helper(cfg.CONF)
       
    38 +    global dhcp
       
    39 +    global interface
       
    40 +    if platform.system() == "SunOS":
    22 +    if platform.system() == "SunOS":
    41 +        dhcp = importutils.import_module("neutron.agent.solaris.dhcp")
       
    42 +        interface = \
    23 +        interface = \
    43 +            importutils.import_module("neutron.agent.solaris.interface")
    24 +            importutils.import_module("neutron.agent.solaris.interface")
    44 +    else:
    25 +    else:
    45 +        dhcp = importutils.import_module("neutron.agent.linux.dhcp")
       
    46 +        interface = \
    26 +        interface = \
    47 +            importutils.import_module("neutron.agent.linux.interface")
    27 +            importutils.import_module("neutron.agent.linux.interface")
    48      cfg.CONF.register_opts(dhcp.OPTS)
       
    49      cfg.CONF.register_opts(interface.OPTS)
    28      cfg.CONF.register_opts(interface.OPTS)
    50  
    29  
    51 --- neutron-2014.2.2/neutron/api/rpc/handlers/dhcp_rpc.py.~1~	2015-02-05 07:45:33.000000000 -0800
    30  
    52 +++ neutron-2014.2.2/neutron/api/rpc/handlers/dhcp_rpc.py	2015-02-25 00:44:00.464738154 -0800
    31 --- neutron-2015.1.2/neutron/agent/linux/external_process.py.~1~	2015-10-13 10:35:16.000000000 -0700
    53 @@ -168,11 +168,13 @@ class DhcpRpcCallback(n_rpc.RpcCallback)
    32 +++ neutron-2015.1.2/neutron/agent/linux/external_process.py	2016-01-28 23:07:42.221029379 -0800
       
    33 @@ -15,6 +15,7 @@
       
    34  import abc
       
    35  import collections
       
    36  import os.path
       
    37 +import platform
       
    38  import six
       
    39  
       
    40  import eventlet
       
    41 @@ -86,9 +87,17 @@ class ProcessManager(MonitoredProcess):
       
    42                  cmd_callback = self.default_cmd_callback
       
    43              cmd = cmd_callback(self.get_pid_file_name())
       
    44  
       
    45 -            ip_wrapper = ip_lib.IPWrapper(namespace=self.namespace)
       
    46 -            ip_wrapper.netns.execute(cmd, addl_env=self.cmd_addl_env,
       
    47 -                                     run_as_root=self.run_as_root)
       
    48 +            if self.namespace:
       
    49 +                ip_wrapper = ip_lib.IPWrapper(namespace=self.namespace)
       
    50 +                ip_wrapper.netns.execute(cmd, addl_env=self.cmd_addl_env,
       
    51 +                                         run_as_root=self.run_as_root)
       
    52 +            else:
       
    53 +                env_params = []
       
    54 +                if self.cmd_addl_env:
       
    55 +                    env_params = (['/usr/bin/env'] +
       
    56 +                                  ['%s=%s' % pair for pair in
       
    57 +                                   self.cmd_addl_env.items()])
       
    58 +                utils.execute(env_params + list(cmd))
       
    59          elif reload_cfg:
       
    60              self.reload_cfg()
       
    61  
       
    62 @@ -131,6 +140,14 @@ class ProcessManager(MonitoredProcess):
       
    63          if pid is None:
       
    64              return False
       
    65  
       
    66 +        if platform.system() == "SunOS":
       
    67 +            cmd = ['/usr/bin/pargs', pid]
       
    68 +            try:
       
    69 +                exec_out = utils.execute(cmd)
       
    70 +            except RuntimeError:
       
    71 +                return False
       
    72 +            return self.uuid in exec_out
       
    73 +
       
    74          cmdline = '/proc/%s/cmdline' % pid
       
    75          try:
       
    76              with open(cmdline, "r") as f:
       
    77 --- neutron-2015.1.2/neutron/agent/linux/utils.py.~1~	2015-10-13 10:35:16.000000000 -0700
       
    78 +++ neutron-2015.1.2/neutron/agent/linux/utils.py	2016-01-28 23:20:12.736969284 -0800
       
    79 @@ -31,7 +31,10 @@ from eventlet import greenthread
       
    80  from oslo_config import cfg
       
    81  from oslo_log import log as logging
       
    82  from oslo_log import loggers
       
    83 -from oslo_rootwrap import client
       
    84 +try:
       
    85 +    from oslo_rootwrap import client
       
    86 +except:
       
    87 +    pass
       
    88  from oslo_utils import excutils
       
    89  
       
    90  from neutron.agent.common import config
       
    91 --- neutron-2015.1.2/neutron/api/rpc/handlers/dhcp_rpc.py.~1~	2015-10-13 10:35:16.000000000 -0700
       
    92 +++ neutron-2015.1.2/neutron/api/rpc/handlers/dhcp_rpc.py	2016-01-28 23:07:42.219930998 -0800
       
    93 @@ -188,11 +188,13 @@ class DhcpRpcCallback(object):
    54                  for fixed_ip in port['fixed_ips']:
    94                  for fixed_ip in port['fixed_ips']:
    55                      if fixed_ip['subnet_id'] in dhcp_enabled_subnet_ids:
    95                      if fixed_ip['subnet_id'] in dhcp_enabled_subnet_ids:
    56                          dhcp_enabled_subnet_ids.remove(fixed_ip['subnet_id'])
    96                          dhcp_enabled_subnet_ids.remove(fixed_ip['subnet_id'])
    57 -                port['fixed_ips'].extend(
    97 -                port['fixed_ips'].extend(
    58 -                    [dict(subnet_id=s) for s in dhcp_enabled_subnet_ids])
    98 -                    [dict(subnet_id=s) for s in dhcp_enabled_subnet_ids])