Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Clear all filters
Answers

Set a Virtual Server Type in F5 Python SDK

Can I set up a Virtual Server Type, among the existing, for example Standard, Performance (Layer 4), Performance (HTTP), or Forwarding IP? When I create a Virtual Server, by default it is created with the Performance (Layer 4) type. Thanks in advance.

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Changing the profile(s) attached to a virtual isn't that straight-forward especially when incompatible profiles are involved: e.g., changing from fastL4 to http. Please refer to an answer to How can we configure fastL4 VS using icontrol rest. It discusses general iControl REST (using curl) but should be applicable to the F5 Python SDK.

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

You can create a new virtual with a specific profile. The following curl example creates a virtual with the http profile. The tcp profile comes along with it. Again, the method should be applicable to the Python SDK too.

# curl -sku admin:<pass> https://<mgmtIP>/mgmt/tm/ltm/virtual \
  -H "Content-type: application/json" -X POST \
  -d '{"name":"virtual", "profilesReference":{"items":[{"name":"http"}]}}'
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Python code example for creating a "standard" virtual server is here:

https://devcentral.f5.com/wiki/iControlREST.Python-Virtual-Server-Pool-Create.ashx

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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))
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER