Forum Discussion
Satoshi_Toyosa1
Jun 07, 2018Employee
Thank you, Jason Nance, for the pure-Python code. Here's an example code using the F5 Python SDK. It creates a virtual with the specified profiles and pool (the pool should be already there).
from f5.bigip import ManagementRoot
params = {'name': 'myTestVirtual',
'partition': 'Common',
'destination': '192.168.184.100:80',
'mask': '255.255.255.255',
'source': '0.0.0.0/32',
'pool': 'myPool',
'profiles': [
{'name': 'http'},
{'name': 'tcp'}
]
}
Connect to the BIG-IP. Change the IP and user/pass
mgmt = ManagementRoot('192.168.1.1', 'admin', 'adminPasswd')
try:
vs = mgmt.tm.ltm.virtuals.virtual.create(**params)
print(vs.raw)
except Exception as e:
print(params['name'] + ' failed. ' + str(e))