如何列出我有权访问的所有Analytics Engine实例?

问题描述 投票:0回答:1

我想在我的帐户中打印我可以使用的所有Analytics Engine实例。

我可以打印我可用的所有组织和空间:

! 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: [email protected]                       12345-12345-12345678910
> Spc: dev                           12345-12345-12345678912
> Spc: test                          12345-12345-12345678913

-------------------------------------------------------------------------
Org: [email protected]                   aaaaa-bbbbb-ccccccccccc
> Spc: dev                           aaaaa-bbbbb-ccccccccccd
...

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

ibm-cloud analytics-engine analytics-engine-python-sdk
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 [email protected] | SPACE dev

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

ORG [email protected] | SPACE test

....
© www.soinside.com 2019 - 2024. All rights reserved.