components/openstack/neutron/files/neutron-dhcp-agent
changeset 6848 8e252a37ed0d
parent 6382 ed601ca40b9c
equal deleted inserted replaced
6847:57069587975f 6848:8e252a37ed0d
    15 #    under the License.
    15 #    under the License.
    16 
    16 
    17 import ConfigParser
    17 import ConfigParser
    18 import os
    18 import os
    19 import re
    19 import re
       
    20 from subprocess import CalledProcessError, Popen, PIPE, check_call
    20 import sys
    21 import sys
    21 
    22 
    22 from openstack_common import is_ml2_plugin, kill_contract
    23 from openstack_common import kill_contract
    23 import smf_include
    24 import smf_include
    24 
       
    25 from subprocess import CalledProcessError, Popen, PIPE, check_call
       
    26 
    25 
    27 
    26 
    28 def set_hostmodel(value):
    27 def set_hostmodel(value):
    29     cmd = ["/usr/sbin/ipadm", "show-prop", "-p", "hostmodel",
    28     cmd = ["/usr/sbin/ipadm", "show-prop", "-p", "hostmodel",
    30            "-co", "current", "ipv4"]
    29            "-co", "current", "ipv4"]
    56     dlnames = output.splitlines()
    55     dlnames = output.splitlines()
    57     # DHCP agent datalinks are always 15 characters in length. They start with
    56     # DHCP agent datalinks are always 15 characters in length. They start with
    58     # 'dh', end with '_0', and in between they are hexadecimal digits.
    57     # 'dh', end with '_0', and in between they are hexadecimal digits.
    59     prog = re.compile('dh[0-9A-Fa-f\_]{11}_0')
    58     prog = re.compile('dh[0-9A-Fa-f\_]{11}_0')
    60     ret_code = smf_include.SMF_EXIT_OK
    59     ret_code = smf_include.SMF_EXIT_OK
    61     ovs_bridge = None
    60     ovs_bridge = get_ovs_bridge()
    62     if is_ml2_plugin():
       
    63         ovs_bridge = get_ovs_bridge()
       
    64     for dlname in dlnames:
    61     for dlname in dlnames:
    65         if prog.search(dlname) is None:
    62         if prog.search(dlname) is None:
    66             continue
    63             continue
    67         try:
    64         try:
    68             # first remove the IP
    65             # first remove the IP
   108     smf_include.smf_subprocess(cmd)
   105     smf_include.smf_subprocess(cmd)
   109 
   106 
   110 
   107 
   111 def get_ovs_bridge():
   108 def get_ovs_bridge():
   112     parser = ConfigParser.ConfigParser()
   109     parser = ConfigParser.ConfigParser()
   113     parser.read("/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini")
   110     parser.read("/etc/neutron/plugins/ml2/openvswitch_agent.ini")
   114     try:
   111     try:
   115         ovs_bridge = parser.get("ovs", "integration_bridge")
   112         ovs_bridge = parser.get("ovs", "integration_bridge")
   116     except ConfigParser.NoOptionError:
   113     except ConfigParser.NoOptionError:
   117         ovs_bridge = None
   114         ovs_bridge = None
   118     return ovs_bridge
   115     return ovs_bridge