[placement] Allow both /placement and /placement/ to work
When mounted under a prefix (such as /placement) the service was only returning the home document at /placement/ not /placement. In the context of having a prefix, we'd generally like the latter to work and for '/' to work when there is no prefix. This allows both. Note that this doesn't make /placement/resource_providers/ work, and we don't want that. Change-Id: I0ac92bf9982227d5f4915175182e5230aeb039b4 Closes-Bug: #1626490
This commit is contained in:
parent
6383894a33
commit
f21e7e3329
nova
@ -48,6 +48,14 @@ ROUTE_DECLARATIONS = {
|
||||
'/': {
|
||||
'GET': root.home,
|
||||
},
|
||||
# NOTE(cdent): This allows '/placement/' and '/placement' to
|
||||
# both work as the root of the service, which we probably want
|
||||
# for those situations where the service is mounted under a
|
||||
# prefix (as it is in devstack). While weird, an empty string is
|
||||
# a legit key in a dictionary and matches as desired in Routes.
|
||||
'': {
|
||||
'GET': root.home,
|
||||
},
|
||||
'/resource_providers': {
|
||||
'GET': resource_provider.list_resource_providers,
|
||||
'POST': resource_provider.create_resource_provider
|
||||
|
@ -18,6 +18,7 @@ import routes
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.placement import handler
|
||||
from nova.api.openstack.placement.handlers import root
|
||||
from nova import test
|
||||
from nova.tests import uuidsentinel
|
||||
|
||||
@ -112,3 +113,20 @@ class PlacementLoggingTest(test.NoDBTestCase):
|
||||
app, environ, start_response)
|
||||
mocked_log.error.assert_not_called()
|
||||
mocked_log.exception.assert_not_called()
|
||||
|
||||
|
||||
class DeclarationsTest(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(DeclarationsTest, self).setUp()
|
||||
self.mapper = handler.make_map(handler.ROUTE_DECLARATIONS)
|
||||
|
||||
def test_root_slash_match(self):
|
||||
environ = _environ(path='/')
|
||||
result = self.mapper.match(environ=environ)
|
||||
self.assertEqual(root.home, result['action'])
|
||||
|
||||
def test_root_empty_match(self):
|
||||
environ = _environ(path='')
|
||||
result = self.mapper.match(environ=environ)
|
||||
self.assertEqual(root.home, result['action'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user