Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to disable health check on servers #313

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions acos_client/tests/unit/v30/test_slb_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -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'
}
}
Expand All @@ -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'
}
}
Expand All @@ -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'
}
}
Expand Down Expand Up @@ -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,
}
Expand All @@ -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'
}
}
Expand All @@ -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'
}
}
Expand All @@ -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'
}
}
Expand Down
17 changes: 14 additions & 3 deletions acos_client/v30/slb/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down