4049N/A#!/usr/bin/python2.7
2521N/A
5838N/A# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
2521N/A#
2521N/A# Licensed under the Apache License, Version 2.0 (the "License"); you may
2521N/A# not use this file except in compliance with the License. You may obtain
2521N/A# a copy of the License at
2521N/A#
2521N/A# http://www.apache.org/licenses/LICENSE-2.0
2521N/A#
2521N/A# Unless required by applicable law or agreed to in writing, software
2521N/A# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
2521N/A# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
2521N/A# License for the specific language governing permissions and limitations
2521N/A# under the License.
2521N/A
2521N/Aimport os
6846N/Afrom subprocess import CalledProcessError, check_call
2521N/Aimport sys
2521N/A
2521N/Aimport smf_include
2521N/A
2521N/A
2521N/Adef start():
6029N/A cfg_files = sys.argv[2:3]
6846N/A # It is ML2 plugin for now, until we introduce another plugin
6846N/A cfg_files.append("/etc/neutron/plugins/ml2/ml2_conf.ini")
6029N/A
6029N/A # verify paths are valid
6029N/A for f in cfg_files:
6029N/A if not os.path.exists(f) or not os.access(f, os.R_OK):
6029N/A print '%s does not exist or is not readable' % f
6029N/A return smf_include.SMF_EXIT_ERR_CONFIG
6029N/A
5838N/A # sync the database to have the Kilo schema
6029N/A cmd = ["/usr/bin/neutron-db-manage", "--config-file", cfg_files[0],
6029N/A "--config-file", cfg_files[1], "upgrade", "head"]
5838N/A try:
5838N/A check_call(cmd)
5838N/A except CalledProcessError as err:
5838N/A print "Unable to create database for Neutron: %s" % err
5838N/A sys.exit(smf_include.SMF_EXIT_ERR_CONFIG)
5838N/A
6029N/A cmd = "/usr/bin/pfexec /usr/lib/neutron/neutron-server --config-file %s " \
6029N/A "--config-file %s" % tuple(cfg_files)
2521N/A smf_include.smf_subprocess(cmd)
2521N/A
2521N/Aif __name__ == "__main__":
2521N/A os.putenv("LC_ALL", "C")
2521N/A smf_include.smf_main()