Generate a get_param from a get_input instead of inlining the default value

Change-Id: I44ccd70de4c6410f6234d291a30556caa0828d8d
Signed-off-by: Mathieu Velten <mathieu.velten@cern.ch>
This commit is contained in:
Mathieu Velten 2016-02-29 18:19:50 +01:00
parent 5ca236d44b
commit 0f62a40a8d
6 changed files with 66 additions and 5 deletions

View File

@ -326,7 +326,11 @@ class TranslateNodeTemplates(object):
if artifact.get('type', None) == 'tosca.artifacts.File':
return {'get_file': artifact.get('file')}
elif isinstance(input_value, GetInput):
return input_value.result()
if isinstance(input_value.args, list) \
and len(input_value.args) == 1:
return {'get_param': input_value.args[0]}
else:
return {'get_param': input_value.args}
return input_value

View File

@ -4,13 +4,19 @@ description: >
TOSCA template to test custom type with an interface defined on it,
and an interface overriding the type's one on the template itself
parameters: {}
parameters:
install_path:
type: string
default: /home/custom/other
resources:
customwebserver_create_deploy:
type: OS::Heat::SoftwareDeployment
properties:
config:
get_resource: customwebserver_create_config
input_values:
path:
get_param: install_path
server:
get_resource: server
server:

View File

@ -0,0 +1,34 @@
heat_template_version: 2013-05-23
description: >
TOSCA template to test custom type with an interface defined on it,
and an interface overriding the type's one on the template itself
parameters:
install_path:
type: string
default: /home/custom/from/cli
resources:
customwebserver_create_deploy:
type: OS::Heat::SoftwareDeployment
properties:
config:
get_resource: customwebserver_create_config
input_values:
path:
get_param: install_path
server:
get_resource: server
server:
type: OS::Nova::Server
properties:
flavor: m1.small
image: ubuntu-12.04-software-config-os-init
user_data_format: SOFTWARE_CONFIG
customwebserver_create_config:
type: OS::Heat::SoftwareConfig
properties:
config:
get_file: install_override.sh
group: script
outputs: {}

View File

@ -66,7 +66,8 @@ resources:
config:
get_resource: web_app_create_config
input_values:
context_root: my_web_app
context_root:
get_param: context_root
server:
get_resource: server
depends_on:

View File

@ -13,8 +13,12 @@ node_types:
implementation: install.sh
topology_template:
node_templates:
inputs:
install_path:
type: string
default: /home/custom/other
node_templates:
customwebserver:
type: tosca.nodes.CustomWebServer
requirements:
@ -23,6 +27,8 @@ topology_template:
Standard:
create:
implementation: install_override.sh
inputs:
path: { get_input: install_path }
server:
type: tosca.nodes.Compute
@ -37,4 +43,3 @@ topology_template:
distribution: Ubuntu
version: 12.04
architecture: x86_64

View File

@ -544,6 +544,17 @@ class ToscaHotTranslationTest(TestCase):
self.assertEqual({}, diff, '<difference> : ' +
json.dumps(diff, indent=4, separators=(', ', ': ')))
def test_hot_translate_custom_type_with_param_override(self):
tosca_file = '../tests/data/test_tosca_custom_type_with_override.yaml'
hot_file = '../tests/data/hot_output/' \
'hot_custom_type_with_param_override.yaml'
params = {'install_path': '/home/custom/from/cli'}
diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
hot_file,
params)
self.assertEqual({}, diff, '<difference> : ' +
json.dumps(diff, indent=4, separators=(', ', ': ')))
def test_hot_translate_artifact(self):
tosca_file = '../tests/data/test_tosca_artifact.yaml'
hot_file = '../tests/data/hot_output/' \