SDK API文档

class mosclient.v1.client.Client(access, secret, url, format=None, timeout=300, debug=False, region='Beijing')

MCS API client (v1)

参数:
  • access (string) – 指定MOS API access key
  • secret (string) – 指定MOS API secret
  • url (string) – MOS API访问URL
  • format (string) – 指定返回数据格式xml或者json,缺省为xml
  • timeout (int) – 超时秒数,缺省为300秒
  • debug (bool) – 是否输出debug信息,缺省为False
AllocateAddress(name, billing_model='bandwidth', availability_zone_id=None)

分配浮动IP

参数:
  • name
  • billing_model – 代表计费方式,有效值:bandwidth,flow,分别代表按带宽和按流量计费。默认为bandwidth
  • availability_zone_id – 代表可用区ID, 通过DescribeAvailabilityZones接口获取
返回:

Address结构

AssociateAddress(allocation_id, association_type, instance_id, bandwidth)

将浮动IP绑定到其他云产品上

参数:
  • allocation_id – 浮动IP的ID(或者IP)
  • association_type – 绑定云产品类型。有效值为server、elb,分别代表绑定到云服务器和ELB负载均衡器
  • instance_id – 绑定的云产品ID
  • bandwidth – 绑定浮动IP的带宽限制
返回:

Address结构

AttachVolume(ebs_id, instance_id)

绑定EBS 到 实例

参数:
  • instance_id – 实例的ID
  • ebs_id – EBS的ID
返回:

请求是否成功

AuthorizeSecurityGroupIngress(gid, rules=None)

给一个安全组授权进入流量的规则(10条上限)

参数:
  • gid (string) – 安全组ID
  • rules – 入流量授权规则的列表

规则类型: string 规则格式: ACTION [IP] PROTOCAL [PORT]

ACTION: 必填,支持allow/deny IP: 选填,默认为0.0.0.0/0,可以是一个IP或一个网段,例如:192.168.0.1,192.168.0.0/16 PROTOCAL: 必填,支持tcp/udp/icmp/any PORT: 选填,如果是any或者是icmp,不必填;如果是tcp或udp,不填时默认为全部端口,填时为指定端口,如8000,

也支持设定范围,如20-25(注:范围包含的端口个数不能超过30)
示例:
‘deny tcp 2200’,’deny 192.168.0.0/16 tcp 80’,’allow 192.168.0.0/24 any’,’allow udp 21-22’
ChangeECSType(ecs_id, flavor)

更改ECS 配置 :param ecs_id: ECS ID :type ecs_id:string :param flavor: ECS 类型 :type flavor: string :return: return

ChangeInstanceType(iid, itype, duration=None, datadisk=None, bandwidth=None)

更改虚拟机类型

参数:
  • iid (string) – 虚拟机ID
  • itype (string) – 指定更改的虚拟机类型
  • duration (string) – 指定更改后的初始租期,缺省为‘1M’,即一个月
  • datadisk (int) – 指定创建虚拟机使用的额外数据盘,单位为GB
  • bandwidth (int) – 指定创建虚拟机使用的额外带宽,单位为Mbps
ChangeRDSType(rid, rtype, datadisk=None, duration=None)

更改RDS类型

参数:
  • rid (string) – RDS ID
  • rtype (string) – 指定更改的RDS类型ID,可通过DescribeRDSTypes方法查询
  • datadisk (int) – 指定更改的RDS数据盘大小,单位GB(可选)
  • duration (string) – 指定更改的RDS租期,单位:’H’(小时)、’M’(月),缺省为‘1M’,即一个月(可选)
ChangeRedisType(rid, memory, duration=None)

更改Redis类型

参数:
  • rid (string) – Redis ID
  • memory (int) – 指定更改的Redis内存大小,单位GB
  • duration (string) – 指定更改后的初始租期,缺省为‘1M’,即一个月
ConfigAddress(allocation_id, name=None)

配置浮动IP, 目前支持名称修改

参数:
  • allocation_id – 浮动IP的ID(或者IP)
  • name – 浮动IP的名称
返回:

Address结构

ConfigAddressBandwidth(allocation_id, bandwidth=None)

配置浮动IP带宽

参数:
  • allocation_id – 浮动IP的ID(或者IP)
  • bandwidth – 浮动IP的带宽
返回:

Address结构

ConfigListenerBackend(*args, **kwargs)

配置Listener Backend

参数:
  • backend_id (string) – Backend id
  • listener_id (string) – ELB listener id
  • weight (int) – Forwarding weight
  • port (int) – Forwarding port
返回:

Backend

ConfigLoadBalancerListener(*args, **kwargs)

配置指定的监听转发策略

参数:
  • listenser_id (string) – 转发调度策略的ID
  • name (string) – 监听转发策略名称
  • alg (string) – 有效值为wrr(加权轮询)、rr(轮询),转发调度策略
  • protocol (string) – 转发协议, 有效值TCP、HTTP、HTTPS
  • frontend_port (int) – 监听转发规则的对外服务端口
  • backend_port (int) – 监听转发规则到后端服务器池的端口
  • enablesessionsticky (boolean) – 是否打开会话保持
  • check_interval (int) – 健康检查时间间隔, 默认5
  • check_rise (int) – 连续健康检查成功多少次后,认为后端服务可用
  • check_fall (int) – 连续健康检查失败多少次后,认为后端服务不可用
  • check_timeout (int) – 健康检查超时时间, 默认3
  • domain (string) – 转发规则对应的域名
  • location (string) – 转发规则对应的URL location
  • cookie_name (string) – 指定七层会话保持的cookie名称
  • check_url (string) – 健康检查URL
  • session_mode (string) – 会话保持模式
  • session_timeout (int) – 会话保持超时时间
  • certificate_id (string) – Https类型转发对应的证书ID
