Cleanup remaining code that used 'status' fields of HealthMonitor

Also cleanup some comments in abstract_driver

fixes bug 1208822

Change-Id: Ibfee548a1e27cc25b8607fb24018e3b35148a955
This commit is contained in:
Eugene Nikanorov 2013-08-06 16:36:25 +04:00
parent f27fba3ad7
commit a2e1666190
4 changed files with 7 additions and 16 deletions

View File

@ -106,11 +106,6 @@ class LoadBalancerAbstractDriver(object):
@abc.abstractmethod
def create_health_monitor(self, context, health_monitor):
"""Driver may call the code below in order to update the status.
self.plugin.update_status(context, HealthMonitor,
health_monitor["id"],
constants.ACTIVE)
"""
pass
@abc.abstractmethod

View File

@ -158,7 +158,11 @@ def _get_first_ip_from_port(port):
def _get_server_health_option(config):
"""return the first active health option."""
for monitor in config['healthmonitors']:
if monitor['status'] == ACTIVE and monitor['admin_state_up']:
# not checking the status of healthmonitor for two reasons:
# 1) status field is absent in HealthMonitor model
# 2) only active HealthMonitors are fetched with
# LoadBalancerCallbacks.get_logical_device
if monitor['admin_state_up']:
break
else:
return '', []

View File

@ -151,7 +151,6 @@ class LoadBalancerPlugin(loadbalancer_db.LoadBalancerPluginDb,
self.driver.delete_member(context, m)
def create_health_monitor(self, context, health_monitor):
# no PENDING_CREATE status sinse healthmon is shared DB object
hm = super(LoadBalancerPlugin, self).create_health_monitor(
context,
health_monitor
@ -160,10 +159,6 @@ class LoadBalancerPlugin(loadbalancer_db.LoadBalancerPluginDb,
return hm
def update_health_monitor(self, context, id, health_monitor):
if 'status' not in health_monitor['health_monitor']:
health_monitor['health_monitor']['status'] = (
constants.PENDING_UPDATE
)
old_hm = self.get_health_monitor(context, id)
hm = super(LoadBalancerPlugin, self).update_health_monitor(
context,

View File

@ -111,8 +111,7 @@ class TestHaproxyCfg(base.BaseTestCase):
'address': '10.0.0.3',
'protocol_port': 80,
'weight': 1}],
'healthmonitors': [{'status': 'ACTIVE',
'admin_state_up': True,
'healthmonitors': [{'admin_state_up': True,
'delay': 3,
'max_retries': 4,
'timeout': 2,
@ -130,8 +129,7 @@ class TestHaproxyCfg(base.BaseTestCase):
self.assertEqual(expected_opts, list(opts))
def test_get_server_health_option(self):
test_config = {'healthmonitors': [{'status': 'ERROR',
'admin_state_up': False,
test_config = {'healthmonitors': [{'admin_state_up': False,
'delay': 3,
'max_retries': 4,
'timeout': 2,
@ -141,7 +139,6 @@ class TestHaproxyCfg(base.BaseTestCase):
'expected_codes': '200'}]}
self.assertEqual(('', []), cfg._get_server_health_option(test_config))
test_config['healthmonitors'][0]['status'] = 'ACTIVE'
self.assertEqual(('', []), cfg._get_server_health_option(test_config))
test_config['healthmonitors'][0]['admin_state_up'] = True