From 14c7fbb8ecba5abf1e69583f469a4cbc10861ad3 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Tue, 16 Oct 2018 11:46:26 +0300 Subject: [PATCH] NSX|V3: Add LB status calls validations When getting the LB objects status and statistics from the NSX, verify the structure ans content of the response, as sometimes it does not contain all the data. Change-Id: I4756daf688ebc29e5c71019ce28ae2df771e0b4c --- .../lbaas/nsx_v3/implementation/loadbalancer_mgr.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vmware_nsx/services/lbaas/nsx_v3/implementation/loadbalancer_mgr.py b/vmware_nsx/services/lbaas/nsx_v3/implementation/loadbalancer_mgr.py index 0b6a5928f6..4a47e5fd90 100644 --- a/vmware_nsx/services/lbaas/nsx_v3/implementation/loadbalancer_mgr.py +++ b/vmware_nsx/services/lbaas/nsx_v3/implementation/loadbalancer_mgr.py @@ -173,8 +173,13 @@ class EdgeLoadBalancerManagerFromDict(base_mgr.Nsxv3LoadbalancerBaseManager): lb_service_id = lb_binding['lb_service_id'] try: service_status = service_client.get_status(lb_service_id) + if not isinstance(service_status, dict): + service_status = {} + vs_statuses = service_client.get_virtual_servers_status( lb_service_id) + if not isinstance(vs_statuses, dict): + vs_statuses = {} except nsxlib_exc.ManagerError: LOG.warning("LB service %(lbs)s is not found", {'lbs': lb_service_id}) @@ -239,7 +244,7 @@ class EdgeLoadBalancerManagerFromDict(base_mgr.Nsxv3LoadbalancerBaseManager): # to this loadbalancer if vs['virtual_server_id'] not in vs_list: continue - vs_stats = vs['statistics'] + vs_stats = vs.get('statistics', {}) for stat in lb_const.LB_STATS_MAP: lb_stat = lb_const.LB_STATS_MAP[stat] stats[stat] += vs_stats[lb_stat]