Merge "Fix fetching LBaas pool stats failure"

This commit is contained in:
Jenkins
2015-08-04 15:15:06 +00:00
committed by Gerrit Code Review
2 changed files with 52 additions and 42 deletions

View File

@@ -822,7 +822,13 @@ class EdgeLbDriver(object):
lb_stats = self.vcns.get_loadbalancer_statistics(
pool_mapping['edge_id'])
pools_stats = lb_stats.get('pool', [])
except nsxv_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.error(
_LE('Failed to read load balancer statistics, edge: %s'),
pool_mapping['edge_id'])
pools_stats = lb_stats[1].get('pool', [])
for pool_stats in pools_stats:
if pool_stats['poolId'] == pool_mapping['edge_pool_id']:
return {'bytes_in': pool_stats.get('bytesIn', 0),
@@ -832,12 +838,6 @@ class EdgeLbDriver(object):
'total_connections':
pool_stats.get('totalSessions', 0)}
except nsxv_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.error(
_LE('Failed to read load balancer statistics, edge: %s'),
pool_mapping['edge_id'])
return {'bytes_in': 0,
'bytes_out': 0,
'active_connections': 0,

View File

@@ -596,7 +596,17 @@ class TestEdgeLbDriver(base.BaseTestCase):
def test_stats(self):
pool_mapping = {'edge_id': EDGE_ID, 'edge_pool_id': EDGE_POOL_ID}
pool_stats = {
pool_stats = (
{
'status': '200',
'content-location': '',
'transfer-encoding': 'chunked',
'expires': 'Thu, 01 Jan 1970 00:00:00 GMT',
'server': '',
'cache-control': 'private, no-cache',
'date': 'Thu, 30 Jul 2015 08:59:27 GMT',
'content-type': 'application/json'},
{
'timeStamp': 1427358733,
'virtualServer': [
{'name': 'MdSrv',
@@ -627,7 +637,7 @@ class TestEdgeLbDriver(base.BaseTestCase):
'maxSessions': 10000,
'httpReqRateMax': 0,
'curSessions': 5000,
'bytesIn': 1000000}]}
'bytesIn': 1000000}]})
expected_stats = {
'active_connections': 5000,
'bytes_in': 1000000,