Getting Started with the f5-common-python SDK
Jason, great article and awesome SDK ... i just fall in love with it.
I am working on migrating sites from one 'old' unit to the new one. Plan is to read the following information from the Old unit :
- Virtual Server
- Pools
- Persistence profile
- SSL Profile
- Data Groups
- iRules etc.
and create a script to re-create them ditto on the new unit.
So far I have developed the Virtual Server script and wondering if you can see if its the right way of doing it :
from f5.bigip import ManagementRoot
import getpass
mgmt = ManagementRoot(BigIP_IP, "admin", "pass")
print ("===Create a Virtual===")
vip = mgmt.tm.ltm.virtuals.virtual.create(\
name='testvip',\
partition='Common',\
destination='10.10.10.10:80',\
ipProtocol='tcp',\
sourceAddressTranslation={'type': 'automap'},\
persist=[ { 'name': 'testvip-Cookie' } ],\
rules=["testvip-rules"],\
profilesReference={ 'items' : [ { 'name' : 'http_XForwardedFor' }, \
{"name": "oneconnect"},\
{"name": "tcp-lan-optimized", "context": "serverside"},\
{"name": "tcp-wan-optimized", "context": "clientside"},\
{"name": "testvip-clientssl-ssl"}
] }
)
But one thing I couldn't able to do is how to disable the above VIP. I mean "state"="disabled". I tried disabled = 'true' but it errors out.
Second, I need to modify the virtual-address attached to the above testVIP (10.10.10.10) to disable "arp" and "icmpEcho" and change the traffic-group but I couldn't able to even check if it exists :
vip = mgmt.tm.ltm.virtualAddress.exists(name='10.10.10.10', partition='Common')
It keeps giving an error
AttributeError: '' object has no attribute 'virtualAddress'
Please let me know what I am missing or doing wrong.
Highly appreciate your help.
Thank you,
Muhammad