Forum Discussion

Maylin's avatar
Maylin
Icon for Nimbostratus rankNimbostratus
Feb 02, 2021

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?

 

 

4 Replies

    • JRahm's avatar
      JRahm
      Icon for Admin rankAdmin

       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.

  • 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.