From: Steve Baker Date: Tue, 5 Mar 2013 01:00:22 +0000 (+1300) Subject: Use stack.resource_by_refid to get the user resource. X-Git-Tag: 2014.1~786^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=545b54f9bee189846f7e7b3c0f367cfa91b2ce03;p=openstack-build%2Fheat-build.git Use stack.resource_by_refid to get the user resource. Related to Bug #1131534 Change-Id: If8c9f0982f4a29c597c5ad3805637270e1a97f23 --- diff --git a/heat/engine/resources/user.py b/heat/engine/resources/user.py index 42910592..5e7bd563 100644 --- a/heat/engine/resources/user.py +++ b/heat/engine/resources/user.py @@ -138,13 +138,7 @@ class AccessKey(resource.Resource): # into the UserName parameter. Would be cleaner to just make the User # resource return resource_id for FnGetRefId but the AWS definition of # user does say it returns a user name not ID - for r in self.stack: - # this is to reduce the number of checks without having to - # look for the class name. - if callable(getattr(r, 'access_allowed', None)): - refid = r.FnGetRefId() - if refid == self.properties['UserName']: - return r + return self.stack.resource_by_refid(self.properties['UserName']) def handle_create(self): try: diff --git a/heat/tests/test_user.py b/heat/tests/test_user.py index 8fc6fa33..14e41232 100644 --- a/heat/tests/test_user.py +++ b/heat/tests/test_user.py @@ -279,6 +279,7 @@ class AccessKeyTest(unittest.TestCase): 'test_stack.CfnUser' stack = self.parse_stack(t) stack.resources['CfnUser'].resource_id = self.fc.user_id + stack.resources['CfnUser'].state = 'CREATE_COMPLETE' resource = self.create_access_key(t, stack, 'HostKeys')