Add API alias for '/statuses'
Fixes a neutron-lbaas LBaaS v2 API compatibility issue when requesting a load balancer status tree via '/statuses'. This patch adds an alias for '/statuses' to use the same code as '/status'. Change-Id: I7aebf87c5f48e2e72b1f7f26b95663a861382f36 Story: 2001812 Task: 12547
This commit is contained in:
parent
1f278e7ab3
commit
922c79f52f
@ -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
|
||||
|
@ -2436,10 +2436,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'])
|
||||
|
5
releasenotes/notes/statuses_alias-27559e3d74b9eaf0.yaml
Normal file
5
releasenotes/notes/statuses_alias-27559e3d74b9eaf0.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes a neutron-lbaas LBaaS v2 API compatibility issue when requesting a
|
||||
load balancer status tree via '/statuses'.
|
Loading…
Reference in New Issue
Block a user