Fix haproxy plugin_driver.update_health_monitor() signature

- add old_health_monitor parameter to the method
- the method signature in abstract lbaas driver was also changed
  to accept pool_id rather than an assoc object as driver only needs pool_id

Fixes bug 1190577

Change-Id: Ie199f46e089a16214ed649a3169e985a726e5d99
This commit is contained in:
Oleg Bondarev 2013-06-13 16:28:38 +04:00 committed by Gerrit Code Review
parent cc260d5d64
commit a1b8a10c56
4 changed files with 44 additions and 4 deletions

View File

@ -117,7 +117,7 @@ class LoadBalancerAbstractDriver(object):
def update_health_monitor(self, context, def update_health_monitor(self, context,
old_health_monitor, old_health_monitor,
health_monitor, health_monitor,
pool_association): pool_id):
pass pass
@abc.abstractmethod @abc.abstractmethod

View File

@ -271,8 +271,9 @@ class HaproxyOnHostPluginDriver(abstract_driver.LoadBalancerAbstractDriver):
self.plugin._delete_db_member(context, member['id']) self.plugin._delete_db_member(context, member['id'])
self.agent_rpc.modify_pool(context, member['pool_id']) self.agent_rpc.modify_pool(context, member['pool_id'])
def update_health_monitor(self, context, healthmon, pool_id): def update_health_monitor(self, context, old_health_monitor,
# healthmon is unused here because agent will fetch what is necessary health_monitor, pool_id):
# monitors are unused here because agent will fetch what is necessary
self.agent_rpc.modify_pool(context, pool_id) self.agent_rpc.modify_pool(context, pool_id)
def delete_health_monitor(self, context, healthmon_id, pool_id): def delete_health_monitor(self, context, healthmon_id, pool_id):

View File

@ -166,7 +166,8 @@ class LoadBalancerPlugin(loadbalancer_db.LoadBalancerPluginDb):
loadbalancer_db.PoolMonitorAssociation loadbalancer_db.PoolMonitorAssociation
).filter_by(monitor_id=hm['id']) ).filter_by(monitor_id=hm['id'])
for assoc in qry: for assoc in qry:
self.driver.update_health_monitor(context, old_hm, hm, assoc) self.driver.update_health_monitor(context, old_hm,
hm, assoc['pool_id'])
return hm return hm
def _delete_db_pool_health_monitor(self, context, hm_id, pool_id): def _delete_db_pool_health_monitor(self, context, hm_id, pool_id):

View File

@ -321,3 +321,41 @@ class TestLoadBalancerPluginNotificationWrapper(TestLoadBalancerPluginBase):
mock.ANY, mock.ANY,
vip['vip']['pool_id'] vip['vip']['pool_id']
) )
def test_update_health_monitor_associated_with_pool(self):
with self.health_monitor(type='HTTP') as monitor:
with self.pool() as pool:
data = {
'health_monitor': {
'id': monitor['health_monitor']['id'],
'tenant_id': self._tenant_id
}
}
req = self.new_create_request(
'pools',
data,
fmt=self.fmt,
id=pool['pool']['id'],
subresource='health_monitors')
res = req.get_response(self.ext_api)
self.assertEqual(res.status_int, 201)
self.mock_api.modify_pool.assert_called_once_with(
mock.ANY,
pool['pool']['id']
)
self.mock_api.reset_mock()
data = {'health_monitor': {'delay': 20,
'timeout': 20,
'max_retries': 2,
'admin_state_up': False}}
req = self.new_update_request("health_monitors",
data,
monitor['health_monitor']['id'])
req.get_response(self.ext_api)
self.mock_api.modify_pool.assert_called_once_with(
mock.ANY,
pool['pool']['id']
)
# TODO(obondarev): improve plugin_driver test coverage (bug 1191007)