2014-08-22 18:00:43 +04:00
|
|
|
# Copyright 2014 - Mirantis, Inc.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2016-09-26 10:51:27 +07:00
|
|
|
import sys
|
|
|
|
|
2016-08-04 14:37:27 +03:00
|
|
|
import keystonemiddleware.opts as keystonemw_opts
|
2015-07-22 14:25:03 +03:00
|
|
|
from oslo_config import cfg
|
2015-04-10 16:29:42 +08:00
|
|
|
from oslo_log import log as logging
|
2014-08-22 18:00:43 +04:00
|
|
|
|
|
|
|
from mistral import config
|
2015-12-01 15:11:42 -05:00
|
|
|
from mistral.db.v2 import api as db_api
|
2014-08-27 11:49:04 +04:00
|
|
|
from mistral.services import action_manager
|
2014-10-09 17:07:54 +04:00
|
|
|
from mistral.services import workflows
|
2014-08-22 18:00:43 +04:00
|
|
|
|
|
|
|
CONF = cfg.CONF
|
2017-05-11 15:46:25 +01:00
|
|
|
LOG = logging.getLogger(__name__)
|
2014-08-22 18:00:43 +04:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2016-08-04 14:37:27 +03:00
|
|
|
# NOTE(jaosorior): This is needed in order for db-sync to also register the
|
|
|
|
# keystonemiddleware options. Those options are used by clients that need a
|
|
|
|
# keystone session in order to be able to register their actions.
|
|
|
|
# This can be removed when mistral moves out of using keystonemiddleware in
|
|
|
|
# favor of keystoneauth1.
|
|
|
|
for group, opts in keystonemw_opts.list_auth_token_opts():
|
|
|
|
CONF.register_opts(opts, group=group)
|
|
|
|
|
2017-02-15 12:34:14 +01:00
|
|
|
CONF.register_cli_opt(config.os_actions_mapping_path)
|
|
|
|
|
2017-05-11 15:46:25 +01:00
|
|
|
logging.register_options(CONF)
|
|
|
|
|
2014-08-22 18:00:43 +04:00
|
|
|
config.parse_args()
|
2014-09-11 13:25:46 +04:00
|
|
|
|
|
|
|
if len(CONF.config_file) == 0:
|
2015-12-01 15:11:42 -05:00
|
|
|
print("Usage: sync_db --config-file <path-to-config-file>")
|
2014-09-11 13:25:46 +04:00
|
|
|
return exit(1)
|
2015-04-10 16:29:42 +08:00
|
|
|
logging.setup(CONF, 'Mistral')
|
2014-08-22 18:00:43 +04:00
|
|
|
|
2017-05-11 15:46:25 +01:00
|
|
|
LOG.info("Starting db_sync")
|
|
|
|
|
|
|
|
LOG.debug("Setting up db")
|
2014-08-22 18:00:43 +04:00
|
|
|
db_api.setup_db()
|
|
|
|
|
2017-05-11 15:46:25 +01:00
|
|
|
LOG.debug("populating db")
|
2014-08-27 11:49:04 +04:00
|
|
|
action_manager.sync_db()
|
2014-10-09 17:07:54 +04:00
|
|
|
workflows.sync_db()
|
2014-08-22 18:00:43 +04:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2016-09-26 10:51:27 +07:00
|
|
|
sys.exit(main())
|