本文为您介绍火山引擎 E-MapReduce(EMR)Python SDK 的安装流程和查询集群(ListClusters)的样例代码。
需要安装Python 3 (>3.6)
可使用 pip 安装相应的安装包
pip install --user volcengine
{ "ak": "Your AK", "sk": "Your SK" }
# coding:utf-8 from __future__ import print_function import json from volcengine.emr.EMRService import EMRService if __name__ == '__main__': emr_service = EMRService(region="cn-beijing") # call the following methods explicitly if you dont set ak and sk in $HOME/.volc/config # emr_service.set_ak(testAk) # emr_service.set_sk(testSk) params = {} resp = emr_service.list_clusters(params) print(json.dumps(resp, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':')))
/Users/bytedance/volc-sdk-python-internal/volc-sdk-python/venv/bin/python /Users/bytedance/volc-sdk-python-internal/volc-sdk-python/volcengine/example/emr/example_list_clusters.py { "ResponseMetadata":{ "Action":"ListClusters", "Deprecated":false, "Error":null, "Region":"cn-beijing", "RequestId":"202211011500050102080162031C73E93B", "Service":"emr", "Version":"2021-09-15" }, "Result":{ "items":[ { "PublicIp":[ { "InstanceId":"i-ybzvtid8d0xxxxxxxx", "InstanceName":"emr-3xxd3o882ixxxxxxxx-master-1", "PublicIpAddress":"180.184.69.164" } ], "accountId":xxxxxxxx, "archived":false, "authorized":false, "buttonStatus":{ "cancelPay":"hidden", "clone":"visible", "modifyChargeType":"hidden", "payForCluster":"hidden", "reboot":"hidden", "release":"visible", "renew":"hidden", "scaleOut":"visible" }, "canModifyChargeType":true, "clusterTypeName":"Hadoop", "coralActivated":false, "coralHiveCollectionStatus":"INACTIVE", "createTime":"2022-10-17T17:59:18", "creatorId":xxxxxxxx, "creatorName":"EMR_Dev", "deployOption":"ECS", "ecsRole":"VEECSforEMRRole", "id":xxx, "instanceId":"emr-3xxd3o882ixxxxxxxx", "isFavorite":true, "krbStatus":"DISABLED", "launchTime":"2022-10-17T18:07:46", "name":"权限xxxxxxxx", "orderNumber":"Order7155416xxxxxxxx", "payType":"POST", "project":"default", "renewalStatus":"/", "status":"RUNNING", "tags":[], "type":"Hadoop", "updateTime":"2022-10-18T11:07:00", "version":"3.0.0" }, { "PublicIp":[ { "InstanceId":"i-yby7vmesxxxxxxxx", "InstanceName":"emr-3gmooxwp4xxxxxxxx-master-1", "PublicIpAddress":"180.184.96.243" } ], "accountId":210xxxxxxxx, "archived":false, "authorized":false, "buttonStatus":{ "cancelPay":"hidden", "clone":"visible", "modifyChargeType":"hidden", "payForCluster":"hidden", "reboot":"hidden", "release":"visible", "renew":"hidden", "scaleOut":"visible" }, "canModifyChargeType":true, "clusterTypeName":"Hadoop", "coralActivated":false, "coralHiveCollectionStatus":"INACTIVE", "createTime":"2022-09-24T16:56:43", "creatorId":21xxxxxxxx, "creatorName":"EMR_Dev", "deployOption":"ECS", "ecsRole":"VEECSforEMRRole", "id":xxx, "instanceId":"emr-3gmooxwpxxxxxxxx", "isFavorite":true, "krbStatus":"DISABLED", "launchTime":"2022-09-24T17:08:45", "name":"qa-xxxxxxxx", "orderNumber":"Order71468xxxxxxxx", "payType":"POST", "project":"default", "renewalStatus":"/", "status":"RUNNING", "tags":[], "type":"Hadoop", "updateTime":"2022-10-27T16:15:10", "version":"1.3.1" } ], "pageNum":0, "pageSize":10, "pages":1, "total":8 } } Process finished with exit code 0