urllib.unquote(path.group(2)),
urllib.unquote(path.group(3)))
+ def stack(self):
+ '''
+ Return a HeatIdentifier for the top-level stack
+ '''
+ return HeatIdentifier(self.tenant, self.stack_name, self.stack_id)
+
def arn(self):
'''
Return an ARN of the form:
def __repr__(self):
return repr(dict(self))
+
+
+class ResourceIdentifier(HeatIdentifier):
+ def __init__(self, stack_identifier, resource_id):
+ path = (stack_identifier.path.rstrip('/') +
+ '/resources/%s' % resource_id)
+ super(ResourceIdentifier, self).__init__(stack_identifier.tenant,
+ stack_identifier.stack_name,
+ stack_identifier.stack_id,
+ path)
from heat.common import exception
from heat.common import config
from heat.db import api as db_api
+from heat.engine import identifier
from heat.engine import timestamp
from heat.engine.resources.properties import Properties
return result
return not result
+ def identifier(self):
+ '''Return an identifier for this resource'''
+ return identifier.ResourceIdentifier(self.stack.identifier(),
+ self.name)
+
def parsed_template(self, section=None, default={}):
'''
Return the parsed template data for the resource. May be limited to
utils.generate_uuid()))
+@attr(tag=['unit', 'identifier'])
+@attr(speed='fast')
+class ResourceIdentifierTest(unittest.TestCase):
+ def test_resource_init_no_path(self):
+ si = identifier.HeatIdentifier('t', 's', 'i')
+ ri = identifier.ResourceIdentifier(si, 'r')
+ self.assertEqual(ri.path, '/resources/r')
+
+ def test_resource_init_path(self):
+ si = identifier.HeatIdentifier('t', 's', 'i')
+ pi = identifier.ResourceIdentifier(si, 'p')
+ ri = identifier.ResourceIdentifier(pi, 'r')
+ self.assertEqual(ri.path, '/resources/p/resources/r')
+
+
# allows testing of the test directly, shown below
if __name__ == '__main__':
sys.argv.append(__file__)