ask the parseltongue programmer
Apr. 15th, 2015 09:11 pmSo, I'm mucking around with python - in particular, with F5's "bigsuds" library, which does web transactions with their "iControl" API. I've run into a data structure that is making me remember that I never took a data structures class.
I'm trying to get the list of health monitors for a given pool, using "LocalLB.Pool.get_monitor_instance([pool])". The get_monitor_instance API reference page just says I get a string back. Which, I do, but in python-speak, I get what looks like a dictionary which includes other dictionaries embedded in a list embedded in a list. Like this:
How the heck do I parse this? I'd like to be able to break it down to a dictionary so I can say "print thing["10.10.0.23"]['template_name']" where that would be "http", I guess.
ETA: based on the consensus, evidently by parsing it as JSON. ("Riiiiiiiiiight. What's acubit JSON?)" Next on my agenda, figuring out wtf this JSON thing is all about.
I'm trying to get the list of health monitors for a given pool, using "LocalLB.Pool.get_monitor_instance([pool])". The get_monitor_instance API reference page just says I get a string back. Which, I do, but in python-speak, I get what looks like a dictionary which includes other dictionaries embedded in a list embedded in a list. Like this:
[[{'enabled_state': True, 'instance': {'template_name': 'http', 'instance_definition': {'ipport': {'port': 80, 'address': '10.10.10.23'}, 'address_type': 'ATYPE_EXPLICIT_ADDRESS_EXPLICIT_PORT'}}, 'instance_state': 'INSTANCE_STATE_UP'}, {'enabled_state': True, 'instance': {'template_name': 'http', 'instance_definition': {'ipport': {'port': 80, 'address': '10.10.10.24'}, 'address_type': 'ATYPE_EXPLICIT_ADDRESS_EXPLICIT_PORT'}}, 'instance_state': 'INSTANCE_STATE_UP'}]]
ETA: based on the consensus, evidently by parsing it as JSON. ("Riiiiiiiiiight. What's a