summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-01-28 22:49:40 +0000
committerGerrit Code Review <review@openstack.org>2016-01-28 22:49:41 +0000
commit1e3145e84f5be22909fa1cb8ccbf06290e3ec190 (patch)
treef8d4d5b433e1d7f79c5492ea69a26949f75dd368
parent2f2798272b3ec71faee25f794265c28319f29068 (diff)
parent24228cbc0620d05a7d057edd35d894561eab514d (diff)
downloadheat-1e3145e84f5be22909fa1cb8ccbf06290e3ec190.tar.gz
Merge "Don't calculate attributes for metadata request" into stable/kilo
-rw-r--r--heat/api/openstack/v1/resources.py2
-rw-r--r--heat/engine/api.py5
-rw-r--r--heat/rpc/client.py2
-rw-r--r--heat/tests/test_api_cfn_v1.py4
-rw-r--r--heat/tests/test_api_openstack_v1.py9
-rw-r--r--heat/tests/test_engine_api_utils.py6
6 files changed, 20 insertions, 8 deletions
diff --git a/heat/api/openstack/v1/resources.py b/heat/api/openstack/v1/resources.py
index bed6e470c..ddef18e4a 100644
--- a/heat/api/openstack/v1/resources.py
+++ b/heat/api/openstack/v1/resources.py
@@ -101,6 +101,8 @@ class ResourceController(object):
whitelist = {'with_attr': 'multi'}
params = util.get_allowed_params(req.params, whitelist)
+ if 'with_attr' not in params:
+ params['with_attr'] = None
res = self.rpc_client.describe_stack_resource(req.context,
identity,
resource_name,
diff --git a/heat/engine/api.py b/heat/engine/api.py
index 998cb99c5..074ace9b9 100644
--- a/heat/engine/api.py
+++ b/heat/engine/api.py
@@ -186,8 +186,9 @@ def format_stack_resource(resource, detail=True, with_props=False,
if detail:
res[rpc_api.RES_DESCRIPTION] = resource.t.description
res[rpc_api.RES_METADATA] = resource.metadata_get()
- res[rpc_api.RES_SCHEMA_ATTRIBUTES] = format_resource_attributes(
- resource, with_attr)
+ if with_attr is not False:
+ res[rpc_api.RES_SCHEMA_ATTRIBUTES] = format_resource_attributes(
+ resource, with_attr)
if with_props:
res[rpc_api.RES_SCHEMA_PROPERTIES] = format_resource_properties(
diff --git a/heat/rpc/client.py b/heat/rpc/client.py
index a4f81bc23..bb4bf3014 100644
--- a/heat/rpc/client.py
+++ b/heat/rpc/client.py
@@ -336,7 +336,7 @@ class EngineClient(object):
sort_dir=sort_dir))
def describe_stack_resource(self, ctxt, stack_identity, resource_name,
- with_attr=None):
+ with_attr=False):
"""
Get detailed resource information about a particular resource.
:param ctxt: RPC context.
diff --git a/heat/tests/test_api_cfn_v1.py b/heat/tests/test_api_cfn_v1.py
index 886bfe27e..267224ed7 100644
--- a/heat/tests/test_api_cfn_v1.py
+++ b/heat/tests/test_api_cfn_v1.py
@@ -1288,7 +1288,7 @@ class CfnStackControllerTest(common.HeatTestCase):
args = {
'stack_identity': identity,
'resource_name': dummy_req.params.get('LogicalResourceId'),
- 'with_attr': None,
+ 'with_attr': False,
}
rpc_client.EngineClient.call(
dummy_req.context, ('describe_stack_resource', args), version='1.2'
@@ -1353,7 +1353,7 @@ class CfnStackControllerTest(common.HeatTestCase):
args = {
'stack_identity': identity,
'resource_name': dummy_req.params.get('LogicalResourceId'),
- 'with_attr': None,
+ 'with_attr': False,
}
rpc_client.EngineClient.call(
dummy_req.context, ('describe_stack_resource', args), version='1.2'
diff --git a/heat/tests/test_api_openstack_v1.py b/heat/tests/test_api_openstack_v1.py
index 6e12658a0..31a8686e0 100644
--- a/heat/tests/test_api_openstack_v1.py
+++ b/heat/tests/test_api_openstack_v1.py
@@ -2293,6 +2293,7 @@ class ResourceControllerTest(ControllerTest, common.HeatTestCase):
u'physical_resource_id':
u'a3455d8c-9f88-404d-a85b-5315293e67de',
u'resource_type': u'AWS::EC2::Instance',
+ u'attributes': {u'foo', 'bar'},
u'metadata': {u'ensureRunning': u'true'}
}
self.m.StubOutWithMock(rpc_client.EngineClient, 'call')
@@ -2325,6 +2326,7 @@ class ResourceControllerTest(ControllerTest, common.HeatTestCase):
u'physical_resource_id':
u'a3455d8c-9f88-404d-a85b-5315293e67de',
u'resource_type': u'AWS::EC2::Instance',
+ u'attributes': {u'foo', 'bar'},
}
}
@@ -2356,6 +2358,7 @@ class ResourceControllerTest(ControllerTest, common.HeatTestCase):
u'physical_resource_id':
u'a3455d8c-9f88-404d-a85b-5315293e67de',
u'resource_type': u'AWS::EC2::Instance',
+ u'attributes': {u'foo', 'bar'},
u'metadata': {u'ensureRunning': u'true'},
u'nested_stack_id': dict(nested_stack_identity)
}
@@ -2569,7 +2572,7 @@ class ResourceControllerTest(ControllerTest, common.HeatTestCase):
req.context,
('describe_stack_resource',
{'stack_identity': stack_identity, 'resource_name': res_name,
- 'with_attr': None}),
+ 'with_attr': False}),
version='1.2'
).AndReturn(engine_resp)
self.m.ReplayAll()
@@ -2600,7 +2603,7 @@ class ResourceControllerTest(ControllerTest, common.HeatTestCase):
req.context,
('describe_stack_resource',
{'stack_identity': stack_identity, 'resource_name': res_name,
- 'with_attr': None}),
+ 'with_attr': False}),
version='1.2'
).AndRaise(to_remote_error(error))
self.m.ReplayAll()
@@ -2632,7 +2635,7 @@ class ResourceControllerTest(ControllerTest, common.HeatTestCase):
req.context,
('describe_stack_resource',
{'stack_identity': stack_identity, 'resource_name': res_name,
- 'with_attr': None}),
+ 'with_attr': False}),
version='1.2'
).AndRaise(to_remote_error(error))
self.m.ReplayAll()
diff --git a/heat/tests/test_engine_api_utils.py b/heat/tests/test_engine_api_utils.py
index 06744b342..4b9a93ccd 100644
--- a/heat/tests/test_engine_api_utils.py
+++ b/heat/tests/test_engine_api_utils.py
@@ -96,6 +96,12 @@ class FormatTest(common.HeatTestCase):
formatted = api.format_stack_resource(res, False)
self.assertEqual(resource_keys, set(formatted.keys()))
+ def test_format_stack_resource_no_attrs(self):
+ res = self.stack['generic1']
+ formatted = api.format_stack_resource(res, True, with_attr=False)
+ self.assertNotIn(rpc_api.RES_SCHEMA_ATTRIBUTES, formatted)
+ self.assertIn(rpc_api.RES_METADATA, formatted)
+
@mock.patch.object(api, 'format_resource_properties')
def test_format_stack_resource_with_props(self, mock_format_props):
mock_format_props.return_value = 'formatted_res_props'