diff options
author | Zane Bitter <zbitter@redhat.com> | 2012-12-20 13:31:14 +0100 |
---|---|---|
committer | Zane Bitter <zbitter@redhat.com> | 2012-12-21 19:04:28 +0100 |
commit | 61be8e1ea40ccb2696fba1bf1524d3678bb40f3c (patch) | |
tree | 692564591b6200bc2b77b0df71587410806adfa8 | |
parent | b8f8167ff98bb2a4fabd84c5ae6f67b589600ec4 (diff) | |
download | heat-61be8e1ea40ccb2696fba1bf1524d3678bb40f3c.tar.gz |
RPC API: Simplify describe_stack_resources call
Remove the part with the physical_resource_id, which can now be done
through the find_physical_resource call.
Change-Id: Idff625014121aaa6ff3697b36fe38facaf54a499
Signed-off-by: Zane Bitter <zbitter@redhat.com>
-rw-r--r-- | heat/api/cfn/v1/stacks.py | 3 | ||||
-rw-r--r-- | heat/engine/service.py | 20 | ||||
-rw-r--r-- | heat/rpc/client.py | 8 | ||||
-rw-r--r-- | heat/tests/test_api_cfn_v1.py | 6 | ||||
-rw-r--r-- | heat/tests/test_engine_service.py | 27 | ||||
-rw-r--r-- | heat/tests/test_rpc_client.py | 3 |
6 files changed, 17 insertions, 50 deletions
diff --git a/heat/api/cfn/v1/stacks.py b/heat/api/cfn/v1/stacks.py index 5797805fc..fdb3a5e20 100644 --- a/heat/api/cfn/v1/stacks.py +++ b/heat/api/cfn/v1/stacks.py @@ -540,8 +540,7 @@ class StackController(object): resources = self.engine_rpcapi.describe_stack_resources( con, stack_identity=identity, - physical_resource_id=None, - logical_resource_id=req.params.get('LogicalResourceId')) + resource_name=req.params.get('LogicalResourceId')) except rpc_common.RemoteError as ex: return exception.map_remote_error(ex) diff --git a/heat/engine/service.py b/heat/engine/service.py index 44387daa8..8823af83e 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -394,25 +394,13 @@ class EngineService(service.Service): return dict(resource.identifier()) @request_context - def describe_stack_resources(self, context, stack_identity, - physical_resource_id, logical_resource_id): - if stack_identity is not None: - s = self._get_stack(context, stack_identity) - else: - rs = db_api.resource_get_by_physical_resource_id( - context, physical_resource_id) - if not rs: - msg = "The specified PhysicalResourceId doesn't exist" - raise AttributeError(msg) - s = rs.stack - - if not s: - raise AttributeError("The specified stack doesn't exist") + def describe_stack_resources(self, context, stack_identity, resource_name): + s = self._get_stack(context, stack_identity) stack = parser.Stack.load(context, stack=s) - if logical_resource_id is not None: - name_match = lambda r: r.name == logical_resource_id + if resource_name is not None: + name_match = lambda r: r.name == resource_name else: name_match = lambda r: True diff --git a/heat/rpc/client.py b/heat/rpc/client.py index 431abf2fd..ca2c4f484 100644 --- a/heat/rpc/client.py +++ b/heat/rpc/client.py @@ -205,12 +205,10 @@ class EngineClient(heat.openstack.common.rpc.proxy.RpcProxy): physical_resource_id=physical_resource_id), topic=_engine_topic(self.topic, ctxt, None)) - def describe_stack_resources(self, ctxt, stack_identity, - physical_resource_id, logical_resource_id): + def describe_stack_resources(self, ctxt, stack_identity, resource_name): return self.call(ctxt, self.make_msg('describe_stack_resources', - stack_identity=stack_identity, - physical_resource_id=physical_resource_id, - logical_resource_id=logical_resource_id), + stack_identity=stack_identity, + resource_name=resource_name), topic=_engine_topic(self.topic, ctxt, None)) def list_stack_resources(self, ctxt, stack_identity): diff --git a/heat/tests/test_api_cfn_v1.py b/heat/tests/test_api_cfn_v1.py index d09023767..4474f538f 100644 --- a/heat/tests/test_api_cfn_v1.py +++ b/heat/tests/test_api_cfn_v1.py @@ -983,8 +983,7 @@ class StackControllerTest(unittest.TestCase): 'version': self.api_version}, None).AndReturn(identity) args = { 'stack_identity': identity, - 'physical_resource_id': None, - 'logical_resource_id': dummy_req.params.get('LogicalResourceId'), + 'resource_name': dummy_req.params.get('LogicalResourceId'), } rpc.call(dummy_req.context, self.topic, {'method': 'describe_stack_resources', @@ -1072,8 +1071,7 @@ class StackControllerTest(unittest.TestCase): 'version': self.api_version}, None).AndReturn(identity) args = { 'stack_identity': identity, - 'physical_resource_id': None, - 'logical_resource_id': dummy_req.params.get('LogicalResourceId'), + 'resource_name': dummy_req.params.get('LogicalResourceId'), } rpc.call(dummy_req.context, self.topic, {'method': 'describe_stack_resources', diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py index 2853fabf5..17a35629c 100644 --- a/heat/tests/test_engine_service.py +++ b/heat/tests/test_engine_service.py @@ -579,7 +579,7 @@ class stackServiceTest(unittest.TestCase): def test_stack_resources_describe(self): resources = self.man.describe_stack_resources(self.ctx, self.stack_identity, - None, 'WebServer') + 'WebServer') self.assertEqual(len(resources), 1) r = resources[0] @@ -600,7 +600,7 @@ class stackServiceTest(unittest.TestCase): def test_stack_resources_describe_no_filter(self): resources = self.man.describe_stack_resources(self.ctx, self.stack_identity, - None, None) + None) self.assertEqual(len(resources), 1) r = resources[0] @@ -608,36 +608,21 @@ class stackServiceTest(unittest.TestCase): self.assertEqual(r['logical_resource_id'], 'WebServer') def test_stack_resources_describe_bad_lookup(self): - self.assertRaises(AttributeError, + self.assertRaises(TypeError, self.man.describe_stack_resources, - self.ctx, None, None, 'WebServer') + self.ctx, None, 'WebServer') def test_stack_resources_describe_nonexist_stack(self): nonexist = dict(self.stack_identity) nonexist['stack_name'] = 'foo' self.assertRaises(AttributeError, self.man.describe_stack_resources, - self.ctx, nonexist, None, 'WebServer') - - def test_stack_resources_describe_physid(self): - resources = self.man.describe_stack_resources(self.ctx, - self.stack_identity, - None, None) - phys_id = resources[0]['physical_resource_id'] - - result = self.man.describe_stack_resources(self.ctx, - None, phys_id, None) - self.assertEqual(result, resources) - - def test_stack_resources_describe_nonexist_physid(self): - self.assertRaises(AttributeError, - self.man.describe_stack_resources, - self.ctx, None, 'foo', 'WebServer') + self.ctx, nonexist, 'WebServer') def test_find_physical_resource(self): resources = self.man.describe_stack_resources(self.ctx, self.stack_identity, - None, None) + None) phys_id = resources[0]['physical_resource_id'] result = self.man.find_physical_resource(self.ctx, phys_id) diff --git a/heat/tests/test_rpc_client.py b/heat/tests/test_rpc_client.py index 19f646882..3f74b8c78 100644 --- a/heat/tests/test_rpc_client.py +++ b/heat/tests/test_rpc_client.py @@ -136,8 +136,7 @@ class EngineRpcAPITestCase(unittest.TestCase): def test_describe_stack_resources(self): self._test_engine_api('describe_stack_resources', 'call', stack_identity=self.identity, - physical_resource_id=u'404d-a85b-5315293e67de', - logical_resource_id=u'WikiDatabase') + resource_name=u'WikiDatabase') def test_list_stack_resources(self): self._test_engine_api('list_stack_resources', 'call', |