17 import os |
17 import os |
18 import sys |
18 import sys |
19 |
19 |
20 import smf_include |
20 import smf_include |
21 |
21 |
|
22 from subprocess import Popen, PIPE |
|
23 |
22 |
24 |
23 def start(): |
25 def start(): |
24 # verify paths are valid |
26 # verify paths are valid |
25 for f in sys.argv[2:4]: |
27 for f in sys.argv[2:4]: |
26 if not os.path.exists(f) or not os.access(f, os.R_OK): |
28 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 |
29 print '%s does not exist or is not readable' % f |
28 return smf_include.SMF_EXIT_ERR_CONFIG |
30 return smf_include.SMF_EXIT_ERR_CONFIG |
29 |
31 |
|
32 # System-wide forwarding (either ipv4 or ipv6 or both) must be enabled |
|
33 # before neutron-l3-agent can be started. |
|
34 cmd = ["/usr/sbin/ipadm", "show-prop", "-c", "-p", "forwarding", |
|
35 "-o", "current", "ipv4"] |
|
36 p = Popen(cmd, stdout=PIPE, stderr=PIPE) |
|
37 output, error = p.communicate() |
|
38 if p.returncode != 0: |
|
39 print "failed to determine if IPv4 forwarding is enabled or not" |
|
40 return smf_include.SMF_EXIT_ERR_FATAL |
|
41 v4fwding = "on" in output |
|
42 |
|
43 cmd = ["/usr/sbin/ipadm", "show-prop", "-c", "-p", "forwarding", |
|
44 "-o", "current", "ipv6"] |
|
45 p = Popen(cmd, stdout=PIPE, stderr=PIPE) |
|
46 output, error = p.communicate() |
|
47 if p.returncode != 0: |
|
48 print "failed to determine if IPv6 forwarding is enabled or not" |
|
49 return smf_include.SMF_EXIT_ERR_FATAL |
|
50 v6fwding = "on" in output |
|
51 |
|
52 if not any((v4fwding, v6fwding)): |
|
53 print "System-wide IPv4 or IPv6 (or both) forwarding must be enabled " \ |
|
54 "before enabling %s" % os.getenv("SMF_FMRI") |
|
55 return smf_include.SMF_EXIT_ERR_CONFIG |
|
56 |
30 cmd = "/usr/lib/neutron/neutron-l3-agent --config-file %s " \ |
57 cmd = "/usr/lib/neutron/neutron-l3-agent --config-file %s " \ |
31 "--config-file %s" % tuple(sys.argv[2:4]) |
58 "--config-file %s" % tuple(sys.argv[2:4]) |
32 smf_include.smf_subprocess(cmd) |
59 smf_include.smf_subprocess(cmd) |
33 |
60 |
34 if __name__ == "__main__": |
61 if __name__ == "__main__": |