0

我想打印我帐户中可用的所有分析引擎实例。

我可以使用以下方式打印所有可用的组织和空间:

! pip install --quiet --upgrade git+https://github.com/snowch/ibm-analytics-engine-python@master

然后

from ibm_analytics_engine import CloudFoundryAPI, CloudFoundryAPI
from ibm_analytics_engine import IAE, IAEServicePlanGuid, IAEClusterSpecificationExamples

cf = CloudFoundryAPI(api_key_filename='api_key.json')
iae = IAE(cf_client=cf)
cf.print_orgs_and_spaces()

输出:

-------------------------------------------------------------------------
Org: me@me.com                       12345-12345-12345678910
> Spc: dev                           12345-12345-12345678912
> Spc: test                          12345-12345-12345678913

-------------------------------------------------------------------------
Org: them@them.com                   aaaaa-bbbbb-ccccccccccc
> Spc: dev                           aaaaa-bbbbb-ccccccccccd
...

我怎样才能列出这些空间中的集群?

4

1 回答 1

0

你可以这样做:

! pip install --quiet --upgrade git+https://github.com/snowch/ibm-analytics-engine-python@master

然后

from ibm_analytics_engine import CloudFoundryAPI, CloudFoundryAPI
from ibm_analytics_engine import IAE, IAEServicePlanGuid, IAEClusterSpecificationExamples

cf = CloudFoundryAPI(api_key_filename='api_key.json')
iae = IAE(cf_client=cf)

import pprint
pp = pprint.PrettyPrinter(indent=4)

for org in cf.orgs_and_spaces():
    for space in org['spaces']:
        print('ORG {} | SPACE {}'.format(org['name'], space['name']))
        print()

        clusters = iae.clusters(space_guid=space['guid'])
        if len(clusters) > 0:
            for cluster in clusters:
                pp.pprint(cluster)
                print()

输出:

ORG me@me.com | SPACE dev

{   'guid': 'abcd-abcd-abcdefghi',
    'name': 'Analytics Engine',
    'state': 'succeeded'}

ORG me@me.com | SPACE test

....
于 2017-12-14T15:29:27.557 回答