f5-common-python
f5-common-python copied to clipboard
Better formatting for /stats and similiar endpoints
Apart from /stats we have /sys/hostInfo and /sys/memory endpoints which present data in a specific format. While we have a utility that will format that data if the user chooses to do so, it would be good if the output is streamlined and introduced into SDK as perhaps a new method to be called upon, we have to do this in a separate method as not to break backwards compatibility.
Opening this issue for discussion and proposed work
pool members stats are not currently handled well if at all in the current Stats utility. That needs work as well. Some thoughts on end-user experience:
# Loading stats - would be nice to not care about URL format, just load the stats available to the object
pool = mgmt.tm.pools.pool.load(name='testpool')
pstats = pool.stats()
For the stat fields themselves, it would be nice to flatten everything to attributes on the stats objects rather than dictionary k,v pairs like current behavior. So instead of having to iterate through all the items and pull description/value details out, we should handle this for them unless a kwarg is supplied that returns data as is for backwards compatibility.
This would result in accessors of:
pstats.serverside_bitsOut (value int)
pstats.status_statusReason (description string)
Instead of:
pstats['serverside_bitsOut']['value']
pstats['status_statusReason']['description']
you can include decorators that will do this for you rather than modify the data we get straight out of the unit. Once i get some time (soon) I will experiment and put some proposals here