From fad3c7b87c736170b063e0536cc601329972201b Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Sun, 12 Aug 2018 13:41:22 +0300 Subject: [PATCH] New api for getting the LB virtual servers status Change-Id: I71a56b87144aad743795ad1295ec636b17429035 --- vmware_nsxlib/tests/unit/v3/test_load_balancer.py | 9 +++++++++ vmware_nsxlib/v3/load_balancer.py | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/vmware_nsxlib/tests/unit/v3/test_load_balancer.py b/vmware_nsxlib/tests/unit/v3/test_load_balancer.py index 906775f8..aac19e48 100644 --- a/vmware_nsxlib/tests/unit/v3/test_load_balancer.py +++ b/vmware_nsxlib/tests/unit/v3/test_load_balancer.py @@ -545,6 +545,15 @@ class TestService(nsxlib_testcase.NsxClientTestCase): get.assert_called_with( 'loadbalancer/services/%s/status' % fake_service['id']) + def test_get_virtual_servers_status(self): + with mock.patch.object(self.nsxlib.client, 'get') as get: + fake_service = consts.FAKE_SERVICE.copy() + self.nsxlib.load_balancer.service.get_virtual_servers_status( + fake_service['id']) + get.assert_called_with( + 'loadbalancer/services/%s/virtual-servers/status' % + fake_service['id']) + def test_delete_service(self): with mock.patch.object(self.nsxlib.client, 'delete') as delete: fake_service = consts.FAKE_SERVICE.copy() diff --git a/vmware_nsxlib/v3/load_balancer.py b/vmware_nsxlib/v3/load_balancer.py index 0fd77dfb..e4efb6e6 100644 --- a/vmware_nsxlib/v3/load_balancer.py +++ b/vmware_nsxlib/v3/load_balancer.py @@ -454,6 +454,11 @@ class Service(LoadBalancerBase): object_url = '%s/%s/%s' % (self.resource, service_id, 'status') return self.client.get(object_url) + def get_virtual_servers_status(self, service_id): + object_url = '%s/%s/%s/%s' % (self.resource, service_id, + 'virtual-servers', 'status') + return self.client.get(object_url) + def get_stats(self, service_id, source='realtime'): object_url = '%s/%s/%s?source=%s' % (self.resource, service_id, 'statistics', source)