LBaaS: update DB pool stats received from lbaas agent

Fixes bug 1201401

Change-Id: I84e2fbdb3e6368529c1d829d4e8134e6b0b54311
This commit is contained in:
Oleg Bondarev 2013-07-16 13:02:02 +04:00
parent b99b020b29
commit dab95c4861
3 changed files with 5 additions and 6 deletions

View File

@ -459,7 +459,7 @@ class LoadBalancerPluginDb(LoadBalancerPluginBase,
return self._fields(res, fields) return self._fields(res, fields)
def _update_pool_stats(self, context, pool_id, data=None): def update_pool_stats(self, context, pool_id, data=None):
"""Update a pool with new stats structure.""" """Update a pool with new stats structure."""
with context.session.begin(subtransactions=True): with context.session.begin(subtransactions=True):
pool_db = self._get_resource(context, Pool, pool_id) pool_db = self._get_resource(context, Pool, pool_id)

View File

@ -179,8 +179,7 @@ class LoadBalancerCallbacks(object):
LOG.debug(msg, port_id) LOG.debug(msg, port_id)
def update_pool_stats(self, context, pool_id=None, stats=None, host=None): def update_pool_stats(self, context, pool_id=None, stats=None, host=None):
# TODO(markmcclain): add stats collection self.plugin.update_pool_stats(context, pool_id, data=stats)
pass
class LoadBalancerAgentApi(proxy.RpcProxy): class LoadBalancerAgentApi(proxy.RpcProxy):

View File

@ -931,7 +931,7 @@ class TestLoadBalancer(LoadBalancerPluginDbTestCase):
with self.pool() as pool: with self.pool() as pool:
pool_id = pool['pool']['id'] pool_id = pool['pool']['id']
ctx = context.get_admin_context() ctx = context.get_admin_context()
self.plugin._update_pool_stats(ctx, pool_id) self.plugin.update_pool_stats(ctx, pool_id)
pool_obj = ctx.session.query(ldb.Pool).filter_by(id=pool_id).one() pool_obj = ctx.session.query(ldb.Pool).filter_by(id=pool_id).one()
for key in keys: for key in keys:
self.assertEqual(pool_obj.stats.__dict__[key], 0) self.assertEqual(pool_obj.stats.__dict__[key], 0)
@ -948,7 +948,7 @@ class TestLoadBalancer(LoadBalancerPluginDbTestCase):
with self.pool() as pool: with self.pool() as pool:
pool_id = pool['pool']['id'] pool_id = pool['pool']['id']
ctx = context.get_admin_context() ctx = context.get_admin_context()
self.assertRaises(ValueError, self.plugin._update_pool_stats, self.assertRaises(ValueError, self.plugin.update_pool_stats,
ctx, pool_id, {k: v}) ctx, pool_id, {k: v})
def test_update_pool_stats(self): def test_update_pool_stats(self):
@ -959,7 +959,7 @@ class TestLoadBalancer(LoadBalancerPluginDbTestCase):
with self.pool() as pool: with self.pool() as pool:
pool_id = pool['pool']['id'] pool_id = pool['pool']['id']
ctx = context.get_admin_context() ctx = context.get_admin_context()
self.plugin._update_pool_stats(ctx, pool_id, stats_data) self.plugin.update_pool_stats(ctx, pool_id, stats_data)
pool_obj = ctx.session.query(ldb.Pool).filter_by(id=pool_id).one() pool_obj = ctx.session.query(ldb.Pool).filter_by(id=pool_id).one()
for k, v in stats_data.items(): for k, v in stats_data.items():
self.assertEqual(pool_obj.stats.__dict__[k], v) self.assertEqual(pool_obj.stats.__dict__[k], v)