Recognise arn: for REST stack lookup.

Note that the Routes mapper does brittle regexp fu to map parameters,
hence using \x3A for matching a colon

Fixes: Bug #1131759
Change-Id: I063bf9057782c1c0a3f809d4f8068e2594be264d
This commit is contained in:
Steve Baker 2013-03-08 13:08:04 +13:00
parent e64c536c41
commit 8939c3e524
2 changed files with 19 additions and 0 deletions

View File

@ -66,6 +66,11 @@ class API(wsgi.Router):
stack_mapper.connect("stack_lookup",
"/stacks/{stack_name}",
action="lookup")
# \x3A matches on a colon.
# Routes treats : specially in its regexp
stack_mapper.connect("stack_lookup",
r"/stacks/{stack_name:arn\x3A.*}",
action="lookup")
subpaths = ['resources', 'events']
path = "{path:%s}" % '|'.join(subpaths)
stack_mapper.connect("stack_lookup_subpath",

View File

@ -1678,6 +1678,20 @@ class RoutesTest(unittest.TestCase):
'tenant_id': 'aaaa',
'stack_name': 'teststack'
})
self.assertRoute(
self.m,
'/aaaa/stacks/arn:openstack:heat::6548ab64fbda49deb188851a3b7d8c8b'
':stacks/stack-1411-06/1c5d9bb2-3464-45e2-a728-26dfa4e1d34a',
'GET',
'lookup',
'StackController',
{
'tenant_id': 'aaaa',
'stack_name': 'arn:openstack:heat:'
':6548ab64fbda49deb188851a3b7d8c8b:stacks/stack-1411-06/'
'1c5d9bb2-3464-45e2-a728-26dfa4e1d34a'
})
self.assertRoute(
self.m,
'/aaaa/stacks/teststack/resources',