PipelineFX Forum

Qube! => Developer Customization => Topic started by: methodhai on March 06, 2008, 04:58:03 AM

Title: Listing of groups and clusters
Post by: methodhai on March 06, 2008, 04:58:03 AM
Is it possible to retrieve the list of groups and clusters from the within the Python API?

Thanks,
Hai
Title: Re: Listing of groups and clusters
Post by: Scot Brew on March 06, 2008, 08:17:42 PM
Currently the way to do this is to gather the host information through qb.hostinfo() and then extract out the groups and clusters from there.  Here is some sample python to extract out the groups and cluster information using just the qb python module.

Clusters:
        clusters = [i['cluster'].strip() for i in qb.hostinfo()]
        clusters = [i for i in clusters if len(i) > 0]  # remove empty items
        clusters = list(set(clusters))                  # make sure unique

Groups:
        groups = []
        for i in qb.hostinfo():
            groups.extend(i['groups'].strip().split(','))
        groups = [i.strip() for i in groups if len(i) > 0]  # remove empty&whitespace
        groups = list(set(groups))                  # make sure unique
Title: Re: Listing of groups and clusters
Post by: methodhai on March 06, 2008, 08:23:53 PM
Excellent. Thanks Scot.
Title: Re: Listing of groups and clusters
Post by: Scot Brew on March 11, 2008, 04:47:09 AM
You're welcome Hai.