easy_list
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
resource_type | str | 是 | 资源类型,目前仅允许列举”jobs”, “clusters”, “tasks”, “images”, “instances” |
*resource_info | tuple | 否 | 位置参数,包含列举资源需要提供的其他所有信息,如列举”instances”时需要提供job_id和task_name |
**filters | dict | 否 | 键值对参数,可以设置多个资源过滤条件 |
easy_list方法返回一个 list
对象,其中包含了 resource_type
中所有符合过滤条件的资源。
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 easy_list():
try:
# List all jobs which named "PythonSDK" and have a description of "test list job".
for job in client.easy_list("jobs", Name="PythonSDK", Description="test list job"):
print (job.Name, job.Id)
# List all jobs which named "PythonSDK" and have a description of "test list job".
# filters can be also unpacked from a dict.
job_filters = {
"Name": "PythonSDK",
"Description": "test list job"
}
for job in client.easy_list("jobs", **job_filters):
print (job.Name, job.Id)
# List all jobs whose state is "Waiting" or "Running".
# `filetrs` with a tuple value also available.
for job in client.easy_list('jobs', State=['Waiting', 'Running']):
print (job.Name, job.Id)
# List all jobs whose state is "Waiting" or "Running".
# `filters` with a function value defined by users.
state_filter = lambda state: state in ['Waiting', 'Running']
for job in client.easy_list('jobs', State=state_filter):
print (job.Name, job.Id)
# List all "Runing" tasks in a job.
job_id = 'job-xxx'
client.easy_list('tasks', job_id, State='Running')
# List all "Running" instances in a task.
job_id = 'job-xxx'
task_name = 'Echo'
client.easy_list('instances', job_id, task_name, State='Running')
except ClientError, e:
print (e.get_status_code(), e.get_code(), e.get_requestid(), e.get_msg())
if __name__ == '__main__':
easy_list()
当服务器中的磁盘发生故障、或者由于人为误操作导致服务器数据丢失时,可以使用...
操作场景 本文档介绍如何使用腾讯云容器服务(TKE)提供的基础镜像进行自定义镜...
作者 | 愈安 来源 | 阿里巴巴云原生公众号 2020 年双十一交易峰值达到 58.3 W 笔...
自力处事器租用是IDC市场上最贵的一种接入体例,他确保整个服务器只有一个客户在...
大数据时代和大数据分析时代已经来临。到2025年,全球数据领域估计将增长到175ZB...
云服务器的到来,加速了云计算时代的来临。传统物理服务器逐渐受到冷落,云服务...
本文比较并总结遍历数组的四种方式: for 循环: for(let index = 0 ;index some...
网站 域名 怎么备案?选用国内服务器空间搭 建网站 ,网站就需要进行备案。网站 ...
当我们在玩游戏时所追求的就是网速,网速越好我们娱乐就越带劲。如果慢速率的网...
调用ListTagResources查询指定资源已绑定的标签列表。 接口说明 请求中至少指定...