rmd: (wtfdog)
[personal profile] rmd
So, 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:

[[{'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'}]]


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 a cubit JSON?)" Next on my agenda, figuring out wtf this JSON thing is all about.

Date: 2015-04-16 02:41 am (UTC)
From: [identity profile] rmd.livejournal.com
Thanks!

"BANDWIDTH IS PRECIOUS! WE MUST BE AS INFORMATION-DENSE AS POSSIBLE!"
"We have ALL THE BANDWIDTH! BE VERBOSE!"
"Seriously, gang? Fuck that. Let's be reasonable, here."

Profile

rmd: (Default)
rmd

June 2025

S M T W T F S
1234567
89 1011121314
15161718192021
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 19th, 2026 11:03 pm
Powered by Dreamwidth Studios