Skip to content

Commit

Permalink
Merge pull request #388 from a10networks/master
Browse files Browse the repository at this point in the history
Merge master to stable/victoria for acos-client v2.10.0 release
  • Loading branch information
ytsai-a10 authored May 12, 2023
2 parents edf5739 + 964fe39 commit af937e7
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 32 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
| ACOS Version | AXAPI Version | ACOS Client Version | Status |
| 2.7.1† | 2 | >=0.1.0,<0.3.0 | end-of-life |
| 2.7.2 | 2 | >=0.1.0,<0.3.0 | end-of-life |
| 4.0.0 | 3 | >=1.4.6,<1.5.0 | Maintenance |
| 4.1.1 | 3 | >=1.5.0,<2.0.0 | Maintenance |
| 4.1.4 GR1-P2 | 3 | >=2.0.0,<2.4.0 | Maintenance |
| 4.1.4 | 3 | >=2.4.0 | Maintenance |
| 4.0.0 | 3 | >=1.4.6,<1.5.0 | end-of-life |
| 4.1.1 | 3 | >=1.5.0,<2.0.0 | end-of-life |
| 4.1.4 GR1-P2 | 3 | >=2.0.0,<2.4.0 | end-of-life |
| 4.1.4 | 3 | >=2.4.0 | end-of-life |
| 4.1.4 GR1-P5 | 3 | >=2.6.0 | Maintenance |
| 5.2.1 | 3 | >=2.6.0 | Maintenance |
| 5.2.1-p1 | 3 | >=2.7.0 | Maintenance |
| 5.2.1-p2 | 3 | >=2.9.0 | Maintenance |
| 5.2.1-p2 | 3 | >=2.9.1 | Maintenance |
| 5.2.1-p2 | 3 | >=2.10.0 | Maintenance |
```

†Works only when not using partitioning
Expand All @@ -40,7 +41,7 @@
### Install using pip

```sh
$ pip install acos-client>=2.6.0
$ pip install acos-client>=2.9.0
```

### Install from source
Expand Down
27 changes: 23 additions & 4 deletions acos_client/v30/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,30 @@ def reload_all(self):
payload = {"reload": {"all": 1}}
self._post("/reload", payload)

def setInterface(self, interface):
data = {"ethernet": {"ifnum": str(interface), "name": "DataPort",
"action": "enable", "ip": {"dhcp": 1}}}
def setInterface(self, interface, address_list, ip_version, dual=False):
if not address_list and ip_version == 4:
data = {"ethernet": {"ifnum": str(interface), "name": "DataPort",
"action": "enable", "ip": {"dhcp": 1}}}

if address_list and ip_version == 4:
data = {'ethernet': {'ifnum': str(interface), "name": "DataPort", "action": "enable",
'ip': {'address-list': address_list}}}

if ip_version == 6:
if address_list:
if dual:
data = {'ethernet': {'ifnum': str(interface), "name": "DataPort",
"action": "enable", "ip": {"dhcp": 1},
'ipv6': {'address-list': address_list, 'ipv6-enable': 1}}}
else:
data = {'ethernet': {'ifnum': str(interface), "name": "DataPort",
"action": "enable",
'ipv6': {'address-list': address_list, 'ipv6-enable': 1}}}
else:
data = {'ethernet': {'ifnum': str(interface), "name": "DataPort"}}

url = "/interface/ethernet/" + str(interface)
self._post(url, data)
self._put(url, data)

def reboot(self):
self._post("/reboot", "")
Expand Down
11 changes: 11 additions & 0 deletions acos_client/v30/nat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@


class Nat(base.BaseV30):

@property
def pool(self):
return self.Pool(self.client)

@property
def ipv6pool(self):
return self.IPv6Pool(self.client)

class Pool(base.BaseV30):
url_prefix = "/ip/nat/pool/"

Expand Down Expand Up @@ -88,3 +93,9 @@ def stats(self, name='', max_retries=None, timeout=None, **kwargs):

def all_stats(self, **kwargs):
return self.stats()


class IPv6Pool(Pool):
def __init__(self, client):
super().__init__(client)
self.url_prefix = "/ipv6/nat/pool/"
102 changes: 85 additions & 17 deletions acos_client/v30/slb/template/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from acos_client import errors as acos_errors
from acos_client.v30 import base
import acos_client.utils as utils


class BaseSSL(base.BaseV30):
Expand All @@ -32,13 +33,19 @@ def exists(self, name):
except acos_errors.NotFound:
return False

def get_acos_version(self):
url = "/version/oper"
return self._get(url)

def _set(self, name, cert="", key="", passphrase="", update=False,
cipher_template=None, **kwargs):
# Unimplemented options:
# encrypted, session_ticket_enable, version, forward_proxy_enable,
# close_notify, session_cache_size, session_cache_timeout,
# server_certificate_error, cipher_without_prio_list,

version_summary = self.get_acos_version()
acos_version = version_summary['version']['oper']['sw-version'].split(',')[0]
params = {}

if cipher_template:
Expand All @@ -50,23 +57,84 @@ def _set(self, name, cert="", key="", passphrase="", update=False,
}

else:
obj_params = {
"name": name,
"cert": cert,
"key": key,
self.passphrase: passphrase,
# Unimplemented options:
# "encrypted": encrypted,
# "session-ticket-enable": session_ticket_enable,
# "version": version,
# "forward-proxy-enable": forward_proxy_enable,
# "close-notify": close_notify,
# "session-cache-size": session_cache_size,
# "session-cache-timeout": session_cache_timeout,
# "server-certificate-error": server_certificate_error,
# "cipher-without-prio-list": cipher_without_prio_list,
# "ca-certs": ca_certs,
}
if utils.acos_version_cmp(acos_version, "5.2.0") >= 0:
if not update:
obj_params = {
"name": name,
"certificate-list": [
{
"cert": cert,
"key": key,
"passphrase": passphrase
}
]
# Unimplemented options:
# "encrypted": encrypted,
# "session-ticket-enable": session_ticket_enable,
# "version": version,
# "forward-proxy-enable": forward_proxy_enable,
# "close-notify": close_notify,
# "session-cache-size": session_cache_size,
# "session-cache-timeout": session_cache_timeout,
# "server-certificate-error": server_certificate_error,
# "cipher-without-prio-list": cipher_without_prio_list,
# "ca-certs": ca_certs,
}
else:
if self.exists(name):
existing_template = self.get(name)
existing_cert_list = existing_template['client-ssl']['certificate-list'][0]
existing_cert = existing_cert_list['cert']
existing_key = existing_cert_list['key']
if "passphrase" in existing_cert_list:
existing_passphrase = existing_cert_list['passphrase']
else:
existing_passphrase = ""

obj_params = {
"name": name,
"certificate-list": [
{
"cert": existing_cert,
"key": existing_key,
"passphrase": existing_passphrase
},
{
"cert": cert,
"key": key,
"passphrase": passphrase
}
]
# Unimplemented options:
# "encrypted": encrypted,
# "session-ticket-enable": session_ticket_enable,
# "version": version,
# "forward-proxy-enable": forward_proxy_enable,
# "close-notify": close_notify,
# "session-cache-size": session_cache_size,
# "session-cache-timeout": session_cache_timeout,
# "server-certificate-error": server_certificate_error,
# "cipher-without-prio-list": cipher_without_prio_list,
# "ca-certs": ca_certs,
}
else:
obj_params = {
"name": name,
"cert": cert,
"key": key,
self.passphrase: passphrase,
# Unimplemented options:
# "encrypted": encrypted,
# "session-ticket-enable": session_ticket_enable,
# "version": version,
# "forward-proxy-enable": forward_proxy_enable,
# "close-notify": close_notify,
# "session-cache-size": session_cache_size,
# "session-cache-timeout": session_cache_timeout,
# "server-certificate-error": server_certificate_error,
# "cipher-without-prio-list": cipher_without_prio_list,
# "ca-certs": ca_certs,
}

params = {'%s-ssl' % self.prefix: {}}
for key, val in six.iteritems(obj_params):
Expand Down
1 change: 0 additions & 1 deletion acos_client/v30/slb/virtual_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def _set(self, name, ip_address=None, arp_disable=False, description=None, vrid=
params = {
"virtual-server": self.minimal_dict({
"name": name,
"ip-address": ip_address,
"arp-disable": None if arp_disable is None else int(arp_disable),
"description": description,
"port-list": port_list
Expand Down
15 changes: 12 additions & 3 deletions acos_client/v30/vrrpa/vrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from acos_client import errors as acos_errors
from acos_client.v30 import base
from acos_client.v30.vrrpa.blade_params import BladeParameters
from collections import ChainMap


class VRID(base.BaseV30):
Expand Down Expand Up @@ -44,16 +45,24 @@ def _build_params(self, vrid_val, threshold=None, disable=None, floating_ips=[],
vrid_floating_ips = None
if floating_ips:
if is_partition:
ip_partition_list = [{'ip-address-partition': ip} for ip in floating_ips]
ip_partition_list = [{'ip-address-partition': ip} for ip in floating_ips if not self._is_ipv6(ip)]
vrid_floating_ips = {
'ip-address-part-cfg': ip_partition_list
}
ipv6_partition_list = [{'ipv6-address-partition': ip} for ip in floating_ips if self._is_ipv6(ip)]
ipv6_vrid_floating_ips = {
'ipv6-address-part-cfg': ipv6_partition_list
}
else:
ip_list = [{'ip-address': ip} for ip in floating_ips]
ip_list = [{'ip-address': ip} for ip in floating_ips if not self._is_ipv6(ip)]
vrid_floating_ips = {
'ip-address-cfg': ip_list
}
vrid['floating-ip'] = vrid_floating_ips
ipv6_list = [{'ipv6-address': ip} for ip in floating_ips if self._is_ipv6(ip)]
ipv6_vrid_floating_ips = {
'ipv6-address-cfg': ipv6_list
}
vrid['floating-ip'] = dict(ChainMap(vrid_floating_ips, ipv6_vrid_floating_ips))

if threshold or disable:
threshold = threshold if threshold in range(0, 256) else 1
Expand Down
2 changes: 1 addition & 1 deletion acos_client/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# License for the specific language governing permissions and limitations
# under the License.

VERSION = '2.9.1'
VERSION = '2.10.0'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name = "acos-client",
version = "2.9.1",
version = "2.10.0",
packages = find_packages(),

author = "A10 Networks",
Expand Down

0 comments on commit af937e7

Please sign in to comment.