From a2e1666190da7d82c520aef92ef0f44d7a294c5d Mon Sep 17 00:00:00 2001 From: Eugene Nikanorov Date: Tue, 6 Aug 2013 16:36:25 +0400 Subject: [PATCH] Cleanup remaining code that used 'status' fields of HealthMonitor Also cleanup some comments in abstract_driver fixes bug 1208822 Change-Id: Ibfee548a1e27cc25b8607fb24018e3b35148a955 --- neutron/services/loadbalancer/drivers/abstract_driver.py | 5 ----- neutron/services/loadbalancer/drivers/haproxy/cfg.py | 6 +++++- neutron/services/loadbalancer/plugin.py | 5 ----- .../unit/services/loadbalancer/drivers/haproxy/test_cfg.py | 7 ++----- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/neutron/services/loadbalancer/drivers/abstract_driver.py b/neutron/services/loadbalancer/drivers/abstract_driver.py index c20886e91..d05316852 100644 --- a/neutron/services/loadbalancer/drivers/abstract_driver.py +++ b/neutron/services/loadbalancer/drivers/abstract_driver.py @@ -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 diff --git a/neutron/services/loadbalancer/drivers/haproxy/cfg.py b/neutron/services/loadbalancer/drivers/haproxy/cfg.py index 18c40cff9..c25c608bc 100644 --- a/neutron/services/loadbalancer/drivers/haproxy/cfg.py +++ b/neutron/services/loadbalancer/drivers/haproxy/cfg.py @@ -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 '', [] diff --git a/neutron/services/loadbalancer/plugin.py b/neutron/services/loadbalancer/plugin.py index 2f6e2de84..01bb98ad3 100644 --- a/neutron/services/loadbalancer/plugin.py +++ b/neutron/services/loadbalancer/plugin.py @@ -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, diff --git a/neutron/tests/unit/services/loadbalancer/drivers/haproxy/test_cfg.py b/neutron/tests/unit/services/loadbalancer/drivers/haproxy/test_cfg.py index e21b428db..5e9d1b3b2 100644 --- a/neutron/tests/unit/services/loadbalancer/drivers/haproxy/test_cfg.py +++ b/neutron/tests/unit/services/loadbalancer/drivers/haproxy/test_cfg.py @@ -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 -- 2.45.2