NSXP: parse statistics correctly

Change-Id: Iab48111a4309766dd97340338ff261a57347ade4
This commit is contained in:
Kobi Samoray 2019-05-13 17:39:48 +03:00
parent 864cf95bf2
commit a18d04ca55
1 changed files with 20 additions and 15 deletions

View File

@ -253,10 +253,15 @@ def stats_getter(context, core_plugin, ignore_list=None):
lb_service_id = lb_service.get('id')
try:
# get the NSX statistics for this LB service
rsp = lb_service_client.get_statistics(lb_service_id)
if rsp and 'virtual_servers' in rsp:
stats_results = lb_service_client.get_statistics(
lb_service_id).get('results', [])
if stats_results:
rsp = stats_results[0]
else:
rsp = {}
# Go over each virtual server in the response
for vs in rsp['virtual_servers']:
for vs in rsp.get('virtual_servers', []):
# look up the virtual server in the DB
if vs.get('statistics'):
vs_stats = vs['statistics']