I have seen multiple samples on creating a pool and loading a member in that pool. I have looked at the "https://localhost/mgmt/tm/ltm/node/example?ver=11.5.3"; for creating nodes but so far I am not getting the idea. Is there a way using Python Rest or Python SDK to create a node in the common partition with no pool? After the node is loaded I will then take that node and use it in a pool/s but the pool/s are in different partition.
This code will add a node to the Common Partition. Once the node is added in common it needs to be added to two different Partitions. For example below adding it to one different Partition. I have read this before but when running "update" the old information is removed and the new is added. How can I append the new to the old using the SDK?
from f5.bigip import ManagementRoot
mgmt = ManagementRoot("bigip.example.com", "admin", "somepassword")
mynode = mgmt.tm.ltm.nodes.node.create(name='10.5.183.191', address='10.5.183.191', description='12345avc', partition='Common')
pool_a = mgmt.tm.ltm.pools.pool.load(name='pool1', partition='CL-COM_SELFSERV')
pool_a.members = '10.5.183.192:8080'
So when adding new member to a pool it wipes out the existing members. I then tried
but received error:
Traceback (most recent call last):
File "<pyshell#5>", line 1, in
File "C:\Python27\lib\site-packages\f5\bigip\mixins.py", line 125, in getattr
AttributeError: '<class 'f5.bigip.tm.ltm.pool.Pool'>' object has no attribute 'members'
To add an existing node to an existing pool:
pool = mgmt.tm.ltm.pools.pool.load(partition='Common', name='mypool')
The secret sauce is in the overloaded name argument - it is really "node_name:service_port".
The above adds an existing node called "mynodename" to the pool and sets its service port to 80.
Up front: I'm very new to the SDK. My efforts so far have only focused on querying the device and reading state. I haven't practiced much in the realm of creating or modifying objects.
The pool members are a sub-collection under the pool. You can get the sub-collection:
which will return a list of member objects. It looks like you're trying to pass just a string, where the collection of members is actually a list of member objects. Rather than botch the nomenclature, I found a decent starting example in the docs. Look about half-way down in the coding example on this link for an example of creating new pool members:
Managing LTM Pools and Members via the F5 SDK
Sorry I can't give you a more concrete example but hopefully this will help give you a start until someone with more experience on the SDK can fill in any other details.