diff options
author | Laszlo Hegedus <laszlo.hegedus@ericsson.com> | 2016-07-07 15:00:28 +0200 |
---|---|---|
committer | Jens Rosenboom <j.rosenboom@x-ion.de> | 2016-07-21 14:45:18 +0000 |
commit | 1b78aab869ab04c394aed5368ee457e02e6bcd8b (patch) | |
tree | 63338ee0a8a29fdff66797e241410bfd2f4fba37 | |
parent | fd9ee40216b445115f3d828df81c4163ad80cc75 (diff) | |
download | ceilometer-1b78aab869ab04c394aed5368ee457e02e6bcd8b.tar.gz |
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
(cherry picked from commit 46e0d65f545dc0f463b7eb47c7203120b7965ff0)
-rw-r--r-- | ceilometer/neutron_client.py | 22 | ||||
-rw-r--r-- | ceilometer/tests/unit/test_neutronclient.py | 6 |
2 files changed, 20 insertions, 8 deletions
diff --git a/ceilometer/neutron_client.py b/ceilometer/neutron_client.py index b5778e50..ffac7926 100644 --- a/ceilometer/neutron_client.py +++ b/ceilometer/neutron_client.py @@ -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 diff --git a/ceilometer/tests/unit/test_neutronclient.py b/ceilometer/tests/unit/test_neutronclient.py index 4bf61fc3..788ca479 100644 --- a/ceilometer/tests/unit/test_neutronclient.py +++ b/ceilometer/tests/unit/test_neutronclient.py @@ -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()) |