Forum Discussion
Dec 07, 2010
Smart way to convert a PoolMemberDefinitionSequenceSequence to a IPPortDefinitionSequenceSequence
Hi,
I want to dump out (and eventually read in and set) the enabled state of each of my GTM pools pool members. Its easy to get a list of the pools and pool members, but the PoolMember.get_en...
L4L7_53191
Dec 09, 2010Nimbostratus
Ok - this should get you close. My brain is a bit fried so there are probably more optimizations available. Note that I added the little stub class just for some sane data structures that we can access via attributes. This is probably slower than other methods, but to me it's cleaner...
wipobj = b.GlobalLB.WideIP
poolobj = b.GlobalLB.Pool
poolmemobj = b.GlobalLB.PoolMember
wideips = wipobj.get_list()
pools = poolobj.get_list()
poolmembers = poolobj.get_member(pools)
class DataHolder():
''' A dummy class to set attrs against for ease of reading '''
def __init__(self, tup):
self.pool = tup[0]
self.members = self.clean_members(tup)
self.member_states = []
def clean_members(self, tup):
return [x.member for x in tup[1]]
combined = zip(pools,poolmembers)
data_list = []
print out pool name, and its members.
for x in combined:
data_list.append(DataHolder(x))
print "Pool: %s" % x[0]
print "\t Mems:"
for y in x[1]:
print "\t=>%s:%s" % (y.member.address,y.member.port)
Now, we've got the IPPort definitions already defined, per pool
found inside the data_list[idx].members attribute. We can pass that array
into a Commoon.IPPortSequence.items[] array and get the status.
pmemseq = poolmemobj.typefactory.create('Common.IPPortDefinitionSequence')
pmemseq.item = [x.members for x in [y for y in data_list]]
member_status = poolmemobj.get_enabled_state(pool_names = [x.pool for x in data_list], members = [pmemseq])
Once you nail down a final version, would you mind posting it back?
Thanks!
-Matt
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