Forum Discussion
Trying to create VIPs via Python and get an error
Here is the snippet of code that is used to create the VIPs on the f5;
rv0=revisedServer.replace("dev_","test_vip_")
print (eachServer[0][3].upper())
rv1=eachServer[0][3].upper()
params = {'name': rv0, 'source': "0.0.0.0/0", 'description': "TEST VS",'protocol': rv1,'pool': revisedServer,'profiles': profiles,'partition': 'Common','sourceAddressTranslation': {'type': 'snat'},'vlansEnabled': 'True','vlans': ['/Common/Dev'],'arp':'disabled','icmpecho':'disabled','state':'disabled','port':eachServer[0][1],'tagMode':'none'}
print (params)
#LETS CREATE VIRTIUAL SERVERS IF THE SERVER ALREADY EXISTS KEEP IT MOVING
try:
ltm.virtuals.virtual.create(**params)
except Exception as e:
print (e)
When run I get the following error:
400 Unexpected Error: Bad Request for uri: https://pltbigip01.pexdev.corp:443/mgmt/tm/ltm/virtual/
Text: '{"code":400,"message":"Instance contains a string","errorStack":[],"apiError":1}'
Does anyone know why?
- PSilvaRet. Employee
While I don't have a direct answer, this link has some Python resources that might help? https://devcentral.f5.com/s/feed/0D51T00006i7jgRSAQ
And, this is the F5 Python SDK Documentation
https://f5-sdk.readthedocs.io/en/latest/
Also, might have some insight.
Hope that helps.
ps
- JRahmAdmin
if you reformat your code there to use the codeblock, it'll be helpful. I can take a look a little later tonight to see what's going on. In the meantime, if you're just getting started with f5-common-python, I'd recommend you take a look at bigrest instead, as it is in active development.
- JRahmAdmin
Some feedback on your sample:
'Protocol' --> Should be: 'ipProtocol' 'vlansEnabled': 'True' --> Should be: 'vlansEnabled': true 'icmpecho' --> Should be: 'icmpEcho' BUT this is not an attribute on the virtual server, it's on the virtual address (/mgmt/tm/ltm/virtual-address/<ip>), as is the 'arp' attribute 'state': 'disabled' --> Should be: 'enabled': true OR 'disabled': true 'port' --> Is included in: 'destination' BUT that property is missing, it should include ip:port Make sure profiles is configured appropriately, it is a sub collection 'tagMode' is not a property I can find on either virtual server or virtual address, what version are you on?
If you want to see the properties on a method, you can use the example by hitting https://your.bigip.here/mgmt/tm/ltm/virtual/example. It's 503 lines long or I'd post it here. Hope this helps.
- Former Member
also some details on this closed (duplicate) question:
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com