diff --git a/acos_client/tests/unit/v30/test_slb_server.py b/acos_client/tests/unit/v30/test_slb_server.py index 6e306e02..6ad9836d 100644 --- a/acos_client/tests/unit/v30/test_slb_server.py +++ b/acos_client/tests/unit/v30/test_slb_server.py @@ -53,6 +53,7 @@ def test_server_create(self, mocked_get): 'action': 'enable', 'conn-limit': 8000000, 'conn-resume': None, + 'health-check': None, 'host': '192.168.2.254', 'name': VSERVER_NAME, } @@ -88,6 +89,7 @@ def test_server_create_with_template(self, mocked_get): 'conn-resume': None, 'host': '192.168.2.254', 'name': VSERVER_NAME, + 'health-check': None, 'template-server': 'test-template-server' } } @@ -181,6 +183,7 @@ def test_server_create(self, mocked_get): 'action': 'enable', 'conn-limit': 8000000, 'conn-resume': None, + 'health-check': None, 'server-ipv6-addr': '2001:baad:deed:bead:daab:daad:cead:100e', 'name': VSERVER_NAME, } @@ -216,6 +219,7 @@ def test_server_create_with_template(self, mocked_get): 'conn-resume': None, 'host': '192.168.2.254', 'name': VSERVER_NAME, + 'health-check': None, 'template-server': 'test-template-server' } } diff --git a/acos_client/v30/action.py b/acos_client/v30/action.py index 339929cc..615bfc4e 100644 --- a/acos_client/v30/action.py +++ b/acos_client/v30/action.py @@ -45,3 +45,64 @@ def clideploy(self, commandlist, **kwargs): "commandlist": commandlist } return self._post("/clideploy/", payload, **kwargs) + + def reload(self): + self._post("/reload", "") + + def setInterface(self, interface): + data = {"ethernet": {"ifnum": str(interface), "name": "DataPort", + "action": "enable", "ip": {"dhcp": 1}}} + url = "/interface/ethernet/" + str(interface) + self._post(url, data) + + def reboot(self): + self._post("/reboot", "") + + def configureVRRP(self, device_id, set_id): + data = {"common": {"device-id": device_id, "set-id": set_id, + "action": "enable"}} + url = "/vrrp-a/common" + self._post(url, data) + + def configureVRID(self, vrid): + data = {"vrid": {"vrid-val": vrid, + "blade-parameters": {"priority": 150}}} + url = "/vrrp-a/vrid" + self._post(url, data) + + def configSynch(self, ip_address, username, password): + data = {"sync": {"address": ip_address, "auto-authentication": 1, + "type": "all", "usr": username, "pwd": password}} + url = "/configure/sync" + self._post(url, data) + + def set_vcs_device(self, device_id, priority): + data = {"device": {"device": device_id, "priority": priority, + "management": 1, "enable": 1}} + url = "/vcs/device/" + self._post(url, data) + + def set_vcs_para(self, floating_ip, floating_ip_mask): + data = {"vcs-para": {"floating-ip-cfg": [{"floating-ip": floating_ip, + "floating-ip-mask": floating_ip_mask}]}} + url = "/vcs/vcs-para" + self._post(url, data) + + def vcs_enable(self): + data = {"action": {"action": "enable"}} + url = "/vcs/action" + self._post(url, data) + + def vcs_reload(self): + url = "/vcs/reload" + self._post(url) + + def check_vrrp_status(self): + url = "/vrrp-a" + data = self._get(url) + if "common" in data["vrrp-a"].keys() and \ + "action" in data["vrrp-a"]["common"].keys() and \ + data["vrrp-a"]["common"]["action"] == "enable": + return True + else: + return False diff --git a/acos_client/v30/slb/hm.py b/acos_client/v30/slb/hm.py index 567484b2..97bee1a7 100644 --- a/acos_client/v30/slb/hm.py +++ b/acos_client/v30/slb/hm.py @@ -23,6 +23,7 @@ class HealthMonitor(base.BaseV30): # Valid method objects + UDP = 'udp' ICMP = 'icmp' TCP = 'tcp' HTTP = 'http' @@ -33,6 +34,11 @@ class HealthMonitor(base.BaseV30): ICMP: { "icmp": 1 }, + UDP: { + "udp": 1, + "udp-port": 5550, + "force-up-with-single-healthcheck": 0 + }, HTTP: { "http": 1, "http-port": 80, @@ -62,7 +68,7 @@ def get(self, name, **kwargs): return self._get(self.url_prefix + name, **kwargs) def _set(self, action, name, mon_method, interval, timeout, max_retries, - method=None, url=None, expect_code=None, port=None, update=False, + method=None, url=None, expect_code=None, port=None, ipv4=None, update=False, **kwargs): params = { "monitor": { @@ -72,7 +78,8 @@ def _set(self, action, name, mon_method, interval, timeout, max_retries, "timeout": int(timeout), "method": { mon_method: self._method_objects[mon_method] - } + }, + "override-ipv4": ipv4 } } if method: @@ -100,10 +107,10 @@ def _set(self, action, name, mon_method, interval, timeout, max_retries, if update: action += name - self._post(action, params, **kwargs) + return self._post(action, params, **kwargs) def create(self, name, mon_type, interval, timeout, max_retries, - method=None, url=None, expect_code=None, port=None, **kwargs): + method=None, url=None, expect_code=None, port=None, ipv4=None, **kwargs): try: self.get(name) except acos_errors.NotFound: @@ -111,15 +118,16 @@ def create(self, name, mon_type, interval, timeout, max_retries, else: raise acos_errors.Exists() - self._set(self.url_prefix, name, mon_type, interval, timeout, - max_retries, method, url, expect_code, port, **kwargs) + return self._set(self.url_prefix, name, mon_type, interval, timeout, + max_retries, method, url, expect_code, port, ipv4, update=False, + **kwargs) def update(self, name, mon_type, interval, timeout, max_retries, - method=None, url=None, expect_code=None, port=None, **kwargs): + method=None, url=None, expect_code=None, port=None, ipv4=None, **kwargs): self.get(name) # We want a NotFound if it does not exist - self._set(self.url_prefix, name, mon_type, interval, timeout, - max_retries, method, url, expect_code, port, update=True, - **kwargs) + return self._set(self.url_prefix, name, mon_type, interval, timeout, + max_retries, method, url, expect_code, port, ipv4, update=True, + **kwargs) def delete(self, name): - self._delete(self.url_prefix + name) + return self._delete(self.url_prefix + name) diff --git a/acos_client/v30/slb/server.py b/acos_client/v30/slb/server.py index 8e111ea2..607c9c9c 100644 --- a/acos_client/v30/slb/server.py +++ b/acos_client/v30/slb/server.py @@ -35,6 +35,7 @@ def create(self, name, ip_address, status=1, server_templates=None, **kwargs): "action": 'enable' if status else 'disable', "conn-resume": kwargs.get("conn_resume", None), "conn-limit": kwargs.get("conn_limit", 8000000), + "health-check": kwargs.get("health_check") } } diff --git a/acos_client/v30/slb/template/persistence.py b/acos_client/v30/slb/template/persistence.py index 147f42ae..3a57179a 100644 --- a/acos_client/v30/slb/template/persistence.py +++ b/acos_client/v30/slb/template/persistence.py @@ -37,7 +37,10 @@ def exists(self, name): def create(self, name, **kwargs): if self.exists(name): raise acos_errors.Exists - self._post(self.prefix, self.get_params(name), **kwargs) + self._post(self.prefix, + self.get_params(name, + cookie_name=kwargs.get("cookie_name")), + **kwargs) def delete(self, name, **kwargs): self._delete(self.prefix + name, **kwargs) @@ -49,11 +52,11 @@ def __init__(self, client): self.pers_type = 'cookie' super(CookiePersistence, self).__init__(client) - def get_params(self, name, cookie_name=None): + def get_params(self, name, **kwargs): return { "cookie": { "name": name, - "cookie-name": cookie_name + "cookie-name": kwargs.get("cookie_name") } } @@ -64,7 +67,7 @@ def __init__(self, client): self.pers_type = 'source-ip' super(SourceIpPersistence, self).__init__(client) - def get_params(self, name): + def get_params(self, name, **kwargs): return { "source-ip": { "name": name diff --git a/acos_client/v30/slb/template/ssl.py b/acos_client/v30/slb/template/ssl.py index 7afce7a7..54562313 100644 --- a/acos_client/v30/slb/template/ssl.py +++ b/acos_client/v30/slb/template/ssl.py @@ -52,8 +52,8 @@ def _set(self, name, cert="", key="", passphrase="", update=False, else: obj_params = { "name": name, - "cert-str": cert, - "key-str": key, + "cert": cert, + "key": key, self.passphrase: passphrase, # Unimplemented options: # "encrypted": encrypted,