返回:

创建成功的监听转发策略

CreateAliveAlarm(iid, description=None)

创建主机存活监控

参数:
  • iid (string) – 虚拟机ID
  • description (string) – 描述
返回:

请求是否成功

CreateBDSystem(name, architecture, slave_count, bds_type, zone, admin_pass, description=None)

创建Hadoop集群.

参数:
  • name (string) – 集群名称
  • architecture (string) – 集群架构类型,目前支持’single_master’
  • slave_count (int) – 集群规模
  • bds_type (string) – 集群选用的配置类型,通过DescribeBDSTypes查找
  • zone (string) – 可以为zone的name或者id
  • admin_pass (string) – 管理员密码
  • description (string) –
返回:

BigDataSystem结构

CreateDLImage(name, image_config, description=None)

创建DLImage.

CreateDLJob(project_id, name, hardware_mode, distributed, job_type, auto_start=True, code_source=None, with_tensorboard=False, node_num=None, gpu_num=None, code_main_file=None, data_dir=None, ckpt_dir=None, output_dir=None, cmdline_args=None, tensorboard_log_dir=None, notice_uid=None, distribute_file=None, description=None, image_id=None, **kwargs)

创建DLJob.

参数:
  • name (string) – Job名称
  • description (string) –
返回:

DLJob结构

CreateDLProject(name, description=None)

创建DLProject.

参数:
  • name (string) – 集群名称
  • description (string) –
返回:

DLProject结构

CreateECS(name, flavor, driver, master_count=1, zone=None)

创建ECS :param name: ECS Name :type name:string :param flavor: ECS 类型 :type flavor: string :param driver: ECS driver :type driver: string :param master_count: 主节点数 :type master_count: int :param zone: 分区 ID or Name :type zone: string :return: ECS结构列表

CreateECSNode(ecs_id, count)

创建ECS Node :param ecs_id: ECS ID :type ecs_id:string :return: ECS结构列表

CreateInstance(imageid, itype, duration=None, name=None, keypair=None, secgroup=None, datadisk=None, bandwidth=None, zone=None, nets=None)

创建虚拟机

参数:
  • imageid (string) – 系统模板ID
  • itype (string) – 虚拟机类型ID
  • duration (string) – 虚拟机租期, 缺省为‘1M’,即一个月
  • name (string) – 虚拟机名称(可选)
  • keypair (string) – 虚拟机使用的SSH密钥ID
  • secgroup (string) – 安全组ID
  • datadisk (int) – 指定创建虚拟机使用的额外数据盘,单位为GB
  • bandwidth (int) – 指定创建虚拟机使用的额外带宽,单位为Mbps
  • zone (string) – 指定创建虚拟机所在的数据中心, 可通过DescribeAvailabilityZones接口获取
  • vpcsubnetid (string) – 指定虚拟专有网络中的子网
  • vpcsubnetip (string) – 指定子网的情况下,可自定义IP(必须在子网IP范围内)
返回:

创建成功的虚拟机信息

CreateLoadBalancer(*args, **kwargs)

创建ELB

参数:
  • name (string) – ELB名称
  • allocation_id (string) – EIP 浮动IP的AllocationId
  • bandwidth (int) – 指定创建虚拟机使用的额外带宽,单位为Mbps
  • zone (string) – 指定创建虚拟机所在的数据中心, 可通过DescribeAvailabilityZones接口获取
返回:

创建成功的ELB信息

CreateLoadBalancerListener(*args, **kwargs)

创建ELB 监听转发策略

参数:
  • name (string) – 监听转发策略名称
  • alg (string) – 有效值为wrr(加权轮询)、rr(轮询),转发调度策略
  • protocol (string) – 转发协议, 有效值TCP、HTTP、HTTPS
  • frontend_port (int) – 监听转发规则的对外服务端口
  • backend_port (int) – 监听转发规则到后端服务器池的端口
  • enablesessionsticky (boolean) – 是否打开会话保持
  • elb_id (string) – ELB实例的ID
  • check_interval (int) – 健康检查时间间隔, 默认5
  • check_rise (int) – 连续健康检查成功多少次后,认为后端服务可用
  • check_fall (int) – 连续健康检查失败多少次后,认为后端服务不可用
  • check_timeout (int) – 健康检查超时时间, 默认3
  • domain (string) – 转发规则对应的域名
  • location (string) – 转发规则对应的URL location
  • cookie_name (string) – 指定七层会话保持的cookie名称
  • check_url (string) – 健康检查URL
  • session_mode (string) – 会话保持模式
  • session_timeout (int) – 会话保持超时时间
  • certificate_id (string) – Https类型转发对应的证书ID
返回:

创建成功的监听转发策略

CreateMetricAlarm(iid, metric, operator, threshold, description=None)

创建指标监控

参数:
  • iid (string) – 虚拟机ID
  • metric (string) – 监控指标名称
  • operator (string) – 判断操作符
  • threshold (string) – 监控阈值
  • description (string) – 描述
返回:

请求是否成功

CreateRDS(rtype, datadisk, engine, username, password, name, zone, duration=None, **param)

创建RDS

