Skip to content

Commit

Permalink
Merge pull request #271 from a10networks/feature/octavia-support
Browse files Browse the repository at this point in the history
[STACK-1129] PR to add Octavia support for ACOSv4.1.4/AXAPIv3
  • Loading branch information
hthompson6 authored Apr 16, 2020
2 parents 2b4f8f7 + 8121dbd commit 800718e
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 17 deletions.
4 changes: 4 additions & 0 deletions acos_client/tests/unit/v30/test_slb_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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'
}
}
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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'
}
}
Expand Down
61 changes: 61 additions & 0 deletions acos_client/v30/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 19 additions & 11 deletions acos_client/v30/slb/hm.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
class HealthMonitor(base.BaseV30):

# Valid method objects
UDP = 'udp'
ICMP = 'icmp'
TCP = 'tcp'
HTTP = 'http'
Expand All @@ -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,
Expand Down Expand Up @@ -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": {
Expand All @@ -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:
Expand Down Expand Up @@ -100,26 +107,27 @@ 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:
pass
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)
1 change: 1 addition & 0 deletions acos_client/v30/slb/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

Expand Down
11 changes: 7 additions & 4 deletions acos_client/v30/slb/template/persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
}
}

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions acos_client/v30/slb/template/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 800718e

Please sign in to comment.