diff --git a/acos_client/tests/unit/v30/test_slb_server.py b/acos_client/tests/unit/v30/test_slb_server.py index efc5df02..98778a37 100644 --- a/acos_client/tests/unit/v30/test_slb_server.py +++ b/acos_client/tests/unit/v30/test_slb_server.py @@ -49,7 +49,7 @@ def test_server_create(self): 'action': 'enable', 'conn-limit': None, 'conn-resume': None, - 'health-check': None, + 'health-check-disable': 0, 'host': '192.168.2.254', 'name': VSERVER_NAME, } @@ -75,7 +75,7 @@ def test_server_create_with_template(self): 'conn-resume': None, 'host': '192.168.2.254', 'name': VSERVER_NAME, - 'health-check': None, + 'health-check-disable': 0, 'template-server': 'test-template-server' } } @@ -102,7 +102,7 @@ def test_server_update_with_template(self): 'conn-resume': None, 'host': '192.168.2.254', 'name': VSERVER_NAME, - 'health-check': None, + 'health-check-disable': 0, 'template-server': 'test-template-server' } } @@ -129,7 +129,7 @@ def test_server_replace_with_template(self): 'conn-resume': None, 'host': '192.168.2.254', 'name': VSERVER_NAME, - 'health-check': None, + 'health-check-disable': 0, 'template-server': 'test-template-server' } } @@ -221,7 +221,7 @@ def test_server_create(self): 'action': 'enable', 'conn-limit': None, 'conn-resume': None, - 'health-check': None, + 'health-check-disable': 0, 'server-ipv6-addr': '2001:baad:deed:bead:daab:daad:cead:100e', 'name': VSERVER_NAME, } @@ -247,7 +247,7 @@ def test_server_create_with_template(self): 'conn-resume': None, 'host': '192.168.2.254', 'name': VSERVER_NAME, - 'health-check': None, + 'health-check-disable': 0, 'template-server': 'test-template-server' } } @@ -274,7 +274,7 @@ def test_server_update_with_template(self): 'conn-resume': None, 'host': '192.168.2.254', 'name': VSERVER_NAME, - 'health-check': None, + 'health-check-disable': 0, 'template-server': 'test-template-server' } } @@ -301,7 +301,7 @@ def test_server_replace_with_template(self): 'conn-resume': None, 'host': '192.168.2.254', 'name': VSERVER_NAME, - 'health-check': None, + 'health-check-disable': 0, 'template-server': 'test-template-server' } } diff --git a/acos_client/v30/slb/server.py b/acos_client/v30/slb/server.py index ec4c0e01..c01fa956 100644 --- a/acos_client/v30/slb/server.py +++ b/acos_client/v30/slb/server.py @@ -26,17 +26,28 @@ class Server(base.BaseV30): def get(self, name, **kwargs): return self._get(self.url_prefix + name, **kwargs) - def _set(self, name, ip_address, status=1, server_templates=None, port_list=None, **kwargs): + def _set(self, name, ip_address, status=1, server_templates=None, port_list=None, hm_name=None, **kwargs): + params = { "server": { "name": name, "action": 'enable' if status else 'disable', "conn-resume": kwargs.get("conn_resume"), - "conn-limit": kwargs.get("conn_limit"), - "health-check": kwargs.get("health_check"), + "conn-limit": kwargs.get("conn_limit") } } + # If we explicitly disable health checks, ensure it happens + # Else, we implicitly disable health checks if not specified. + health_check_disable = 1 if kwargs.get("health_check_disable", False) else 0 + + # When enabling/disabling a health monitor, you can't specify + # health-check-disable and health-check at the same time. + if hm_name is None: + params["server"]["health-check-disable"] = health_check_disable + else: + params["server"]["health-check"] = hm_name + if port_list: params['server']['port-list'] = port_list