参数:
  • rtype (string) – RDS类型ID,可通过DescribeRDSTypes方法查询
  • datadisk (int) – RDS使用的数据盘大小,单位为GB
  • engine (string) – RDS的引擎名称,可通过DescribeRDSEngines方法查询
  • username (string) – RDS的用户名
  • password (string) – RDS的用户密码
  • name (string) – RDS的名称
  • zone (string) – 可用区,可通过DescribeAvailabilityZones方法查询
  • duration (string) – RDS租期,单位:’H’(小时)、’M’(月),缺省为‘1M’,即一个月(可选)
返回:

创建成功的RDS信息

CreateRDSAlarm(rid, metric, operator, threshold, description=None)

创建RDS指标监控

参数:
  • rid (string) – RDS的ID
  • metric (string) – 监控指标名称
  • operator (string) – 判断操作符
  • threshold (string) – 监控阈值
  • description (string) – 描述
返回:

请求是否成功

CreateRDSNode(rds_id, role, count)

创建RDS Node :param rds_id: ECS ID :type rds_id:string :return: ECS结构列表

CreateRedis(memory, duration=None, name=None, zone=None)

创建Redis

参数:
  • memory (int) – Redis的内存大小(GB)
  • duration (string) – Redis租期, 缺省为‘1M’,即一个月
  • name (string) – Redis名称(可选)
  • zone (string) – 可用区,可通过DescribeAvailabilityZones方法查询(可选)
返回:

创建成功的Redis信息

CreateRedisAlarm(rid, metric, operator, threshold, description=None)

创建Redis指标监控

参数:
  • rid (string) – Redis的ID
  • metric (string) – 监控指标名称
  • operator (string) – 判断操作符
  • threshold (string) – 监控阈值
  • description (string) – 描述
返回:

请求是否成功

CreateSDSystem(name, architecture, slave_count, bds_type, zone, admin_pass, description=None)

创建实时计算集群.

参数:
  • name (string) – 集群名称
  • architecture (string) – 集群架构,目前支持’single_master’
  • slave_count (int) – 集群规模数量
  • bds_type (string) – 集群选用的配置类型,通过DescribeSDSTypes查找
  • zone (string) – 可以为zone的name或者id
  • admin_pass (string) – 管理员密码
  • description (string) –
返回:

StreamingSystem结构

CreateSecurityGroup(name, desc)

创建安全组

参数:
  • name (string) – 安全组名称
  • desc (string) – 安全组描述
CreateServerGroup(name, zone=None)

创建分组 :param name: 分组 Name :type name:string :param zone: 分区 ID or Name :type zone: string :return: ServerGroup结构列表

CreateTCPAlarm(iid, port, description=None)

创建TCP监控

参数:
  • iid (string) – 虚拟机ID
  • port (int) – tcp端口
  • description (string) – 描述
返回:

请求是否成功

CreateTemplate(iid, name, notes=None)

保存虚拟机的模板

参数:
  • iid (string) – 虚拟机ID
  • name (string) – 模板名称
  • notes (string) – 保存模板的说明
返回:

请求是否成功

CreateVPC(name, cidr, desc=None)

新建VPC

参数:
  • name (string) – VPC名称
  • cidr (string) – 选择网段,choose from ‘10.0.0.0/8’, ‘172.16.0.0/12’, ‘192.168.0.0/16’
  • desc (string) – 描述
返回:

VPC实例

CreateVPCSubnet(name, vpcid, zoneid, startip, endip, netmask, gateway, desc=None)

创建子网

参数:
  • name (string) – VPC名称
  • vpcid (string) – VPC ID
  • zoneid (string) – 可用区ID
  • startip (string) – 子网起始IP
  • endip (string) – 子网结束IP
  • netmask (string) – 子网掩码
  • desc (string) – 描述
返回:

子网实例

CreateVolume(name, disksize, zone=None)

创建EBS

参数:
  • name (string) – EBS 的name
  • disksize (string) – EBS 的大小 单位G
  • zone (string) – 可用区,可通过DescribeAvailabilityZones方法查询(可选)
返回:

Volume, 包含Volume结构列表

CreateVolumeSnapshot(name, ebs_id)

创建EBS快照

参数:
  • name – 快照的名称
  • ebs_id – EBS的ID
返回:

请求是否成功

DeleteAliveAlarm(mid)

删除主机存活监控

参数:mid (string) – 监控项ID
返回:请求是否成功
DeleteBDSystem(idstr)

删除集群.

参数:idstr (string) – 集群ID
返回:
DeleteCDSNode(node_id)

删除CDS Node :param node_id: Node ID :type node_id:string :return: ECS结构列表

DeleteDLImage(idstr)

删除DLImage.

参数:idstr (string) – DLImageID
返回:
DeleteDLJob(idstr)

删除DLJob.

参数:idstr (string) – DLJobID
返回:
DeleteDLProject(idstr)

删除DLProject.

参数:idstr (string) – DLProjectID
返回:
DeleteECS(ecs_id)

删除ECS :param ecs_id: ECS ID :type ecs_id:string :return: ECS结构列表

DeleteKeyPair(kid)

删除一个SSH密钥对

参数:kid (string) – 密钥对ID
DeleteLoadBalancer(elb_id)

删除ELB

参数:elb_id (string) – ELB id
返回:请求是否成功
DeleteLoadBalancerListener(listener_id)

删除ELB Listener

参数:listener_id (string) – ELB listener id
返回:请求是否成功
DeleteMetricAlarm(mid)

删除一个指标监控项

参数:mid (string) – 监控项ID
返回:请求是否成功
DeleteRDSAlarm(mid)

删除一个RDS指标监控项

