Fix stack preview
Don't execute translation rule for property that contains
a GetParam function that can't be resolved at the moment.
Such situation happens when we try to resolve get_param function
that refer to parameter with None value. We receive parameter value
from parent stack, where this value is a reference to some resource
without resource_id, so this situation is legal for stack preview
and we shouldn't fail. Note, that we can reproduce this behaviour
only with resources with hidden parameters and overrided get_resource_id
method, that returns None if resoruce creation has not been started yet.
Change-Id: Ia1097940db983721c8b5116db7ee0a2c4c45339d
Closes-Bug: #1548802
diff --git a/functional/test_preview.py b/functional/test_preview.py
index 5846523..99c24eb 100644
--- a/functional/test_preview.py
+++ b/functional/test_preview.py
@@ -186,3 +186,44 @@
self.assertEqual('abc', res['properties']['value'])
self.assertEqual([], res['required_by'])
+
+ def test_res_group_with_nested_template(self):
+ main_template = '''
+heat_template_version: 2015-04-30
+resources:
+ fixed_network:
+ type: "OS::Neutron::Net"
+ rg:
+ type: "OS::Heat::ResourceGroup"
+ properties:
+ count: 1
+ resource_def:
+ type: nested.yaml
+ properties:
+ fixed_network_id: {get_resource: fixed_network}
+ '''
+ nested_template = '''
+heat_template_version: 2015-04-30
+
+parameters:
+ fixed_network_id:
+ type: string
+resources:
+ port:
+ type: "OS::Neutron::Port"
+ properties:
+ network_id:
+ get_param: fixed_network_id
+
+'''
+ stack_name = self._stack_rand_name()
+ result = self.client.stacks.preview(
+ disable_rollback=True,
+ stack_name=stack_name,
+ template=main_template,
+ files={'nested.yaml': nested_template}).to_dict()
+ # ensure that fixed network and port here
+ self.assertEqual('fixed_network',
+ result['resources'][0]['resource_name'])
+ self.assertEqual('port',
+ result['resources'][1][0][0]['resource_name'])