15 # under the License. |
15 # under the License. |
16 |
16 |
17 import os |
17 import os |
18 import sys |
18 import sys |
19 |
19 |
|
20 from openstack_common import is_ml2_plugin |
20 import smf_include |
21 import smf_include |
21 from subprocess import CalledProcessError, check_call |
22 from subprocess import CalledProcessError, check_call |
22 |
23 |
23 |
24 |
24 def start(): |
25 def start(): |
|
26 cfg_files = sys.argv[2:3] |
|
27 if is_ml2_plugin(): |
|
28 cfg_files.append("/etc/neutron/plugins/ml2/ml2_conf.ini") |
|
29 else: |
|
30 cfg_files.append("/etc/neutron/plugins/evs/evs_plugin.ini") |
|
31 |
|
32 # verify paths are valid |
|
33 for f in cfg_files: |
|
34 if not os.path.exists(f) or not os.access(f, os.R_OK): |
|
35 print '%s does not exist or is not readable' % f |
|
36 return smf_include.SMF_EXIT_ERR_CONFIG |
|
37 |
25 # sync the database to have the Kilo schema |
38 # sync the database to have the Kilo schema |
26 cmd = ["/usr/bin/neutron-db-manage", "--config-file", |
39 cmd = ["/usr/bin/neutron-db-manage", "--config-file", cfg_files[0], |
27 "/etc/neutron/neutron.conf", "--config-file", |
40 "--config-file", cfg_files[1], "upgrade", "head"] |
28 "/etc/neutron/plugins/evs/evs_plugin.ini", "upgrade", "head"] |
|
29 try: |
41 try: |
30 check_call(cmd) |
42 check_call(cmd) |
31 except CalledProcessError as err: |
43 except CalledProcessError as err: |
32 print "Unable to create database for Neutron: %s" % err |
44 print "Unable to create database for Neutron: %s" % err |
33 sys.exit(smf_include.SMF_EXIT_ERR_CONFIG) |
45 sys.exit(smf_include.SMF_EXIT_ERR_CONFIG) |
34 |
46 |
35 # verify paths are valid |
47 cmd = "/usr/bin/pfexec /usr/lib/neutron/neutron-server --config-file %s " \ |
36 for f in sys.argv[2:4]: |
48 "--config-file %s" % tuple(cfg_files) |
37 if not os.path.exists(f) or not os.access(f, os.R_OK): |
|
38 print '%s does not exist or is not readable' % f |
|
39 return smf_include.SMF_EXIT_ERR_CONFIG |
|
40 |
|
41 cmd = "/usr/lib/neutron/neutron-server --config-file %s " \ |
|
42 "--config-file %s" % tuple(sys.argv[2:4]) |
|
43 smf_include.smf_subprocess(cmd) |
49 smf_include.smf_subprocess(cmd) |
44 |
50 |
45 if __name__ == "__main__": |
51 if __name__ == "__main__": |
46 os.putenv("LC_ALL", "C") |
52 os.putenv("LC_ALL", "C") |
47 smf_include.smf_main() |
53 smf_include.smf_main() |