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)
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
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):
'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',
'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',
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]
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]
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)
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',