components/openstack/neutron/files/neutron-openvswitch-agent
changeset 7315 5cc40226273b
parent 6031 1aaf20a19738
equal deleted inserted replaced
7314:014a673c1f62 7315:5cc40226273b
    13 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    13 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    14 #    License for the specific language governing permissions and limitations
    14 #    License for the specific language governing permissions and limitations
    15 #    under the License.
    15 #    under the License.
    16 
    16 
    17 import os
    17 import os
       
    18 from subprocess import CalledProcessError, check_call
    18 import sys
    19 import sys
    19 
    20 
    20 import smf_include
    21 import smf_include
       
    22 
       
    23 from neutron.agent.solaris import packetfilter
    21 
    24 
    22 
    25 
    23 def start():
    26 def start():
    24     # verify paths are valid
    27     # verify paths are valid
    25     for f in sys.argv[2:4]:
    28     for f in sys.argv[2:4]:
    26         if not os.path.exists(f) or not os.access(f, os.R_OK):
    29         if not os.path.exists(f) or not os.access(f, os.R_OK):
    27             print '%s does not exist or is not readable' % f
    30             print '%s does not exist or is not readable' % f
    28             return smf_include.SMF_EXIT_ERR_CONFIG
    31             return smf_include.SMF_EXIT_ERR_CONFIG
    29 
    32 
       
    33     # Cleanup any security groups related PF rules
       
    34     pf = packetfilter.PacketFilter('_auto/neutron:ovs:agent')
       
    35     pf.remove_anchor_recursively()    
       
    36 
    30     cmd = "/usr/bin/pfexec /usr/lib/neutron/neutron-openvswitch-agent " \
    37     cmd = "/usr/bin/pfexec /usr/lib/neutron/neutron-openvswitch-agent " \
    31         "--config-file %s --config-file %s" % tuple(sys.argv[2:4])
    38         "--config-file %s --config-file %s" % tuple(sys.argv[2:4])
    32     smf_include.smf_subprocess(cmd)
    39     smf_include.smf_subprocess(cmd)
    33 
    40 
       
    41 
       
    42 def stop():
       
    43     try:
       
    44         # first kill the SMF contract
       
    45         check_call(["/usr/bin/pkill", "-c", sys.argv[2]])
       
    46     except CalledProcessError as err:
       
    47         print "failed to kill the SMF contract: %s" % err
       
    48         return smf_include.SMF_EXIT_ERR_FATAL
       
    49 
       
    50     # We need to remove the PF rules added under _auto/neutron:ovs:agent
       
    51     # anchor.
       
    52     pf = packetfilter.PacketFilter('_auto/neutron:ovs:agent')
       
    53     pf.remove_anchor_recursively()
       
    54     return smf_include.SMF_EXIT_OK
       
    55 
       
    56 
    34 if __name__ == "__main__":
    57 if __name__ == "__main__":
    35     os.putenv("LC_ALL", "C")
    58     os.putenv("LC_ALL", "C")
    36     smf_include.smf_main()
    59     smf_include.smf_main()