参数:mid (string) – 监控项ID
返回:请求是否成功
DeleteRedisAlarm(mid)

删除一个Redis指标监控项

参数:mid (string) – 监控项ID
返回:请求是否成功
DeleteSDSystem(idstr)

删除集群.

参数:idstr (string) – 集群ID
返回:
DeleteSecurityGroup(gid)

删除一个安全组

参数:gid (string) – 安全组ID
DeleteTCPAlarm(mid)

删除TCP监控

参数:mid (string) – 监控项ID
返回:请求是否成功
DeleteTemplate(tid)

删除一个模板

参数:tid (string) – 模板ID
DeleteVPC(vid)

删除VPC

参数:vpc_id (string) – VPC ID
返回:请求是否成功
DeleteVPCSubnet(subnetid)

删除子网 :param subnetid: 子网ID :type subnetid: string :return: 请求是否成功

DeleteVolume(ebs_id)

删除EBS

参数:ebs_id – EBS的ID
返回:请求是否成功
DeleteVolumeSnapshot(ebs_snapshot_id)

删除EBS快照

参数:ebs_snapshot_id – EBS快照的ID
返回:请求是否成功
DeregisterBackendWithListener(id)

删除指定的后端

参数:id (string) – listener backend id
返回:请求是否成功
DescribeAddresses(allocation_ids=None, limit=0, offset=0, filters=None, zone=None)

返回所有或者部分浮动IP列表信息列表

参数:
  • allocation_ids (list) – 希望获取的Address ID列表
  • limit (int) – 返回的数量限制,用于分页控制
  • offset (int) – 返回的偏移量,用于分页控制
  • filters (dict) – 过滤器,一个dict,包含过滤字段名和值
返回:

AddressSet, 包含Address列表

DescribeAlarmHistory(limit=0, offset=0, filters=None)

查看监控告警历史

参数:
  • limit (int) – 最大返回数量,用于分页控制
  • offset (int) – 返回偏移量,用于分页控制
返回:

AlarmHistorySet,监控告警历史列表

DescribeAliveAlarms()

查看主机存活监控

返回:AliveAlarmSet,包含主机存货监控列表
DescribeAvailabilityZones(limit=0, offset=0, filters=None)

获取Zone(可用区)

参数:
  • limit (int) – 返回Zone数量的上限(可选)
  • offset (int) – 返回Zone数量的偏移量,用于分页显示(可选)
  • filters (dict) – 过滤条件,key/value分别指定过滤字段名称和值,支持的字段名称为:name,status(可选)
返回:

AvailabilityZoneSet,包含系统支持的Zone列表

DescribeBDSTypes(limit=0, offset=0, filters=None)

获取所有BigDataSystem(简称BDS)类型.

参数:
  • limit (int) – 最大返回数量(可选)
  • offset (int) – 返回BDS类型的偏移量,用于分页显示(可选)
  • filters (dict) – 过滤条件,key/value分别指定过滤字段名称和值,支持的字段名称为:name,status(可选)
返回:

BDSTypeSet,包含系统支持的BDS类型列表

DescribeBDSystems(ids=None, names=None, zone=None, filters=None, limit=10, offset=0, order_by='id', order='asc')

获取所有Hadoop集群集群列表信息.

参数:
  • ids (list) – 期望获取的BigDataSystemID列表
  • names (list) – 期望获取信息的BigDataSystem名称列表
  • zone (string) – 指定创建BigDataSystem所在的数据中心名称
  • limit (int) – 最多返回数量
  • offset (int) – 返回BigDataSystem的偏移量,用于分页显示
  • filters (dict) – 过滤器,一个dict,包含过滤字段名和值,可能过滤字段为:name, status
  • order_by (string) – 排序字段
  • order (string) – 值只能为’desc’(升序)或者’asc’(降序)
返回:

BigDataSystemSet,包含BigDataSystem列表

DescribeDLImages(ids=None, names=None, filters=None, limit=10, offset=0, order_by='id', order='asc')

获取深度学习Docker镜像列表信息.

参数:
  • ids (list) – 期望获取的DLImageID列表
  • names (list) – 期望获取信息的DLImage名称列表
  • limit (int) – 最多返回数量
  • offset (int) – 返回DLImage的偏移量,用于分页显示
  • filters (dict) – 过滤器,一个dict,包含过滤字段名和值,可能过滤字段为:name, status
  • order_by (string) – 排序字段
  • order (string) – 值只能为’desc’(升序)或者’asc’(降序)
返回:

DLImageSet,包含DLImage列表

DescribeDLJobs(project_id, ids=None, names=None, filters=None, limit=10, offset=0, order_by='id', order='asc')

获取某个项目里深度学习任务列表信息.

参数:
  • ids (list) – 期望获取的DLJobID列表
  • names (list) – 期望获取信息的DLJob名称列表
  • limit (int) – 最多返回数量
  • offset (int) – 返回DLJob的偏移量,用于分页显示
  • filters (dict) – 过滤器,一个dict,包含过滤字段名和值,可能过滤字段为:name, status
  • order_by (string) – 排序字段
  • order (string) – 值只能为’desc’(升序)或者’asc’(降序)
返回:

DLJobSet,包含DLJob列表

DescribeDLProjects(ids=None, names=None, filters=None, limit=10, offset=0, order_by='id', order='asc')

获取深度学习项目列表信息.

