Trying to find virtual server type through python sdk

I am pulling virtual server info through the rest api and I need to find the type of the virtual server. In everything returned I don’t see anything that looks like Standard or Performance (Fast L4) (the two we use the most). How can I find the type?

u'addressStatus': u'yes',
 u'autoLasthop': u'default',
 u'cmpEnabled': u'yes',
 u'connectionLimit': 0,
 u'description': u'webmail.something.com:80',
 u'destination': u'/C0/1.2.3.4:80',
 u'enabled': True,
 u'fullPath': u'/C0/C0_MAIL_1.2.3.4_TCP_80_VIP',
 u'generation': 1,
 u'gtmScore': 0,
 u'ipProtocol': u'tcp',
 u'kind': u'tm:ltm:virtual:virtualstate',
 u'mask': u'255.255.255.255',
 u'mirror': u'disabled',
 u'mobileAppTunnel': u'disabled',
 u'name': u'C0_MAIL_1.2.3.4_TCP_80_VIP',
 u'nat64': u'disabled',
 u'partition': u'C0',
 u'persist': [{u'name': u'cookie',
               u'nameReference': {u'link': u'https://localhost/mgmt/tm/ltm/persistence/cookie/~Common~cookie?ver=12.1.3.4'},
               u'partition': u'Common',
               u'tmDefault': u'yes'}],
 u'policiesReference': {u'isSubcollection': True,
                        u'link': u'https://localhost/mgmt/tm/ltm/virtual/~C0~C0_MAIL_1.2.3.4_TCP_80_VIP/policies?ver=12.1.3.4'},
 u'pool': u'/C0/C0_PMAIL.0_IPv4_80_POOL',
 u'poolReference': {u'link': u'https://localhost/mgmt/tm/ltm/pool/~C0~C0_MAIL.0_IPv4_80_POOL?ver=12.1.3.4'},
 u'profilesReference': {u'isSubcollection': True,
                        u'link': u'https://localhost/mgmt/tm/ltm/virtual/~C0~C0_MAIL_1.2.3.4_TCP_80_VIP/profiles?ver=12.1.3.4'},
 u'rateLimit': u'disabled',
 u'rateLimitDstMask': 0,
 u'rateLimitMode': u'object',
 u'rateLimitSrcMask': 0,
 u'rules': [u'/Common/SSL_Offload_HTTPS_Rewrite'],
 u'rulesReference': [{u'link': u'https://localhost/mgmt/tm/ltm/rule/~Common~SSL_Offload_HTTPS_Rewrite?ver=12.1.3.4'}],
 u'securityNatPolicy': {u'useDevicePolicy': u'no',
                        u'useRouteDomainPolicy': u'no'},
 u'selfLink': u'https://localhost/mgmt/tm/ltm/virtual/~C0~C0_MAIL_1.2.3.4_TCP_80_VIP?ver=12.1.3.4',
 u'serviceDownImmediateAction': u'none',
 u'source': u'0.0.0.0/0',
 u'sourceAddressTranslation': {u'type': u'none'},
 u'sourcePort': u'preserve',
 'stats': ,
 u'synCookieStatus': u'not-activated',
 u'translateAddress': u'disabled',
 u'translatePort': u'enabled',
 u'vlansDisabled': True,
 u'vsIndex': 64}

Check K55185917: Overview of BIG-IP virtual server types (12.x - 13.x).

Thank you for the KB item, it was very interesting. However, I didn’t see anything in it to explain how I tell what type of VS I’m looking at given the information in the question. I know what type of VS it is from looking at the gui, but I need to tell the difference programmatically from the api.

I created a test virtual server and set it as standard and dumped the data from the api. I then changed it to FastL4 and dumped the data again. It’s exactly the same.

Virtual server type is determined from a set of profiles, not as a configuration object it’s self. If you look at the tmsh config for a virtual server, you won’t see a type.

So as Satoshi was alluding to, knowing what profiles are attributed to what VS, you can infer what the type is. Granted, not the answer you’re looking for.

Or you can add

expandSubcollections=true

query string to the request to expand the

profilesReference

link. For example, the following curl command will get you the names of profiles attached to the virtual

vs

(you can do better with Python than sh, of course).

curl -sku admin:admin https:///mgmt/tm/ltm/virtual/vs?\$select=profilesReference\&expandSubcollections=true \
  | python -m json.tool \
  | fgrep \"name\"
                "name": "fastL4",
                "name": "http",

See OData Queries for how to handle the query parameters in the Python SDK.

In short, you can do something like this.

from f5.bigip import ManagementRoot
mgmt = ManagementRoot('mgmtPort', 'admin', 'admin')
vs = mgmt.tm.ltm.virtuals.virtual.load(
    name='vs', partition='Common',
    requests_params={'params': 'expandSubcollections=true'})

prof = vs.__dict__['profilesReference']['items']
for p in prof:
    print p['name']

Check the Q&A in change virtual server type with TMSH command?.

However, some virtual server types come with additional fields that indicate their types. For example,

Forwarding (Layer 2)

comes with the

l2-forward

field with no value (in tmsh) or

l2Forward

with the value true (in iControl REST).

(tmos) list ltm virtual vs
ltm virtual vs {
    ....
    l2-forward
    ....
}
curl -sku admin:admin https:///mgmt/tm/ltm/virtual/vs | python -m json.tool | grep l2
    "l2Forward": true,

Some don’t. In that case, you need to infer the virtual server type from its profiles. For example, I would assume that the presence of

fasthttp4

profile suggests that it is a

Performance (HTTP)

type.

To my knowledge, there is no documentation, so you need to come up with your own heuristics.