a10sdk-python - Adding members to a Service Group
Hello,
I'm trying to add members to a Service Group using the a10sdk-python modules but can't get it to work. Here's my code:
Creating new Real Servers and Real Ports is no problem but I just don't manage to add this newly created Real Server to an existing Service Group. So if anyone has any pointers or clues I'd be happy to hear! Thanks in advance!
Best,
Jeremy
I'm trying to add members to a Service Group using the a10sdk-python modules but can't get it to work. Here's my code:
from a10sdk.core.slb.slb_server import Server from a10sdk.core.slb.slb_server_port import Port from a10sdk.core.slb.slb_service_group_member import Member def add_servers(k8s_env,new_servers,new_ips,a10_session): server_tuples = [server for server in zip(new_servers,new_ips)] for server in server_tuples: real_server = Server(name=server[0], host=server[1], DeviceProxy=a10_session) health_check = "www-" + k8s_env + "-thesting" service_group = "www-" + k8s_env + "-thesting" real_port = Port(port_number="80", protocol="tcp", health_check=health_check, DeviceProxy=a10_session) service_group_member = Member(name=server[0], port=80, DeviceProxy=a10_session) real_server.create() real_port.create(name=server[0]) service_group_member.create(name=service_group)
Creating new Real Servers and Real Ports is no problem but I just don't manage to add this newly created Real Server to an existing Service Group. So if anyone has any pointers or clues I'd be happy to hear! Thanks in advance!
Best,
Jeremy
0
Comments
I do have examples for AXAPI3.0 which works with ACOS 4.0.0 onwards, are you using that version or ACOS 2.7.0 onwards which uses AXAPI 2.0?
will help you more once i know.
Best Regards,
Eddie Bellamy A10 SE UK
Thanks for the quick reply! I'm using aXAPIv3 with ACOS 4.1.0-P5.
Best,
Jeremy
been checking your A10 SDK which is using URLLIB, my examples are using HTTPLIB within python, please can you send me the error you are getting so we can take a closer look.
please inform me if you want to see my working example using HTTPLIB.
best regards,
Eddie
I have ran your scripts and all is OK, my layout for the zip file was new_servers and new_ips, new_servers were constructed s1, s2, s3 and new_ips '192.168.10.10', '192.168.10.11', '192.168.10.12'
what I don't know is your zip file name structure, but calling my 2 lists together into a zip file worked like your script above.
hope this helps.
best Regards,
Eddie
I'd like to stick with the a10sdk-python modules as those are part of the official A10 Python SDK. And adding real servers and real ports works indeed, it's adding existing real servers to a service group that I can't get to work
And I'm not sure what you mean by zip file name structure, I use zip() to create a list of tuples with the server name and the server IP.
Best,
Jeremy
I will take a look tomorrow.
yes i did mean zip()
BR
Eddie
Thanks for your help. In the meanwhile I'll keep debugging too. If I find something interesting I will post it here.
Best,
Jeremy
My colleague John has also been looking at this.
your config works 100% as long as you have pre-created Service-Group and Health Monitor.
once your initial config creates the new Servers with names, all to port 80, they can be added to an existing Service group.
if you are still having issues, then it would be worth going to support@a10networks.com
best regards,
Eddie
one extra note, not sure if you have tried this, you can use the command "show audit" to check how the API is getting implemented on the A10 Appliance.
best regards,
Eddie
Thanks for the pointers to help debugging the issue. Haven't had the time to dive into this again. Whenever I have new info I'll let you know.
Jeremy
show audit
showed me this:Mar 24 2017 17:05:56 [someapiuser] axapi: [1490375156997751] POST: /axapi/v3/slb/service-group/name-servicegroup/member/name-servicegroup
That won't work of course, the
{name}
template entry is used for both the service group and the server name. So I worked around this by explicitly setting thea10_url
variable: And then my servers get added to service group successfully. So thanks for theshow audit
tip! And this topic can be marked as solved.Best,
Jeremy
Thank you! You are correct. I've been trying to figure out how to remove a server from a service-group for almost 2 weeks. The way the class is built, I think it's impossible to use it for this purpose w/o modifying the url as you've shown me here. I didn't think to update the a10_url, so thank you very much. I can now add and remove servers from a service-group.
service_group = "WEBSRVRS"
a10_url = "/axapi/v3/slb/service-group/" + service_group + "/member/{name}+{port}"
service_group_member = Member(name="MINT20", port=ServicePort, a10_url=a10_url, DeviceProxy=dp)
service_group_member.delete(name="MINT20",port=ServicePort)