Return None for attributes of sd with no actions
If the 'actions' property of a deployment is [], we don't create a software deployment in heat and resource_id of the software deployment is None. However, there is a possibility that we access the attributes of the sd in the template and that results in TypeError as we try to make an rpc call to show the software deployment for None. Change-Id: Iefd3cdd20bb51c63e7267ae0628e0f15544c0427 Task: 33516
This commit is contained in:
parent
c4076e12c8
commit
ee06110347
|
@ -545,12 +545,13 @@ class SoftwareDeployment(signal_responder.SignalResponder):
|
||||||
|
|
||||||
def get_attribute(self, key, *path):
|
def get_attribute(self, key, *path):
|
||||||
"""Resource attributes map to deployment outputs values."""
|
"""Resource attributes map to deployment outputs values."""
|
||||||
sd = self.rpc_client().show_software_deployment(
|
if self.resource_id is not None:
|
||||||
self.context, self.resource_id)
|
sd = self.rpc_client().show_software_deployment(
|
||||||
ov = sd[rpc_api.SOFTWARE_DEPLOYMENT_OUTPUT_VALUES] or {}
|
self.context, self.resource_id)
|
||||||
if key in ov:
|
ov = sd[rpc_api.SOFTWARE_DEPLOYMENT_OUTPUT_VALUES] or {}
|
||||||
attribute = ov.get(key)
|
if key in ov:
|
||||||
return attributes.select_from_attribute(attribute, path)
|
attribute = ov.get(key)
|
||||||
|
return attributes.select_from_attribute(attribute, path)
|
||||||
|
|
||||||
# Since there is no value for this key yet, check the output schemas
|
# Since there is no value for this key yet, check the output schemas
|
||||||
# to find out if the key is valid
|
# to find out if the key is valid
|
||||||
|
|
|
@ -201,7 +201,6 @@ class SoftwareDeploymentTest(common.HeatTestCase):
|
||||||
get_ec2_signed_url.return_value = 'http://192.0.2.2/signed_url'
|
get_ec2_signed_url.return_value = 'http://192.0.2.2/signed_url'
|
||||||
|
|
||||||
self.deployment = self.stack['deployment_mysql']
|
self.deployment = self.stack['deployment_mysql']
|
||||||
|
|
||||||
self.rpc_client = mock.MagicMock()
|
self.rpc_client = mock.MagicMock()
|
||||||
self.deployment._rpc_client = self.rpc_client
|
self.deployment._rpc_client = self.rpc_client
|
||||||
|
|
||||||
|
@ -1097,6 +1096,7 @@ class SoftwareDeploymentTest(common.HeatTestCase):
|
||||||
|
|
||||||
def test_fn_get_att(self):
|
def test_fn_get_att(self):
|
||||||
self._create_stack(self.template)
|
self._create_stack(self.template)
|
||||||
|
self.deployment.resource_id = 'c8a19429-7fde-47ea-a42f-40045488226c'
|
||||||
mock_sd = {
|
mock_sd = {
|
||||||
'outputs': [
|
'outputs': [
|
||||||
{'name': 'failed', 'error_output': True},
|
{'name': 'failed', 'error_output': True},
|
||||||
|
@ -1132,6 +1132,7 @@ class SoftwareDeploymentTest(common.HeatTestCase):
|
||||||
|
|
||||||
def test_fn_get_att_error(self):
|
def test_fn_get_att_error(self):
|
||||||
self._create_stack(self.template)
|
self._create_stack(self.template)
|
||||||
|
self.deployment.resource_id = 'c8a19429-7fde-47ea-a42f-40045488226c'
|
||||||
|
|
||||||
mock_sd = {
|
mock_sd = {
|
||||||
'outputs': [],
|
'outputs': [],
|
||||||
|
|
Loading…
Reference in New Issue