参数:
  • ids (list) – 期望获取的DLProjectID列表
  • names (list) – 期望获取信息的DLProject名称列表
  • limit (int) – 最多返回数量
  • offset (int) – 返回DLProject的偏移量,用于分页显示
  • filters (dict) – 过滤器,一个dict,包含过滤字段名和值,可能过滤字段为:name, status
  • order_by (string) – 排序字段
  • order (string) – 值只能为’desc’(升序)或者’asc’(降序)
返回:

DLProjectSet,包含DLProject列表

DescribeECS(ecs_ids=None, zone=None, limit=None, offset=None, filters=None)

获取EBS实例列表 :param ecs_ids: ECS ID列表 :type ecs_ids: list :param limit: :type limit: int :param offset: :type offset: int :param filters: :type filters: dict :returns: ECSSet, 包含ECS结构列表

DescribeECSNode(ecs, limit=None, offset=None, filters=None)

ECS Node 列表 :param ecs_id: ECS ID :type ecs_id:string :param limit: :type limit: int :param offset: :type offset: int :param filters: :type filters: dict :return: ECS结构列表

DescribeInstanceMetrics(iid=None)

查看虚拟机监控项

参数:iid (string) – 虚拟机ID
返回:MetricSet,包含监控项列表
DescribeInstanceNetworkInterfaces(iid, limit=0, offset=0, filters=None)

获取指定虚拟机的网络接口(虚拟网卡)信息

参数:
  • iid (string) – 虚拟机ID
  • limit (int) – 最大返回数量,用于分页控制
  • offset (int) – 返回的偏移量,用于分页控制
  • filters – 返回结果过滤条件,由dict的key/value指定过滤字段名和值
返回:

InstanceNetworkInterfaceSet,包含虚拟机网络接口列表

DescribeInstanceStatus(iid)

获取虚拟机的状态

参数:iid (string) – 虚拟机ID
返回:虚拟机状态字符串
DescribeInstanceTypes(limit=0, offset=0, filters=None)

获取所有虚拟机类型

参数:
  • limit (int) – 最大返回数量,用于分页控制
  • offset (int) – 返回偏移量,用于分页控制
  • filters (dict) – 过滤条件,key/value分别指定过滤字段名称和值,支持的字段名称为:name, status
返回:

InstanceTypeSet,包含系统支持的虚拟机类型列表

DescribeInstanceVolumes(iid, limit=0, offset=0, filters=None)

获取指定虚拟机的虚拟磁盘信息

参数:
  • iid (string) – 虚拟机ID
  • limit (int) – 最大返回数量,用于分页控制
  • offset (int) – 返回的偏移量,用于分页控制
  • filters – 返回结果过滤条件,由dict的key/value指定过滤字段名和值
返回:

InstanceVolumeSet,包含虚拟机磁盘列表

DescribeInstances(ids=None, names=None, limit=0, offset=0, filters=None, group=None, zone=None)

获得所有虚拟机

参数:
  • ids (list) – 期望获取的虚拟机ID列表
  • names (list) – 期望获取信息的虚拟机名称列表
  • group (string) – 分组名称 or ID
  • zone (string) – 指定创建虚拟机所在的数据中心, 可通过DescribeAvailabilityZones接口获取
  • limit (int) – 最多返回数量
  • offset (int) – 返回虚拟机的偏移量,用于分页显示
  • filters (dict) – 过滤器,一个dict,包含过滤字段名和值,可能过滤字段为:name, status
返回:

InstanceSet,包含虚拟机列表

DescribeKeyPairs(limit=0, offset=0, filters=None)

获取用户的SSH密钥对

参数:
  • limit (int) – 最大返回数量,用于分页控制
  • offset (int) – 返回偏移量,用于分页控制
  • filters (dict) – 过滤条件,key/value分别指定过滤字段名称和值,支持的字段名称为:name
返回:

KeyPairSet, 包含SSH密钥对列表

DescribeListenerBackends(*args, **kwargs)

获取一个Listener对应的一组或全部后端转发

参数:
  • listener_id (string) – Listener ID
  • ids (list) – 期望获取的Listener列表
  • limit (int) – 最多返回数量
  • offset (int) – 返回Backend的偏移量,用于分页显示
  • filters (dict) – 过滤器,一个dict,包含过滤字段名和值,可能过滤字段为:name, status
返回:

BackendSet

DescribeLoadBalancerListeners(*args, **kwargs)

获取指定或全部监听转发策略列表

参数:
  • ids (list) – 期望获取的Listener列表
  • limit (int) – 最多返回数量
  • offset (int) – 返回Listener的偏移量,用于分页显示
  • filters (dict) – 过滤器,一个dict,包含过滤字段名和值,可能过滤字段为:name, status
返回:

ListenerSet

DescribeLoadBalancers(*args, **kwargs)

获得所有ELB

参数:
  • ids (list) – 期望获取的ELB ID列表
  • limit (int) – 最多返回数量
  • offset (int) – 返回虚拟机的偏移量,用于分页显示
  • filters (dict) – 过滤器,一个dict,包含过滤字段名和值,可能过滤字段为:name, status
  • zone (string) – 指定创建虚拟机所在的数据中心, 可通过DescribeAvailabilityZones接口获取
返回:

LoadBalancerSet,包含ELB列表

DescribeMetricAlarms()

查看指标监控

返回:MetricAlarmSet,指标监控列表
DescribeRDS(ids=None, names=None, limit=0, offset=0, filters=None, zone=None)

获取所有RDS

参数:
  • ids (list) – 期望获取的RDS ID列表(可选)
  • names (list) – 期望获取的RDS名称列表(可选)
  • limit (int) – 最多返回数量(可选)
  • offset (int) – 返回RDS的偏移量,用于分页显示(可选)
  • filters (dict) – 过滤条件,key/value分别指定过滤字段名称和值,支持的字段名称为:name,status(可选)
返回:

RDSSet, 包含RDS列表

DescribeRDSAlarms()

查看RDS指标监控

返回:MetricAlarmSet,指标监控列表
DescribeRDSEngines()

获取所有RDS引擎

返回:RDSEngineSet,包含系统支持的RDS引擎列表
DescribeRDSMetrics(rid=None)

查看RDS监控项

参数:rid (string) – RDS ID
返回:MetricSet,包含监控项列表
DescribeRDSNode(rds, limit=None, offset=None, filters=None)

RDS Node 列表 :param rds: RDS ID :type rds:string :param limit: :type limit: int :param offset: :type offset: int :param filters: :type filters: dict :return: ECS结构列表

DescribeRDSTypes(limit=0, offset=0, filters=None)

获取所有RDS类型

参数:
  • limit (int) – 最大返回数量(可选)
  • offset (int) – 返回RDS类型的偏移量,用于分页显示(可选)
  • filters (dict) – 过滤条件,key/value分别指定过滤字段名称和值,支持的字段名称为:name,status(可选)
返回:

RDSTypeSet,包含系统支持的RDS类型列表

DescribeRedis(ids=None, names=None, limit=0, offset=0, filters=None)

获得所有Redis

参数:
  • ids (list) – 期望获取的RedisID列表
  • names (list) – 期望获取信息的Redis名称列表
  • limit (int) – 最多返回数量
  • offset (int) – 返回Redis的偏移量,用于分页显示
  • filters (dict) – 过滤器,一个dict,包含过滤字段名和值,可能过滤字段为:name, status
返回:

RedisSet,包含Redis列表

DescribeRedisAlarms()

查看Redis指标监控

返回:MetricAlarmSet,指标监控列表
DescribeRedisMetrics(rid=None)

查看Redis监控项

参数:rid (string) – Redis ID
返回:MetricSet,包含监控项列表
DescribeSDSTypes(limit=0, offset=0, filters=None)

获取所有StreamingSystem(简称SDS)类型.

参数:
  • limit (int) – 最大返回数量(可选)
  • offset (int) – 返回SDS类型的偏移量,用于分页显示(可选)
  • filters (dict) – 过滤条件,key/value分别指定过滤字段名称和值,支持的字段名称为:name,status(可选)
返回:

SDSTypeSet,包含系统支持的SDS类型列表

DescribeSDSystems(ids=None, names=None, zone=None, filters=None, limit=10, offset=0, order_by='id', order='asc')

获取实时计算集群列表信息.

参数:
  • ids (list) – 期望获取的StreamingSystemID列表
  • names (list) – 期望获取信息的StreamingSystem名称列表
  • zone (string) – 指定创建StreamingSystem所在的数据中心
  • limit (int) – 最多返回数量
  • offset (int) – 返回StreamingSystem的偏移量,用于分页显示
  • filters (dict) – 过滤器,一个dict,包含过滤字段名和值,可能过滤字段为:name, status
  • order_by (string) – 排序字段
  • order (string) – 值只能为’desc’(升序)或者’asc’(降序)
返回:

StreamingSystemSet,包含StreamingSystem列表

DescribeSecurityGroups(ids=None, names=None, limit=0, offset=0, filters=None)

获取安全组信息

参数:
  • ids (list) – 期望获取的安全组ID列表
  • names (list) – 期望获取的安全组名称列表
  • limit (int) – 最多返回数量
  • offset (int) – 返回虚拟机的偏移量,用于分页显示
  • filters (dict) – 过滤器,一个dict,包含过滤字段名和值
DescribeServerByGroup(group=None, zone=None, limit=0, offset=0, filters=None)

分组内机器资源列表 :param group: 分组 名称 or ID :type grop: string :return: GroupGuestSet, 包含GroupGuest结构列表

DescribeServerGroup(servergroup_ids=None, zone=None, limit=0, offset=0, filters=None)

获取分组列表 :param servergroup_ids: 分组 ID列表 :type servergroup_ids: list :param limit: :type limit: int :param offset: :type offset: int :param filters: :type filters: dict :return: ServerGroupSet, 包含ServerGroup结构列表

DescribeTCPAlarms()

查看TCP监控

返回:返回TCPAlarmSet,包含TCP监控列表
DescribeTemplates()

获得所有虚拟机模板

返回:模板列表
DescribeVPCSubnets(subnets_ids=None, limit=0, offset=0, filters=None, zone=None)

返回所有或部分子网信息列表 :param subnets_ids: 子网ID列表 :type subnets_ids: list :param limit: 返回数量 :type limit: string :param offset: 偏移 :type offset: string :param filters: 过滤条件 :type filters: dict :param zone: 可用区 :type zone: string :return: 子网实例集合

DescribeVPCs(vids=None, limit=0, offset=0, filters=None, zone=None)

返回所有或部分VPC信息列表 :param vids: VPC ID列表 :type vids: string :param limit: 返回数量 :type limit: string :param offset: 偏移 :type offset: string :param filters: 过滤条件 :type filters: dict :param zone: 可用区 :type zone: string :return: VPC实例集合

DescribeVolumeSnapshots(ebs_snapshot_ids=None, zone=None, limit=0, offset=0, filters=None)

获取EBS快照实例列表 :param ebs_snapshot_ids: EBS ID列表 :type ebs_snapshot_ids: list :param limit: :type limit: int :param offset: :type offset: int :param filters: :type filters: dict :return: VolumeSnapshotSet, 包含VolumeSnapshot结构列表

DescribeVolumes(ebs_ids=None, zone=None, limit=0, offset=0, filters=None)

获取EBS实例列表 :param ebs_ids: EBS ID列表 :type ebs_ids: list :param limit: :type limit: int :param offset: :type offset: int :param filters: :type filters: dict :returns: VolumeSet, 包含Volume结构列表

DetachVolume(ebs_id, instance_id)

卸载EBS

参数:ebs_id – EBS的ID
返回:请求是否成功
DisableAliveAlarm(mid)

禁用一个主机存活监控项

参数:mid (string) – 监控项ID
返回:请求是否成功
DisableMetricAlarm(mid)

禁用一个指标监控项

参数:mid (string) – 监控项ID
返回:请求是否成功
DisableRDSAlarm(mid)

禁用一个RDS指标监控项

参数:mid (string) – 监控项ID
返回:请求是否成功
DisableRedisAlarm(mid)

禁用一个Redis指标监控项

参数:mid (string) – 监控项ID
返回:请求是否成功
DisableTCPAlarm(mid)

禁用一个TCP监控项

参数:mid (string) – 监控项ID
返回:请求是否成功
DisassociateAddress(allocation_id)

将浮动IP解绑

参数:allocation_id – 浮动IP的ID(或者IP)
返回:请求是否成功
EnableAliveAlarm(mid)

启用一个主机存活监控项

参数:mid (string) – 监控项ID
返回:请求是否成功
EnableMetricAlarm(mid)

启用一个指标监控项

参数:mid (string) – 监控项ID
返回:请求是否成功
EnableRDSAlarm(mid)

启用一个RDS指标监控项

参数:mid (string) – 监控项ID
返回:请求是否成功
EnableRedisAlarm(mid)

启用一个Redis指标监控项

参数:mid (string) – 监控项ID
返回:请求是否成功
EnableTCPAlarm(mid)

启用一个TCP监控项

参数:mid (string) – 监控项ID
返回:请求是否成功
GetBalance()

获取帐户余额

返回:帐户余额和最近更新时间
GetInstanceContractInfo(iid)

获取虚拟机的租期信息

参数:iid (string) – 虚拟机ID
返回:虚拟机租期信息,包含过期时间、自动删除时间
GetInstanceMetadata(iid)

获取虚拟机的metadata

参数:iid (string) – 虚拟机ID
返回:一个dict包含虚拟机所有metadata的key/value
GetPasswordData(iid, key_file=None)

获取虚拟机的Login帐户信息

参数:
  • iid (string) – 虚拟机ID
  • key_file (string) – 私钥文件路径,路过虚拟机使用了SSH密钥,需要指定私钥解密password
返回:

虚拟机Login信息,包含帐户名称、密码,如果使用SSH密钥,则还包含密钥ID和名称

GetRDSContractInfo(rid)

获取RDS的租期信息

参数:rid (string) – RDS ID
返回:RDS租期信息,包含过期时间、自动删除时间
GetRedisContractInfo(rid)

获取Redis的租期信息

参数:rid (string) – Redis ID
返回:Redis租期信息,包含过期时间、自动删除时间
ImportKeyPair(name, pubkey)

导入一个用户的SSH公钥,并创建一个SSH密钥对

参数:
  • name (string) – 密钥对名称
  • pubkey (string) – SSH公钥信息
返回:

创建的SSH密钥对信息

InstanceAssignSecurityGroup(iid, gid)

给一个虚拟机分配安全组

参数:
  • iid (string) – 虚拟机ID
  • gid (string) – 安全组ID
InstanceRevokeSecurityGroup(iid)

撤销一个虚拟机的安全组

参数:iid (string) – 虚拟机ID
ListVPCSubnets(vpc_id, limit=0, offset=0, filters=None)

列出VPC下所有子网列表

参数:
  • vpc_id (string) – VPC ID
  • limit (string) – 返回数量
  • offset (string) – 偏移
  • filters (dict) – 过滤条件
返回:

子网实例集合

ModifyLoadBalancerAttributes(*args, **kwargs)

配置负载均衡 ELB 实例信息 :param elb_id: ELB id :type elb_id: string :param name: ELB name :type name: string :param allocation_id: EIP 浮动IP的AllocationId或者IP :type allocation_id: string :param bandwidth: 指定创建虚拟机使用的额外带宽,单位为Mbps :type bandwidth: int

返回:LoadBalancer
PutInstanceMetadata(iid, data)

修改虚拟机的metadata

参数:
  • iid (string) – 虚拟机ID
  • data (dict) – 需要增加或修改的metadata信息
RebootInstance(iid)

重启虚拟机

参数:iid (string) – 虚拟机ID
RebuildInstanceRootImage(iid, image_id=None)

重置虚拟机系统磁盘

参数:
  • iid (string) – 虚拟机ID
  • image_id (string) – 将虚拟机系统磁盘用指定镜像模板重置,如果无该参数,则使用原镜像模板重置
RecoverVolume(ebs_snapshot_id)

用快照恢复EBS

参数:ebs_snapshot_id – EBS快照的ID
返回:请求是否成功
RegisterBackendWithListener(*args, **kwargs)

给 Listener 添加后端转发

参数:
  • listener_id (string) – ELB listener id
  • server_id (string) – Server id
  • name (string) – Server customize name
  • weight (int) – Forwarding weight
  • port (int) – Forwarding port
