Merge "Add API alias for '/statuses'" into stable/queens

This commit is contained in:
Zuul 2018-07-05 16:00:42 +00:00 committed by Gerrit Code Review
commit 3759336db7
3 changed files with 27 additions and 3 deletions

View File

@ -483,15 +483,19 @@ class LoadBalancersController(base.BaseController):
def _lookup(self, id, *remainder):
"""Overridden pecan _lookup method for custom routing.
Currently it checks if this was a statuses request and routes
the request to the StatusesController.
Currently it checks if this was a status request and routes
the request to the StatusController.
'statuses' is aliased here for backward compatibility with
neutron-lbaas LBaaS v2 API.
"""
if id and len(remainder) and (remainder[0] == 'status' or
remainder[0] == 'statuses' or
remainder[0] == 'stats' or
remainder[0] == 'failover'):
controller = remainder[0]
remainder = remainder[1:]
if controller == 'status':
if controller == 'status' or controller == 'statuses':
return StatusController(lb_id=id), remainder
elif controller == 'stats':
return StatisticsController(lb_id=id), remainder

View File

@ -2432,10 +2432,25 @@ class TestLoadBalancerGraph(base.BaseAPITest):
res = self.get(self.LB_PATH.format(lb_id=lb_id + "/status"))
return res.json.get('statuses').get('loadbalancer')
# Test the "statuses" alias for "status".
# This is required for backward compatibility with neutron-lbaas
def test_statuses(self):
lb = self.create_load_balancer(
uuidutils.generate_uuid()).get('loadbalancer')
statuses = self.get(self.LB_PATH.format(lb_id=lb['id'] + "/statuses"))
response = statuses.json.get('statuses').get('loadbalancer')
self.assertEqual(lb['name'], response['name'])
self.assertEqual(lb['id'], response['id'])
self.assertEqual(lb['operating_status'],
response['operating_status'])
self.assertEqual(lb['provisioning_status'],
response['provisioning_status'])
def test_status(self):
lb = self.create_load_balancer(
uuidutils.generate_uuid()).get('loadbalancer')
response = self._getStatus(lb['id'])
self.assertEqual(lb['name'], response['name'])
self.assertEqual(lb['id'], response['id'])

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixes a neutron-lbaas LBaaS v2 API compatibility issue when requesting a
load balancer status tree via '/statuses'.