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...
JRahm
Jan 20, 2017Admin
We'll need to clean up stats for sure, the nested stuff is not easy access. For all keys/values, you can get at them a little cleaner (note that if you supply partition as an argument, the self link with be /~Common~vip/~Common~vip/stats):
name = ‘testvip’
selflink = 'https://localhost/mgmt/tm/ltm/virtual/{0}/~Common~{0}/stats'.format(name)
vip = b.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'))
for your specific key, given you have set the selflink above, you can get that with:
vipstats.entries.get(selflink).
get('nestedStats').
get('entries').
get('status.availabilityState').
get('description')
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