diff options
author | shangxdy <shang.xiaodong@zte.com.cn> | 2016-08-19 01:30:06 +0800 |
---|---|---|
committer | shangxdy <shang.xiaodong@zte.com.cn> | 2016-08-19 01:30:06 +0800 |
commit | b47932b36b9e69168ea7e0e55461596bcafcf93b (patch) | |
tree | ea0675a36293e41d19ff16185ceb8c1f3e16c3df /tosca2heat/heat-translator/translator/shell.py | |
parent | 278a8fcc9ac9d18d8192d22aca50b39371894db5 (diff) |
Provide a specific stack_name when deploy a template use heat-translator
Currently, the stack ame of a template is random when use
heat-translator online, and there is not any other feedback information
except success or failure, the result is not very convenient.
So it is necessary to provide a stack name when deploy a template.
Note: the improvement will submit to openstack community.
JIRA:PARSER-91
Change-Id: Ia5f99c38301211dfb9c21a8b10dd31a50b82f966
Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
Diffstat (limited to 'tosca2heat/heat-translator/translator/shell.py')
-rw-r--r-- | tosca2heat/heat-translator/translator/shell.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tosca2heat/heat-translator/translator/shell.py b/tosca2heat/heat-translator/translator/shell.py index d5333bc..884e3a6 100644 --- a/tosca2heat/heat-translator/translator/shell.py +++ b/tosca2heat/heat-translator/translator/shell.py @@ -91,6 +91,12 @@ class TranslatorShell(object): help=_('Whether to deploy the generated template ' 'or not.')) + parser.add_argument('--stack-name', + metavar='<stack-name>', + required=False, + help=_('Stack name when deploy the generated ' + 'template.')) + return parser def main(self, argv): @@ -103,6 +109,7 @@ class TranslatorShell(object): output_file = args.output_file validate_only = args.validate_only deploy = args.deploy + stack_name = args.stack_name parsed_params = {} if args.parameters: @@ -122,7 +129,7 @@ class TranslatorShell(object): if heat_tpl: if utils.check_for_env_variables() and deploy: try: - heatclient(heat_tpl, parsed_params) + heatclient(heat_tpl, stack_name, parsed_params) except Exception: log.error(_("Unable to launch the heat stack")) @@ -177,7 +184,7 @@ class TranslatorShell(object): print(output) -def heatclient(output, params): +def heatclient(output, stack_name, params): try: access_dict = utils.get_ks_access_dict() endpoint = utils.get_url_for(access_dict, 'orchestration') @@ -188,7 +195,9 @@ def heatclient(output, params): 'Content-Type': 'application/json', 'X-Auth-Token': token } - heat_stack_name = "heat_" + str(uuid.uuid4()).split("-")[0] + + heat_stack_name = stack_name if stack_name else \ + "heat_" + str(uuid.uuid4()).split("-")[0] output = yaml.load(output) output['heat_template_version'] = str(output['heat_template_version']) data = { |