Adding log to db_sync

if called by mistral-db-manage it will log info level
    to /var/log/mistral/mistral-db-manage

Included some debug level logging also for main actions.

Change-Id: I0574b38efcc0dd7485953bf3089ff0a5a3ef6394
Closes-Bug: #1689821
This commit is contained in:
Adriano Petrich 2017-05-11 15:46:25 +01:00
parent b6de4720db
commit 4c53234e27
3 changed files with 18 additions and 1 deletions

View File

@ -19,6 +19,7 @@ from alembic import command as alembic_cmd
from alembic import config as alembic_cfg
from alembic import util as alembic_u
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import importutils
import six
import sys
@ -34,6 +35,7 @@ importutils.try_import('mistral.api.app')
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
def do_alembic_command(config, cmd, *args, **kwargs):
@ -69,6 +71,7 @@ def do_stamp(config, cmd):
def do_populate(config, cmd):
LOG.info("populating db")
action_manager.sync_db()
workflows.sync_db()
@ -127,8 +130,10 @@ def main():
)
# attach the Mistral conf to the Alembic conf
config.mistral_config = CONF
logging.register_options(CONF)
CONF(project='mistral')
logging.setup(CONF, 'Mistral')
CONF.command.func(config, CONF.command.name)
if __name__ == '__main__':

View File

@ -18,12 +18,15 @@ from mistral.lang import parser as spec_parser
from mistral import utils
from mistral.workflow import data_flow
from mistral.workflow import states
from oslo_log import log as logging
STD_WF_PATH = 'resources/workflows'
LOG = logging.getLogger(__name__)
def register_standard_workflows(run_in_tx=True):
LOG.debug("registering standard workflows")
workflow_paths = utils.get_file_list(STD_WF_PATH)
for wf_path in workflow_paths:
@ -42,6 +45,7 @@ def _clear_system_workflow_db():
def sync_db():
LOG.debug("Syncing db")
with db_api.transaction():
_clear_system_workflow_db()
register_standard_workflows(run_in_tx=False)
@ -49,6 +53,7 @@ def sync_db():
def create_workflows(definition, scope='private', is_system=False,
run_in_tx=True):
LOG.debug("creating workflows")
wf_list_spec = spec_parser.get_workflow_list_spec_from_yaml(definition)
db_wfs = []
@ -81,6 +86,7 @@ def _append_all_workflows(definition, is_system, scope, wf_list_spec, db_wfs):
def update_workflows(definition, scope='private', identifier=None):
LOG.debug("updating workflows")
wf_list_spec = spec_parser.get_workflow_list_spec_from_yaml(definition)
wfs = wf_list_spec.get_workflows()

View File

@ -24,6 +24,7 @@ from mistral.services import action_manager
from mistral.services import workflows
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
def main():
@ -37,16 +38,21 @@ def main():
CONF.register_cli_opt(config.os_actions_mapping_path)
logging.register_options(CONF)
config.parse_args()
if len(CONF.config_file) == 0:
print("Usage: sync_db --config-file <path-to-config-file>")
return exit(1)
logging.setup(CONF, 'Mistral')
LOG.info("Starting db_sync")
LOG.debug("Setting up db")
db_api.setup_db()
LOG.debug("populating db")
action_manager.sync_db()
workflows.sync_db()