Forum Discussion
andy_12_5042
Nimbostratus
Mar 01, 2011iterate over return of get_session_status
I have no issues with creating something like this and then get at the value assigned to port or whatever:
>>> test =m.typefactory.create('Common.IPPortDefinition')
>>> test
(Common.IPPortDefinition){
address = None
port = None
}
>>> test.port=80
>>> test.port
80
>>> test
(Common.IPPortDefinition){
address = None
port = 80
}
However, what I cant seem to wrap my head around is this:
[[(LocalLB.PoolMember.MemberSessionStatus){
member =
(Common.IPPortDefinition){
address = "1.1.1.1"
port = 80
}
session_status = "SESSION_STATUS_ENABLED"
}]]
How would I iterate over a bunch of members like this and get just the address:port:session_status values. I know this has to be something simple but for some reason I just can quote get it. I was able to grab the session_status but not quite the right way.. Anyway thanks for any pointers...
2 Replies
- andy_12_5042
Nimbostratus
so I ended up doing something like this:
stats=m.get_session_status(['temp'])
for item in stats[0]:
... print item.member.address , item.member.port , item.session_status
1.1.1.1 80 SESSION_STATUS_ENABLED
Is that the correct way to get at this.. Well I guess the fact that it works kind of answers that. So, maybe better question is there a better way. I will worry about making it pretty later. (formatted or whatever) - L4L7_53191
Nimbostratus
That's the way to do it. One of the tricks with calls like this is that iControl allows you to query for an entire list of objects. So your get_session_status() call could actually contain a list like:
['temp', 'pool1','pool2','pool3'], in which case your stats list would have 4 nested lists of LocalLB.PoolMember.MemberSessionStatus objects. To get at that information, you'd have to iterate over that list, as you've discovered :)
-Matt
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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