From 5e41fc7f211eb9ade27b3c4339add8588834575e Mon Sep 17 00:00:00 2001 From: Istvan Imre Date: Wed, 11 Jan 2017 09:02:17 +0100 Subject: [PATCH] External OpenStack action mapping file support added It was not possible to specify external openstack action mappong files for mistral, but now support for extenal mappings with absolute path is added. Change-Id: Ia4fa15d396e3c1f5ad91cbcf2fa69a75443becf6 Closes-Bug: #1655557 --- mistral/actions/openstack/action_generator/base.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mistral/actions/openstack/action_generator/base.py b/mistral/actions/openstack/action_generator/base.py index cd1323b9..49b41476 100644 --- a/mistral/actions/openstack/action_generator/base.py +++ b/mistral/actions/openstack/action_generator/base.py @@ -13,6 +13,7 @@ # limitations under the License. import json +import os from oslo_config import cfg from oslo_log import log as logging @@ -29,7 +30,6 @@ os_actions_mapping_path = cfg.StrOpt('openstack_actions_mapping_path', CONF = cfg.CONF CONF.register_opt(os_actions_mapping_path) LOG = logging.getLogger(__name__) -MAPPING_PATH = CONF.openstack_actions_mapping_path def get_mapping(): @@ -40,7 +40,17 @@ def get_mapping(): if '_comment' in map_part: del map_part['_comment'] package = version.version_info.package - with open(pkg.resource_filename(package, MAPPING_PATH)) as fh: + + if os.path.isabs(CONF.openstack_actions_mapping_path): + mapping_file_path = CONF.openstack_actions_mapping_path + else: + path = CONF.openstack_actions_mapping_path + mapping_file_path = pkg.resource_filename(package, path) + + LOG.info("Processing OpenStack action mapping from file: %s", + mapping_file_path) + + with open(mapping_file_path) as fh: mapping = json.load(fh) for k, v in mapping.items():