diff options
author | Zuul <zuul@review.opendev.org> | 2019-05-31 22:26:50 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2019-05-31 22:26:50 +0000 |
commit | 941619d8c5dc244ae780355415686a0838ca9913 (patch) | |
tree | 0fd02ccc5bcc177ea37141323e189cd1a304266d | |
parent | 9bd44195997ca56eb4a4c1f19baa59c2ae0390f6 (diff) | |
parent | d15c9d7eceb95730c25a55d11d38c3b1f4b4de50 (diff) | |
download | heat-941619d8c5dc244ae780355415686a0838ca9913.tar.gz |
Merge "Return None for attributes of sd with no actions" into stable/rocky
-rw-r--r-- | heat/engine/resources/openstack/heat/software_deployment.py | 13 | ||||
-rw-r--r-- | heat/tests/openstack/heat/test_software_deployment.py | 3 |
2 files changed, 9 insertions, 7 deletions
diff --git a/heat/engine/resources/openstack/heat/software_deployment.py b/heat/engine/resources/openstack/heat/software_deployment.py index 8ee64138c..2e46efc27 100644 --- a/heat/engine/resources/openstack/heat/software_deployment.py +++ b/heat/engine/resources/openstack/heat/software_deployment.py @@ -547,12 +547,13 @@ class SoftwareDeployment(signal_responder.SignalResponder): def get_attribute(self, key, *path): """Resource attributes map to deployment outputs values.""" - sd = self.rpc_client().show_software_deployment( - self.context, self.resource_id) - ov = sd[rpc_api.SOFTWARE_DEPLOYMENT_OUTPUT_VALUES] or {} - if key in ov: - attribute = ov.get(key) - return attributes.select_from_attribute(attribute, path) + if self.resource_id is not None: + sd = self.rpc_client().show_software_deployment( + self.context, self.resource_id) + ov = sd[rpc_api.SOFTWARE_DEPLOYMENT_OUTPUT_VALUES] or {} + if key in ov: + attribute = ov.get(key) + return attributes.select_from_attribute(attribute, path) # Since there is no value for this key yet, check the output schemas # to find out if the key is valid diff --git a/heat/tests/openstack/heat/test_software_deployment.py b/heat/tests/openstack/heat/test_software_deployment.py index 1ee154994..985030813 100644 --- a/heat/tests/openstack/heat/test_software_deployment.py +++ b/heat/tests/openstack/heat/test_software_deployment.py @@ -201,7 +201,6 @@ class SoftwareDeploymentTest(common.HeatTestCase): get_ec2_signed_url.return_value = 'http://192.0.2.2/signed_url' self.deployment = self.stack['deployment_mysql'] - self.rpc_client = mock.MagicMock() self.deployment._rpc_client = self.rpc_client @@ -1097,6 +1096,7 @@ class SoftwareDeploymentTest(common.HeatTestCase): def test_fn_get_att(self): self._create_stack(self.template) + self.deployment.resource_id = 'c8a19429-7fde-47ea-a42f-40045488226c' mock_sd = { 'outputs': [ {'name': 'failed', 'error_output': True}, @@ -1132,6 +1132,7 @@ class SoftwareDeploymentTest(common.HeatTestCase): def test_fn_get_att_error(self): self._create_stack(self.template) + self.deployment.resource_id = 'c8a19429-7fde-47ea-a42f-40045488226c' mock_sd = { 'outputs': [], |