a10networks / acos-client Goto Github PK
View Code? Open in Web Editor NEWACOS API Client
License: Apache License 2.0
ACOS API Client
License: Apache License 2.0
Move tests from <package dir>/tests
to <package dir>/<module_dir>/tests
As an acos-client user, I would like the ability to configure ACOS license management.
Getting the following error on all calls to vThunder running ACOS 4.1.4-P2
Driver error: 1023590414 Failed to handle json field "destination". Incorrect string value. Only strings defined by schema are allowed.
Neutron server returns request_ids: ['req-79dbb06a-5d31-491f-b274-059dd6498ab0']
Somehow PR #240 is causing this issue. Reverting the PR changes resolves the issue in my test environment. I don't see why this PR is causing the issue since the default values of the optional arguments are identical to the hard coded value in the original code.
Whatever is calling write_memory must be passing different values for those arguments.
Setting key and name to None doesn't translate to null - it appears to use the original value instead.
Expected behavior: v21 of slb.virtual_server.vport.get() will return the correct matching vport.
Actual behavior: Doing a GET against slb.virtual_server.vport
will return only the first existing vport and not necessarily the correct one. Even if you provide data that does not match any existing vport you will get the first vport.
Reproducible: always
Steps to reproduce:
import acos_client
api = acos_client.Client(
'x.x.x.x',
acos.AXAPI_21,
'user',
'pass'
)
api.slb.virtual_server.create(
'vip', '2.1.1.5'
)
api.slb.virtual_server.vport.create(
'vip',
'vport',
api.slb.virtual_server.vport.TCP,
80,
service_group_name=''
)
api.slb.virtual_server.vport.get(
'vip',
'vport',
api.slb.virtual_server.vport.TCP,
81
)
{'protocol': 2, 'port': 80, 'name': 'vport', 'service_group': '', 'connection_limit': {'status': 0}, 'default_selection': 1, 'received_hop': 0, 'status': 1, 'stats_data': 1, 'extended_stats': 0, 'snat_against_vip': 0, 'vport_template': 'default', 'vport_acl_id': 0, 'aflex_list': [], 'send_reset': 0, 'ha_connection_mirror': 0, 'direct_server_return': 0, 'syn_cookie': {'syn_cookie': 0, 'sack': 0}, 'source_nat': '', 'source_nat_auto': 0, 'source_nat_precedence': 0, 'tcp_template': '', 'source_ip_persistence_template': '', 'ip_in_ip': 0, 'pbslb_template': '', 'acl_natpool_binding_list': []}
Bug location:
acos-client/acos_client/v30/nat.py
Line 40 in 25e8f27
Currently NAT-Pool creation using the ACOS-Client is broken. When calling the nat.pool.create() function, a request is sent using an incorrect URL. This request results in a response containing an error message from the A10 device, and leaves the ACOS-Client user unable to create any ipv4 NAT-Pools.
The URL composed by the client is as follows: https://IP/axapi/v3/ip/nat/pool/POOLNAME
POOLNAME is added in the file /acos_client/v30/nat.py at line 40, which should not be the case as a new pool is being created. When inspecting an existing pool this addition of POOLNAME is correct, but should not be done when creating pools.
Bug fix: Simply removing '+ name' at line 40
This fix does not break any other functionality as the __set() method is only used when creating new pools.
Getting 67239953 Port Type Mismatch
when doing a vport update and setting autosnat
to True.
We might need to catch and maybe send '' or not None? Clearing templates will be tricky.
send: 'POST /axapi/v3/slb/virtual-server/e1ecdb70-2e0a-4451-9e47-2bde8c15ce0b/port/80+tcp HTTP/1.1\r\nHost: 10.90.100.
249\r\nContent-Length: 262\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nUser-Agent: ACOS-Client-AGENT-1.3.1alph
a\r\nConnection: keep-alive\r\nContent-type: application/json\r\nAuthorization: A10 56d8e5f203ca3f262ef4a3d56c9570\r\n
\r\n{"port": {"service-group": "e1ecdb70-2e0a-4451-9e47-2bde8c15ce0b-PORT-80", "protocol": "tcp", "name": "c5d80c89-9a
55-4e4e-97ed-f50785d895e1", "auto": 1, "template-persist-source-ip": null, "extended-stats": 1, "port-number": 80, "te
mplate-persist-cookie": null}}'
reply: 'HTTP/1.1 400 Bad Request\r\n'
header: Date: Tue, 29 Mar 2016 21:57:55 GMT
header: Server: Apache
header: Content-Length: 200
header: Connection: close
header: Content-Type: application/json
axapi_http: data = {
"response": {
"status": "fail",
"err": {
"msg": "JSON message is wrong.",
"code": 1023508480,
"from": "JSON",
"location": "port.template-persist-cookie"
}
}
}
016-03-29 16:57:55.997 TRACE neutron_lbaas.services.loadbalancer.plugin File "/usr/local/src/acos-client/acos_client/v30/slb/virtual_port.py", line 115, in update
2016-03-29 16:57:55.997 TRACE neutron_lbaas.services.loadbalancer.plugin **kwargs)
2016-03-29 16:57:55.997 TRACE neutron_lbaas.services.loadbalancer.plugin File "/usr/local/src/acos-client/acos_client/v30/slb/virtual_port.py", line 94, in _set
2016-03-29 16:57:55.997 TRACE neutron_lbaas.services.loadbalancer.plugin return self._post(url, params, **kwargs)
2016-03-29 16:57:55.997 TRACE neutron_lbaas.services.loadbalancer.plugin File "/usr/local/src/acos-client/acos_client/v30/base.py", line 38, in _post
2016-03-29 16:57:55.997 TRACE neutron_lbaas.services.loadbalancer.plugin return self._request('POST', action, params, **kwargs)
2016-03-29 16:57:55.997 TRACE neutron_lbaas.services.loadbalancer.plugin File "/usr/local/src/acos-client/acos_client/v30/base.py", line 32, in _request
2016-03-29 16:57:55.997 TRACE neutron_lbaas.services.loadbalancer.plugin self.auth_header, **kwargs)
2016-03-29 16:57:55.997 TRACE neutron_lbaas.services.loadbalancer.plugin File "/usr/local/src/acos-client/acos_client/v30/axapi_http.py", line 127, in request
2016-03-29 16:57:55.997 TRACE neutron_lbaas.services.loadbalancer.plugin acos_responses.raise_axapi_ex(r, method, api_url)
2016-03-29 16:57:55.997 TRACE neutron_lbaas.services.loadbalancer.plugin File "/usr/local/src/acos-client/acos_client/v30/responses.py", line 204, in raise_axapi_ex
2016-03-29 16:57:55.997 TRACE neutron_lbaas.services.loadbalancer.plugin raise ae.ACOSException(code, response['response']['err']['msg'])
2016-03-29 16:57:55.997 TRACE neutron_lbaas.services.loadbalancer.plugin ACOSException: 1023508480 JSON message is wrong.
2016-03-29 16:57:55.997 TRACE neutron_lbaas.services.loadbalancer.plugin
In both v21 and v30 of acos_client, when calling the .create()
, .update()
or .delete()
method on various slb objects, slb.service.group.create()
or slb.server.delete()
for example, the acos_client doesn't return anything:
>>> r = v1.slb.server.create('test99', '1.1.1.1')
>>> type(r)
<class 'NoneType'>
This seems to be mostly because there are not return
statements in the method itself:
def create(self, name, ip_address, **kwargs):
params = {
"server": {
"name": name,
"host": ip_address,
"status": kwargs.get('status', 1)
}
}
self._post("slb.server.create", params, **kwargs)
It would be helpful, especially in the v21 client which always returns a status code of 200
for these methods to return the json back from the load-balancer.
The version reported in that file is 1.4.5 though it should be perhaps 2.4.0 per the setup.py file.
>>> acos_client.VERSION
'1.4.6'
>>> exit()
(thor_api) LMTC-JMANZER:thor_api jjmanzer$ pip list acos_client | grep acos
acos-client 2.4.0
My team and I need to be able to use this library in Python 3.6, so I've begun testing against that.
In the process, however, I found that the tests are currently only passing against 2.7; they are not even passing currently against 2.6 or pypy2. Interestingly, it appears that Travis is no longer building this project, so this was never exposed.
I have begun the process of fixing the compatibility, which will likely result in a number of pull requests in order to make them smaller and more easily consumable.
The README.md shows an example of how to manipulate information through the client, but not how to obtain information.
For example, how do I get list of slb.virtual_server
? Can I filter them? How do I get from virtual_server
to service_group
, and from there to the server
objects in that group?
(There is a general need for more documentation, but having more examples would be a great start)
Given an existing virtual_server on an A10 with V21 or V30 API support
when calling slb.virtual_server.vport.create('foo', tcp_template='CONN-TIMEOUT-15S')
or when calling slb.virtual_server.vport.create('foo', udp_template='CONN-TIMEOUT-15S')
then the tcp or udp templates should be applied like so...
!! slb virtual-server SG2NLHG558C1558-WEB-VS x.x.x.x /24
!! port 80 tcp
!! name foo
!! template tcp CONN-TIMEOUT-15S
or
!! slb virtual-server SG2NLHG558C1558-WEB-VS x.x.x.x /24
!! port 80 udp
!! name foo
!! template dup CONN-TIMEOUT-15S
This is so API users can control their own idle-timeout values on vports.
When I do a slb.virtual_server.vport.get
against an AX2500 using version 21 of the API I get the following data. Note that connection_limit
returns a status which makes no sense here.
{
"protocol": 11,
"port": 80,
"name": "TEST-1.1.1.1-TCP-80",
"service_group": "TEST-SG",
"connection_limit": {
"status": 0
},
"default_selection": 1,
"received_hop": 0,
"status": 1,
"stats_data": 1,
"extended_stats": 0,
"snat_against_vip": 0,
"vport_template": "default",
"vport_acl_id": 0,
"aflex_list": [],
"send_reset": 0,
"direct_server_return": 0,
"syn_cookie": {
"syn_cookie": 0,
"sack": 0
},
"source_nat": "",
"source_nat_auto": 0,
"source_nat_precedence": 0,
"http_template": "",
"ram_cache_template": "",
"tcp_proxy_template": "",
"tcp_proxy_server_template": "",
"tcp_proxy_client_template": "",
"server_ssl_template": "",
"conn_reuse_template": "",
"source_ip_persistence_template": "",
"pbslb_template": "",
"acl_natpool_binding_list": []
}
Here is an example of the GET against acos_client 30 to compare with:
{
"port": {
"port-number": 81,
"protocol": "tcp",
"range": 0,
"name": "_2.1.1.3_TCP_81",
"conn-limit": 8000000,
"reset": 0,
"no-logging": 0,
"use-alternate-port": 0,
"action": "enable",
"def-selection-if-pref-failed": "def-selection-if-pref-failed",
"ha-conn-mirror": 0,
"skip-rev-hash": 0,
"message-switching": 0,
"force-routing-mode": 0,
"reset-on-server-selection-fail": 0,
"clientip-sticky-nat": 0,
"extended-stats": 1,
"snat-on-vip": 0,
"stats-data-action": "stats-data-enable",
"syn-cookie": 0,
"no-auto-up-on-aflex": 0,
"scaleout-bucket-count": 32,
"auto": 0,
"service-group": "pool1",
"ipinip": 0,
"rtp-sip-call-id-match": 0,
"use-rcv-hop-for-resp": 0,
"template-tcp": "default",
"template-virtual-port": "default",
"use-default-if-no-server": 0,
"no-dest-nat": 0,
"uuid": "8df0f65a-9245-11e8-9bf6-c3c3b3edcd4e"
}
}
As an acos_client user, I'd like my commands to be retried in a new session when my admin session randomly goes away.
Support the subject.
Also no-dest-nat on virtual ports.
Also sampling-enable on virtual ports
Before creating an object, we check to see if it exists already by performing a GET before the POST. The problem is the error code being returned does not match the previous error code and needs to be mapped in the responses in responses.py
test-requirements states >= 1.0.1
We get AttributeErrors because assetTrue was removed from mock somewhere between 1.0.1 and 1.3.0
As an acos-client user, I would like to have the ability to create a new server when creating a new member for a specified service group should said server not exist.
Currently, ACOS users have the ability to either add an existing server to a service group or create and then add a server within a single step. Acos-client users on the other hand only have the ability to add an existing server through the create
function.
Existing Server -> (associate) -> Member Created -> Added to Service Group
(create) -> Server Created -> Member Created -> Added to Service Group
I believe the following code introduced a Tab Error:
acos-client/acos_client/v30/slb/hm.py
Line 91 in f866473
File "<string>", line 91
params['monitor']['override-port'] = int(port)
^
TabError: inconsistent use of tabs and spaces in indentation
Maybe something changed in the API since the sample has been written.
Had to modify it to make it work:
import acos_client as acos
c = acos.Client('172.31.31.31', acos.AXAPI_21, 'admin', 'a10')
c.slb.server.create('s1', '1.1.1.1')
c.slb.server.create('s2', '1.1.1.2')
c.slb.service_group.create('pool1', c.slb.service_group.TCP,
c.slb.service_group.ROUND_ROBIN)
c.slb.virtual_server.create("vip1", '1.1.1.3', 1,)
c.slb.virtual_server.vport.create("vip1", "vs1", c.slb.virtual_server.vport.HTTP, 80, "pool1")
c.slb.hm.create("hm1", c.slb.hm.HTTP, 5, 5, 5, 'GET', '/', '19', 80)
c.slb.service_group.update('pool1', health_monitor='hm1')
c.slb.service_group.member.create("pool1", "s1", 80)
c.slb.service_group.member.create("pool1", "s2", 80)
Given an existing virtual_server
called foo on an A10 with V21 or V30 API support
When calling slb.virtual_server.vport.create('foo', 'bar', ha_conn_mirror=1)
Then the attribute should assigned like so...
!! slb virtual-server foo x.x.x.x /24
!! port 80 tcp
!! name bar
!! ha-conn-mirror
We use virtual appliances of ACOS v4.1.1. And they could be managed through the aXAPI v3.0 as you know.
I could get the aXAPI reference of v2.1 by following.
ftp://srv01.marubeni-sys.com/other/network1/A10/%8E%91%97%BF/ACOS%202.7.2/references/A10_Thunder_aXAPI_Ref-v21-2014_05_16b.pdf
But I have never found the API reference of v3.0.
If that is public, could you please tell me the URL of it.
Thank you.
Here I am testing with python 3.4.2
[1]> import acos_client
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-7f16c23ae206> in <module>()
----> 1 import acos_client
/home/traff/code/a10/acos-client/acos_client/__init__.py in <module>()
15
16 from acos_client.version import VERSION
---> 17 from acos_client.client import Client
18 from acos_client.hash import Hash
19
/home/traff/code/a10/acos-client/acos_client/client.py in <module>()
15 import acos_client
16
---> 17 import errors as acos_errors
18 import v21.axapi_http
19 from v21.ha import HA as v21_HA
ImportError: No module named 'errors'
Issue:
Calling slb.virtual_server.vport.get() using v21 client results in a type error.
Traceback:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/jjmanzer/development/thor_api/.venv/src/acos-client/acos_client/v21/slb/virtual_port.py", line 105, in get
if len(filtered_vports) > 0:
TypeError: object of type 'filter' has no len()
Steps to reproduce:
import acos_client as acos
api = acos.Client(ip_address, acos.AXAPI_21, username, password)
api.slb.hm.create('healthcheck1', api.slb.hm.HTTP, 5, 5, 5, 'GET', '/', '200', 80)
api.slb.service_group.create('pool1',
protocol=api.slb.service_group.TCP,
hm_name='healthcheck1',
lb_method=api.slb.service_group.LEAST_CONNECTION)
api.slb.server.create('server1', '2.1.1.7',
conn_limit=100,
conn_resume=90)
api.slb.server.port.create('server1', 80, api.slb.service_group.TCP,
conn_limit=100,
conn_resume=90)
api.slb.service_group.member.create('pool1', 'server1', 80)
api.slb.virtual_server.create('testvserver1', '1.1.1.5',
vrid=1,
template_virtual_server='ICMP-RATE-LIMIT')
api.slb.virtual_server.vport.create('testvserver1', '_2.1.1.3_TCP_80', api.slb.virtual_server.vport.HTTP, 80,
service_group_name='pool1',
conn_limit=100000,
ha_conn_mirror=1,
template_tcp='CONN-TIMEOUT-30S',
no_dest_nat=0)
api.slb.virtual_server.vport.get('testvserver1', '_2.1.1.3_TCP_80', api.slb.virtual_server.vport.HTTP, 80)
Virtual port _set
handles a stats
argument. create
and update
have a status
argument.
https://github.com/a10networks/acos-client/blob/master/acos_client/v30/slb/virtual_port.py
What's going on?
In both v21 and v30 of acos_client, when calling the .delete()
method on any slb object, slb.server.delete()
for example, if the object does not exist on the Load-Balancer, the method returns nothing, rather than raising acos_client.errors.NotFound
, similar to the .update()
or '.get() methods.
Given an A10 with V21 or V30 API support
When calling slb.virtual_server.create('foo', conn_limit=1000)
Then the attribute should be assigned like so...
!! slb virtual-server foo x.x.x.x /24
!! conn-limit 1000
A10 Version: 2.7.2-P8(build: 164)
acos-client: 1.4.6
Python Version: 3.7.4
When I use acos-client 1.4.6 to set my own A10Networks, the attribute of "Client IP Sticky NAT" is always disable, and I can not find the site where to set it, it does not appear in the json value which I got it from the 'cl.slb.virtual_server.vport.get' method. How can I enable the "Client IP Sticky NAT" to use AXAPI_21 Version?
This is a feature request to update acos_client (preferably both 21 and 30) to support clearing of slb.server
connections. Perhaps with something like api.slb.server.clear(name)
.
Good Afternoon,
am currently unable to pull all service groups, the ServiceGroup class does have a all function in it but for some reason is not working.
this is using AXAPI_30
>>> c.slb.service_group.all()
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'ServiceGroup' object has no attribute 'all'
>>>
c.slb.virtual_server.all() works fine
As a 4.x acos_client user, I'd like to be able to specify no-dest-nat
on virtual server ports.
The following is fixed function
def _http(self, method, api_url, payload):
if self.protocol == 'https':
http = httplib.HTTPSConnection(self.host, self.port, timeout=self.timeout)
http.connect = lambda: force_tlsv1_connect(http)
else:
http = httplib.HTTPConnection(self.host, self.port, timeout=self.timeout)
LOG.debug("axapi_http: url: %s", api_url)
LOG.debug("axapi_http: method: %s", method)
LOG.debug("axapi_http: headers: %s", logutils.clean(self.HEADERS))
LOG.debug("axapi_http: payload: %s", logutils.clean(payload))
http.request(method, api_url, body=payload, headers=self.headers)
r = http.getresponse()
r_data = r.read()
# Workaround for zero length response
def handle_empty_response(data):
if not data:
raise EmptyHttpResponse(r)
return data
http.close()
return handle_empty_response(r_data)
In v21 of acos_client , when calling slb.virtual_server.vport.create()
or slb.virtual_server.vport.update()
there doesn't seem to be a way to configure no-dest-nat
As an acos_client user, I'd like the created or updated virtual server to be returned from client.slb.virtual_server.create
, client.slb.virtual_server.update
, client.slb.service_group.create
, and client.slb.service_group.update
Given a slb.server that has current sessions on either a v21 or v30 API.
When a call to slb.server.clear_sessions('foo')
happens
Then sessions are cleared for that server.
Can this be done with a raw CLI call? If so what would be the correct way to do this?
Given a fresh A10 with V21 or V30 API support
when calling slb.virtual_server.create('foo', vip_template='ICMP-RATE-LIMIT')
then the virtual-server template should be applied like so...
!! slb virtual-server foo x.x.x.x /24
!! template virtual-server ICMP-RATE-LIMIT
This is so API users can control their own ICMP rate limit values on vips.
Right now we just support creating interfaces w/ DHCP - flesh that out.
Given an A10 with V21 or V30 API support
When calling slb.virtual_server.create('foo', 'x.x.x.x', conn_limit=1000, conn_resume=1900)
Then the attribute should be assigned like so...
!! slb server foo x.x.x.x
!! conn-limit 100000
!! conn-resume 98000
The v21 client provides a method to retrieve all service groups
from a device, via client.slb.service_group.all()
:
from acos_client/v21/slb/service_group.py
:
def all(self, **kwargs):
return self._get('slb.service_group.getAll', **kwargs)
The v30 client does not provide this method.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.