Forum Discussion
Ed_Summers
Jan 19, 2017Nimbostratus
F5 Python SDK: How to get virtual server availability?
Due to my limited Python and SDK experience I am finding it difficult to easily obtain the availability state of a virtual server. Given a 'virtual' object, what is the best/easiest way to return the...
Rob_74473
Cirrus
I'm also struggling with this:
partition = 'C25'
pool_name = 'temp_test'
{u'https://localhost/mgmt/tm/ltm/pool/~C25~temp_test/~C25~temp_test/stats': {u'nestedStats': {u'entries': {u'activeMemberCnt': {u'value': 1},
pool = mgmt.tm.ltm.pools.pool.load(name=pool_name, partition=partition)
stats = pool.stats.load()
print("{}".format(pformat(stats.entries)))
selflink = "https://{0}/mgmt/tm/ltm/pool/~{1}~{2}/~{1}~{2}/stats".format(bigip,partition,pool_name)
slink = stats.entries.get(selflink)
nested = slink.get('nestedStats')
entries = nested.get('entries')
activeMemberCnt = entries.get('activeMemberCnt').get('value')
Output:
Traceback (most recent call last):
File "test_f5.py", line 46, in
nested = slink.get('nestedStats')
AttributeError: 'NoneType' object has no attribute 'get'
So, using the example above, I am not able to get the selflink, but I have created the selflink string from what's given in the raw output. I'm working against: BIG-IP 12.1.3 Build 0.0.378 Final
Rob_74473
Apr 25, 2018Cirrus
Directly testing the code above:
name = 'DHCP_RELAY_255.255.255.255_VIP'
selflink = 'https://{0}/mgmt/tm/ltm/virtual/{1}/~Common~{1}/stats'.format(bigip,name)
vip = mgmt.tm.ltm.virtuals.virtual.load(name=name)
vipstats = vip.stats.load()
d = vipstats.entries.get(selflink).get('nestedStats').get('entries')
for i in d:
print("{0}: {1}".format(i, d[i].get('value')))
I get the same error:
Traceback (most recent call last):
File "test_f5.py", line 39, in
d = vipstats.entries.get(selflink).get('nestedStats').get('entries')
AttributeError: 'NoneType' object has no attribute 'get'
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects