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:
parent
f27fba3ad7
commit
a2e1666190
@ -106,11 +106,6 @@ class LoadBalancerAbstractDriver(object):
|
|||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def create_health_monitor(self, context, health_monitor):
|
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
|
pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
|
@ -158,7 +158,11 @@ def _get_first_ip_from_port(port):
|
|||||||
def _get_server_health_option(config):
|
def _get_server_health_option(config):
|
||||||
"""return the first active health option."""
|
"""return the first active health option."""
|
||||||
for monitor in config['healthmonitors']:
|
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
|
break
|
||||||
else:
|
else:
|
||||||
return '', []
|
return '', []
|
||||||
|
@ -151,7 +151,6 @@ class LoadBalancerPlugin(loadbalancer_db.LoadBalancerPluginDb,
|
|||||||
self.driver.delete_member(context, m)
|
self.driver.delete_member(context, m)
|
||||||
|
|
||||||
def create_health_monitor(self, context, health_monitor):
|
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(
|
hm = super(LoadBalancerPlugin, self).create_health_monitor(
|
||||||
context,
|
context,
|
||||||
health_monitor
|
health_monitor
|
||||||
@ -160,10 +159,6 @@ class LoadBalancerPlugin(loadbalancer_db.LoadBalancerPluginDb,
|
|||||||
return hm
|
return hm
|
||||||
|
|
||||||
def update_health_monitor(self, context, id, health_monitor):
|
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)
|
old_hm = self.get_health_monitor(context, id)
|
||||||
hm = super(LoadBalancerPlugin, self).update_health_monitor(
|
hm = super(LoadBalancerPlugin, self).update_health_monitor(
|
||||||
context,
|
context,
|
||||||
|
@ -111,8 +111,7 @@ class TestHaproxyCfg(base.BaseTestCase):
|
|||||||
'address': '10.0.0.3',
|
'address': '10.0.0.3',
|
||||||
'protocol_port': 80,
|
'protocol_port': 80,
|
||||||
'weight': 1}],
|
'weight': 1}],
|
||||||
'healthmonitors': [{'status': 'ACTIVE',
|
'healthmonitors': [{'admin_state_up': True,
|
||||||
'admin_state_up': True,
|
|
||||||
'delay': 3,
|
'delay': 3,
|
||||||
'max_retries': 4,
|
'max_retries': 4,
|
||||||
'timeout': 2,
|
'timeout': 2,
|
||||||
@ -130,8 +129,7 @@ class TestHaproxyCfg(base.BaseTestCase):
|
|||||||
self.assertEqual(expected_opts, list(opts))
|
self.assertEqual(expected_opts, list(opts))
|
||||||
|
|
||||||
def test_get_server_health_option(self):
|
def test_get_server_health_option(self):
|
||||||
test_config = {'healthmonitors': [{'status': 'ERROR',
|
test_config = {'healthmonitors': [{'admin_state_up': False,
|
||||||
'admin_state_up': False,
|
|
||||||
'delay': 3,
|
'delay': 3,
|
||||||
'max_retries': 4,
|
'max_retries': 4,
|
||||||
'timeout': 2,
|
'timeout': 2,
|
||||||
@ -141,7 +139,6 @@ class TestHaproxyCfg(base.BaseTestCase):
|
|||||||
'expected_codes': '200'}]}
|
'expected_codes': '200'}]}
|
||||||
self.assertEqual(('', []), cfg._get_server_health_option(test_config))
|
self.assertEqual(('', []), cfg._get_server_health_option(test_config))
|
||||||
|
|
||||||
test_config['healthmonitors'][0]['status'] = 'ACTIVE'
|
|
||||||
self.assertEqual(('', []), cfg._get_server_health_option(test_config))
|
self.assertEqual(('', []), cfg._get_server_health_option(test_config))
|
||||||
|
|
||||||
test_config['healthmonitors'][0]['admin_state_up'] = True
|
test_config['healthmonitors'][0]['admin_state_up'] = True
|
||||||
|
Loading…
Reference in New Issue
Block a user