返回:

Backend

ReleaseAddress(allocation_id)

释放浮动IP

参数:allocation_id – 浮动IP的ID(或者IP)
返回:请求是否成功
ReleaseServerGroup(group)

删除分组 :param group: 分组 名称 or ID :type grop: string :return: return

RenewInstance(iid, duration=None)

虚拟机租期续费

参数:
  • iid (string) – 虚拟机ID
  • duration (string) – 续费租期,缺省为‘1M’,即一个月
RenewRDS(rid, duration=None)

RDS租期续费

参数:
  • rid (string) – RDS ID
  • duration (string) – 续费周期,单位:’H’(小时)、’M’(月),缺省为‘1M’,即一个月(可选)
RenewRedis(rid, duration=None)

Redis租期续费

参数:
  • rid (string) – Redis ID
  • duration (string) – 续费租期,缺省为‘1M’,即一个月
ReplaceAddress(allocation_id, new_allocation_id, sync=False, timeout=300)

将浮动IP换绑

参数:
  • allocation_id – 浮动IP的ID(或者IP)
  • new_allocation_id – 新的浮动IP的ID(或者IP)
返回:

Address结构

RestartRDS(rid)

重启RDS

参数:rid (string) – RDS ID
RevokeSecurityGroupIngress(gid, rules=None)

从一个安全组中撤销进入流量的规则(指定撤销的规则必须和之前授权的规则完全匹配)

参数:
  • gid (string) – 安全组ID
  • rules (list) – 需要撤销的入流量规则的列表

规则类型: string 规则格式: 见AuthorizeSecurityGroupIngress

ScaleDownBDSystem(idstr, delta)

减容集群.

参数:
  • idstr (string) – 集群ID
  • delta (int) – 减容的nodes数量
返回:

ScaleDownSDSystem(idstr, delta)

减容集群.

参数:
  • idstr (string) – 集群ID
  • delta (int) – 减容的nodes数量
返回:

ScaleUpBDSystem(idstr, delta)

扩容集群.

参数:
  • idstr (string) – 集群ID
  • delta (int) – 扩容的nodes数量
返回:

ScaleUpSDSystem(idstr, delta)

扩容集群.

参数:
  • idstr (string) – 集群ID
  • delta (int) – 扩容的nodes数量
返回:

SearchAssociatedAddresses(ids=None, names=None)

获得所有虚拟机的浮动IP绑定情况

参数:
  • ids (list) – 期望获取的虚拟机ID列表
  • names (list) – 期望获取信息的虚拟机名称列表
返回:

InstanceEipInfoSet,包含虚拟机eip绑定数量列表

ServerJoinGroup(group, instance_id, tag=None)

添加实例到指定分组 :param group: 分组 名称 or ID :type grop: string :param instance_id: InstanceId 对应的实例资源 :type instance_id: string :return: GroupGuest结构列表

ServerLeaveGroup(group, instance_id)

将实例从分组里面移除 :param group: 分组 名称 or ID :type grop: string :param instance_id: InstanceId 对应的实例资源 :type instance_id: string :return: return

StartBDSystem(idstr)

启动集群.

参数:idstr (string) – 集群ID
返回:
StartInstance(iid)

启动虚拟机

参数:iid (string) – 虚拟机ID
StartRDS(rid)

启动RDS

参数:rid (string) – RDS ID
StartSDSystem(idstr)

启动集群.

参数:idstr (string) – 集群ID
返回:
StopBDSystem(idstr)

暂停集群.

参数:idstr (string) – 集群ID
返回:
StopDLJob(idstr)

线束任务.

参数:idstr (string) – 任务ID
返回:
StopInstance(iid, force=False)

停止虚拟机

参数:
  • iid (string) – 虚拟机ID
  • force – 是否强制停止虚拟机
StopRDS(rid, force=False)

停止RDS

参数:
  • rid (string) – RDS ID
  • force – 是否强制停止RDS
StopSDSystem(idstr)

暂停集群.

参数:idstr (string) – 集群ID
返回:
SubmitDLJob(idstr)

提交任务.

参数:idstr (string) – 任务ID
返回:
TerminateInstance(iid)

删除虚拟机

参数:iid (string) – 虚拟机ID
TerminateRDS(rid)

删除RDS

参数:rid (string) – RDS ID
TerminateRedis(rid)

删除Redis

参数:rid (string) – Redis ID
UpdateDLImage(idstr, name=None, image_config=None, desc=None)

更新DLImage.

UpdateDLJob(id, name=None, hardware_mode=None, distributed=None, job_type=None, code_source=None, with_tensorboard=None, auto_start=None, node_num=None, gpu_num=None, code_main_file=None, data_dir=None, ckpt_dir=None, output_dir=None, cmdline_args=None, tensorboard_log_dir=None, notice_uid=None, distribute_file=None, desc=None, image_id=None, **kwargs)

更新DLJob.

参数:
  • name (string) – Job名称
  • desc (string) –
返回:

DLJob结构

UpdateDLProject(idstr, name, desc=None)

更新DLProject.

参数:idstr (string) – DLProjectID
返回:
UpdateVPC(vid, name, desc=None)

更新VPC

参数:
  • vpc_id (string) – VPC ID
  • name (string) – VPC名称
  • desc (string) – VPC描述
返回:

返回VPC实例

UpdateVPCSubnet(subnetid, name, desc=None)

更新子网

参数:
  • subnetid (string) – 子网ID
  • name (string) – 名称
  • desc (string) – 描述
返回:

子网实例