全部产品
Search
文档中心

:获取集群信息

更新时间:Feb 01, 2023

接口

get_cluster

参数

参数 类型 是否必须 描述
cluster string 集群标识符

返回值

get_cluster方法将返回一个GetResponse 对象。

例子

Python 源码:

e.g.

import time
import batchcompute
from batchcompute import CN_SHENZHEN as REGION
from batchcompute import Client, ClientError

ACCESS_KEY_ID = 'Your Access Key Id'
ACCESS_KEY_SECRET = 'Your Access Key Secret'

client = Client(REGION, ACCESS_KEY_ID, ACCESS_KEY_SECRET)

def get_cluster():
    try:
        cluster_id = "cls-xxx"
        rsp = client.get_cluster(cluster_id)
        print (rsp.Name, rsp.State)
    except ClientError, e:
        print (e.get_status_code(), e.get_code(), e.get_requestid(), e.get_msg())

if __name__ == '__main__':
    get_cluster()

执行结果:

(u'test-cluster', u'Active')