from webob import exc
from heat.api.openstack.v1 import util
+from heat.common import identifier
from heat.common import wsgi
from heat.common import template_format
from heat.rpc import api as engine_api
"""
Redirect to the canonical URL for a stack
"""
-
try:
- identity = self.engine.identify_stack(req.context,
- stack_name)
- except rpc_common.RemoteError as ex:
- return util.remote_error(ex)
+ identity = dict(identifier.HeatIdentifier.from_arn(stack_name))
+ except ValueError:
+ try:
+ identity = self.engine.identify_stack(req.context,
+ stack_name)
+ except rpc_common.RemoteError as ex:
+ return util.remote_error(ex)
location = util.make_url(req, identity)
if path:
self.fail('No redirect generated')
self.m.VerifyAll()
+ def test_lookup_arn(self):
+ identity = identifier.HeatIdentifier(self.tenant, 'wordpress', '1')
+
+ req = self._get('/stacks%s' % identity.arn_url_path())
+
+ self.m.ReplayAll()
+
+ try:
+ result = self.controller.lookup(req, tenant_id=identity.tenant,
+ stack_name=identity.arn())
+ except webob.exc.HTTPFound as found:
+ self.assertEqual(found.location, self._url(identity))
+ else:
+ self.fail('No redirect generated')
+ self.m.VerifyAll()
+
def test_lookup_nonexistant(self):
stack_name = 'wibble'