diff options
author | shangxdy <shang.xiaodong@zte.com.cn> | 2016-08-22 10:56:23 +0800 |
---|---|---|
committer | shangxdy <shang.xiaodong@zte.com.cn> | 2016-08-22 10:56:23 +0800 |
commit | fb0a919b86d862ca3d4454b4c563b4f2eea8144d (patch) | |
tree | 4e46ac335ca636734802cd1e184219c420e37136 /tosca2heat | |
parent | 6fecb729f550f4f543739375df8148ab9de38668 (diff) |
Modify the stack name to template file name when deploy stack use
heat-translator
When deploy a stack online, it can specify a name as a input name(which
was added by issue PARSER-91), but the parameter is optional, if no
specified name, currently the default stack name is shown below:
'heat' + first part of a random uuid
For readable and to be easier founded, the default name will be improved
to be the follow:
'heat' + filename of template file + first part of a random uuid.
JIRA:PARSER-93
Change-Id: Ib8f5fd18bf4e57d2424c2a439aa6db8feead44cd
Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
Diffstat (limited to 'tosca2heat')
-rw-r--r-- | tosca2heat/heat-translator/translator/shell.py | 9 | ||||
-rw-r--r-- | tosca2heat/heat-translator/translator/tests/test_shell.py | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/tosca2heat/heat-translator/translator/shell.py b/tosca2heat/heat-translator/translator/shell.py index 884e3a6..dc49b5c 100644 --- a/tosca2heat/heat-translator/translator/shell.py +++ b/tosca2heat/heat-translator/translator/shell.py @@ -129,7 +129,10 @@ class TranslatorShell(object): if heat_tpl: if utils.check_for_env_variables() and deploy: try: - heatclient(heat_tpl, stack_name, parsed_params) + file_name = os.path.basename( + os.path.splitext(template_file)[0]) + heatclient(heat_tpl, stack_name, + file_name, parsed_params) except Exception: log.error(_("Unable to launch the heat stack")) @@ -184,7 +187,7 @@ class TranslatorShell(object): print(output) -def heatclient(output, stack_name, params): +def heatclient(output, stack_name, file_name, params): try: access_dict = utils.get_ks_access_dict() endpoint = utils.get_url_for(access_dict, 'orchestration') @@ -197,7 +200,7 @@ def heatclient(output, stack_name, params): } heat_stack_name = stack_name if stack_name else \ - "heat_" + str(uuid.uuid4()).split("-")[0] + "heat_" + file_name + '_' + str(uuid.uuid4()).split("-")[0] output = yaml.load(output) output['heat_template_version'] = str(output['heat_template_version']) data = { diff --git a/tosca2heat/heat-translator/translator/tests/test_shell.py b/tosca2heat/heat-translator/translator/tests/test_shell.py index 62f3510..5d41921 100644 --- a/tosca2heat/heat-translator/translator/tests/test_shell.py +++ b/tosca2heat/heat-translator/translator/tests/test_shell.py @@ -137,7 +137,7 @@ class ShellTest(TestCase): 'demo', 'http://www.abc.com'] try: data = { - 'stack_name': 'heat_abcXXX', + 'stack_name': 'heat_tosca_helloworld_abcXXX', 'parameters': {}, 'template': { 'outputs': {}, |