Check lbaas version if call is v2 specific
lbaas/loadbalancers and lbaas/listeners are not supported in v1 lbaas extension [1] 1. http://developer.openstack.org/api-ref-networking-v2-ext.html#lbaas-v1.0 Change-Id: I09dd0b5d98794ee773e010382f59fedb04123ff7 Closes-Bug: #1599482
This commit is contained in:
parent
432f411603
commit
46e0d65f54
@ -392,19 +392,25 @@ class Client(object):
|
||||
@logged
|
||||
def list_listener(self):
|
||||
"""This method is used to get the list of the listeners."""
|
||||
resp = self.client.list_listeners()
|
||||
resources = resp.get('listeners')
|
||||
for listener in resources:
|
||||
loadbalancer_id = listener.get('loadbalancers')[0].get('id')
|
||||
status = self._get_listener_status(loadbalancer_id)
|
||||
listener['operating_status'] = status[listener.get('id')]
|
||||
resources = []
|
||||
if self.lb_version == 'v2':
|
||||
# list_listeners works only with lbaas v2 extension
|
||||
resp = self.client.list_listeners()
|
||||
resources = resp.get('listeners')
|
||||
for listener in resources:
|
||||
loadbalancer_id = listener.get('loadbalancers')[0].get('id')
|
||||
status = self._get_listener_status(loadbalancer_id)
|
||||
listener['operating_status'] = status[listener.get('id')]
|
||||
return resources
|
||||
|
||||
@logged
|
||||
def list_loadbalancer(self):
|
||||
"""This method is used to get the list of the loadbalancers."""
|
||||
resp = self.client.list_loadbalancers()
|
||||
resources = resp.get('loadbalancers')
|
||||
resources = []
|
||||
if self.lb_version == 'v2':
|
||||
# list_loadbalancers works only with lbaas v2 extension
|
||||
resp = self.client.list_loadbalancers()
|
||||
resources = resp.get('loadbalancers')
|
||||
return resources
|
||||
|
||||
@logged
|
||||
|
@ -184,3 +184,9 @@ class TestNeutronClient(base.BaseTestCase):
|
||||
self.assertEqual(2, stats[0]['total_connections'])
|
||||
self.assertEqual(3, stats[0]['bytes_in'])
|
||||
self.assertEqual(4, stats[0]['bytes_out'])
|
||||
|
||||
def test_v1_list_loadbalancer_returns_empty_list(self):
|
||||
self.assertEqual([], self.nc.list_loadbalancer())
|
||||
|
||||
def test_v1_list_listener_returns_empty_list(self):
|
||||
self.assertEqual([], self.nc.list_listener())
|
||||
|
Loading…
Reference in New Issue
Block a user