Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 67 additions & 56 deletions ucloud/services/uhost/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def create_uhost_instance(
- **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 <https://docs.ucloud.cn/api/summary/get_project_list>`_
- **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 <https://docs.ucloud.cn/api/summary/regionlist>`_
- **ImageId** (str) - (Required) 镜像ID。 请通过 `DescribeImage <https://docs.ucloud.cn/api/uhost-api/describe_image.html>`_ 获取
- **LoginMode** (str) - (Required) 主机登陆模式。密码(默认选项): Password,密钥:KeyPair。
- **LoginMode** (str) - (Required) 主机登陆模式。密码(默认选项): Password,密钥:KeyPair,Password,自制镜像密码:ImagePasswd
- **Zone** (str) - (Required) 可用区。参见 `可用区列表 <https://docs.ucloud.cn/api/summary/regionlist>`_
- **AlarmTemplateId** (int) - 告警模板id,如果传了告警模板id,且告警模板id正确,则绑定告警模板。绑定告警模板失败不会影响创建主机流程。
- **AutoDataDiskInit** (str) - 数据盘是否需要自动分区挂载。当镜像支持“Cloud-init”Feature时可填写此字段。取值 >“On” 自动挂载(默认值)> “Off” 不自动挂载。
Expand All @@ -179,11 +179,12 @@ def create_uhost_instance(
- **Disks** (list) - 见 **CreateUHostInstanceParamDisks** 模型定义
- **Features** (dict) - 见 **CreateUHostInstanceParamFeatures** 模型定义
- **GPU** (int) - GPU卡核心数。仅GPU机型支持此字段(可选范围与MachineType+GpuType相关)
- **GpuType** (str) - GPU类型,枚举值["K80", "P40", "V100", "T4","T4A", "T4S","2080Ti","2080Ti-4C","1080Ti", "T4/4", "V100S",2080","2080TiS","2080TiPro","3090","4090","4090Pro","A100","A800"]。MachineType为G时必填
- **GpuType** (str) - GPU类型,枚举值["K80", "P40", "V100", "T4","T4A", "T4S","2080Ti","2080Ti-4C","1080Ti", "T4/4", "V100S",2080","2080TiS","2080TiPro","3090","4090","4090Pro","4090_48G","A100","A800","H20"]。MachineType为G时必填
- **HostBinding** (bool) - 【私有专区属性】专区云主机开启宿住关联属性
- **HotplugFeature** (bool) - 热升级特性。True为开启,False为未开启,默认False。
- **IsolationGroup** (str) - 硬件隔离组id。可通过DescribeIsolationGroup获取。
- **KeyPairId** (str) - KeypairId 密钥对ID,LoginMode为KeyPair时此项必须。
- **Labels** (list) - 见 **CreateUHostInstanceParamLabels** 模型定义
- **MachineType** (str) - 云主机机型(V2.0),在本字段和字段UHostType中,仅需要其中1个字段即可。枚举值["N", "C", "G", "O", "OM", "OMEM", "OPRO", "OPROG"]。参考 `云主机机型说明 <https://docs.ucloud.cn/api/uhost-api/uhost_type>`_ 。
- **MaxCount** (int) - 本次最大创建主机数量,取值范围是[1,100],默认值为1。- 库存数量不足时,按库存数量创建。- 配额不足时,返回错误。- 使用隔离组时,以隔离组可用数量为准。
- **Memory** (int) - 内存大小。单位:MB。范围 :[1024, 262144],取值为1024的倍数(可选范围参考控制台)。默认值:8192
Expand Down Expand Up @@ -213,43 +214,40 @@ def create_uhost_instance(

**Request Model**

**CreateUHostInstanceParamSecGroupId**
- **Id** (str) - 安全组 ID。至多可以同时绑定5个安全组。
- **Priority** (int) - 安全组优先级。取值范围[1, 5]


**CreateUHostInstanceParamFeatures**
- **UNI** (bool) - 弹性网卡特性。开启了弹性网卡权限位,此特性才生效,默认 false 未开启,true 开启。


**CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSH**
- **Area** (str) -
- **AreaCode** (str) -
- **Port** (int) -


**CreateUHostInstanceParamNetworkInterfaceEIP**
- **Bandwidth** (int) - 【若绑定EIP,此参数必填】弹性IP的外网带宽, 单位为Mbps. 共享带宽模式下非必传, 非共享带宽模式必须指定非0Mbps带宽. 各地域非共享带宽的带宽范围如下: 流量计费[1-300],带宽计费[1-800]
- **CouponId** (str) - 当前EIP代金券id。请通过DescribeCoupon接口查询,或登录用户中心查看。
- **OperatorName** (str) - 【若绑定EIP,此参数必填】弹性IP的线路。枚举值: 国际: International BGP: Bgp 各地域允许的线路参数如下: cn-sh1: Bgp cn-sh2: Bgp cn-gd: Bgp cn-bj1: Bgp cn-bj2: Bgp hk: International us-ca: International th-bkk: International kr-seoul:International us-ws:International ge-fra:International sg:International tw-kh:International.其他海外线路均为 International
- **PayMode** (str) - 弹性IP的计费模式. 枚举值: "Traffic", 流量计费; "Bandwidth", 带宽计费; "ShareBandwidth",共享带宽模式. "Free":免费带宽模式,默认为 "Bandwidth"
- **ShareBandwidthId** (str) - 绑定的共享带宽Id,仅当PayMode为ShareBandwidth时有效
**CreateUHostInstanceParamLabels**
- **Key** (str) - 用户资源标签的键值
- **Value** (str) - 用户资源标签的值


**CreateUHostInstanceParamNetworkInterfaceIPv6**
**CreateUHostInstanceParamVolumes**


**CreateUHostInstanceParamNetworkInterface**
- **CreateCernetIp** (bool) - 申请并绑定一个教育网EIP。True为申请并绑定,False为不会申请绑定,默认False。当前只支持具有HPC特性的机型。
- **EIP** (dict) - 见 **CreateUHostInstanceParamNetworkInterfaceEIP** 模型定义
**CreateUHostInstanceParamSecGroupId**
- **Id** (str) - 安全组 ID。至多可以同时绑定5个安全组。
- **Priority** (int) - 安全组优先级。取值范围[1, 5]


**CreateUHostInstanceParamFeatures**
- **UNI** (bool) - 弹性网卡特性。开启了弹性网卡权限位,此特性才生效,默认 false 未开启,true 开启。


**CreateUHostInstanceParamDisksCustomBackup**
- **Day** (str) - Disks.N.BackupMode为"Custom"时,进行设置, 以5天级为基础进行倍数扩增,如5、10、15、20、25、30。
- **Hour** (str) - Disks.N.BackupMode为"Custom"时,进行设置, 以24小时级为基础进行倍数扩增,如24、48、72、96。
- **Journal** (str) - Disks.N.BackupMode为"Custom"时,进行设置, 以12小时秒级为基础进行倍数扩增,如12、24、36、48。


**CreateUHostInstanceParamDisks**
- **BackupMode** (str) - 指定快照备份策略。当Disks.N.BackupType为"SNAPSHOT"时此参数生效。枚举值:"Base":标准版,"Ultimate":旗舰版,"Custom":自定义备份链;默认值:"Base"。
- **BackupType** (str) - 磁盘备份方案。枚举值:\\ > NONE,无备份 \\ > SNAPSHOT,快照 \\当前磁盘支持的备份模式参考 `磁盘类型 <https://docs.ucloud.cn/api/uhost-api/disk_type>`_ ,默认值:NONE
- **CouponId** (str) - 云盘代金券id。不适用于系统盘/本地盘。请通过DescribeCoupon接口查询,或登录用户中心查看
- **CustomBackup** (dict) - 见 **CreateUHostInstanceParamDisksCustomBackup** 模型定义
- **Encrypted** (bool) - 【功能仅部分可用区开放,详询技术支持】磁盘是否加密。加密:true, 不加密: false加密必须传入对应的的KmsKeyId,默认值false
- **IsBoot** (str) - 是否是系统盘。枚举值:\\ > True,是系统盘 \\ > False,是数据盘(默认)。Disks数组中有且只能有一块盘是系统盘。
- **KmsKeyId** (str) - 【功能仅部分可用区开放,详询技术支持】kms key id。选择加密盘时必填。
Expand All @@ -258,7 +256,20 @@ def create_uhost_instance(
- **Type** (str) - 磁盘类型。请参考 `磁盘类型 <https://docs.ucloud.cn/api/uhost-api/disk_type>`_ 。


**CreateUHostInstanceParamVolumes**
**CreateUHostInstanceParamNetworkInterfaceEIP**
- **Bandwidth** (int) - 【若绑定EIP,此参数必填】弹性IP的外网带宽, 单位为Mbps. 共享带宽模式下非必传, 非共享带宽模式必须指定非0Mbps带宽. 各地域非共享带宽的带宽范围如下: 流量计费[1-300],带宽计费[1-800]
- **CouponId** (str) - 当前EIP代金券id。请通过DescribeCoupon接口查询,或登录用户中心查看。
- **OperatorName** (str) - 【若绑定EIP,此参数必填】弹性IP的线路。枚举值: 国际: International BGP: Bgp 各地域允许的线路参数如下: cn-sh1: Bgp cn-sh2: Bgp cn-gd: Bgp cn-bj1: Bgp cn-bj2: Bgp hk: International us-ca: International th-bkk: International kr-seoul:International us-ws:International ge-fra:International sg:International tw-kh:International.其他海外线路均为 International
- **PayMode** (str) - 弹性IP的计费模式. 枚举值: "Traffic", 流量计费; "Bandwidth", 带宽计费; "ShareBandwidth",共享带宽模式. "Free":免费带宽模式,默认为 "Bandwidth"
- **ShareBandwidthId** (str) - 绑定的共享带宽Id,仅当PayMode为ShareBandwidth时有效


**CreateUHostInstanceParamNetworkInterfaceIPv6**


**CreateUHostInstanceParamNetworkInterface**
- **CreateCernetIp** (bool) - 申请并绑定一个教育网EIP。True为申请并绑定,False为不会申请绑定,默认False。当前只支持具有HPC特性的机型。
- **EIP** (dict) - 见 **CreateUHostInstanceParamNetworkInterfaceEIP** 模型定义


"""
Expand Down Expand Up @@ -391,29 +402,15 @@ def describe_available_instance_types(

**Response Model**

**Performance**
- **Rate** (int) - 交互展示参数,可忽略
- **Value** (float) - 值,单位是TFlops


**BootDiskInfo**
- **Features** (list) - 磁盘可支持的服务
- **InstantResize** (bool) - 系统盘是否允许扩容,如果是本地盘,则不允许扩容,InstantResize为false。
- **MaximalSize** (int) - MaximalSize为磁盘最大值
- **Name** (str) - 系统盘类别,包含普通云盘|CLOUD_NORMAL、SSD云盘|CLOUD_SSD和RSSD云盘|CLOUD_RSSD。普通本地盘只包含普通本地盘|LOCAL_NORMAL一种。SSD本地盘只包含SSD本地盘|LOCAL_SSD一种。


**DataDiskInfo**
- **Features** (list) - 数据盘可支持的服务
- **MaximalSize** (int) - MaximalSize为磁盘最大值
- **MinimalSize** (int) - 磁盘最小值,如果没有该字段,最小值取基础镜像Size值即可(linux为20G,windows为40G)。
- **Name** (str) - 数据盘类别,包含普通云盘|CLOUD_NORMAL、SSD云盘|CLOUD_SSD和RSSD云盘|CLOUD_RSSD。普通本地盘只包含普通本地盘|LOCAL_NORMAL一种。SSD本地盘只包含SSD本地盘|LOCAL_SSD一种。
**Collection**
- **Cpu** (int) - CPU规格
- **Memory** (list) - 内存规格
- **MinimalCpuPlatform** (list) - CPU和内存规格只能在列出来的CPU平台支持


**Disks**
- **BootDisk** (list) - 见 **BootDiskInfo** 模型定义
- **DataDisk** (list) - 见 **DataDiskInfo** 模型定义
- **Name** (str) - 磁盘介质类别信息,磁盘主要分类如下:云盘|cloudDisk、普通本地盘|normalLocalDisk和SSD本地盘|ssdLocalDisk。
**MachineSizes**
- **Collection** (list) - 见 **Collection** 模型定义
- **Gpu** (int) - Gpu为GPU可支持的规格即GPU颗数,非GPU机型,Gpu为0


**CpuPlatforms**
Expand All @@ -427,15 +424,18 @@ def describe_available_instance_types(
- **Value** (int) - 值,单位是GB


**Collection**
- **Cpu** (int) - CPU规格
- **Memory** (list) - 内存规格
- **MinimalCpuPlatform** (list) - CPU和内存规格只能在列出来的CPU平台支持
**BootDiskInfo**
- **Features** (list) - 磁盘可支持的服务
- **InstantResize** (bool) - 系统盘是否允许扩容,如果是本地盘,则不允许扩容,InstantResize为false。
- **MaximalSize** (int) - MaximalSize为磁盘最大值
- **Name** (str) - 系统盘类别,包含普通云盘|CLOUD_NORMAL、SSD云盘|CLOUD_SSD和RSSD云盘|CLOUD_RSSD。普通本地盘只包含普通本地盘|LOCAL_NORMAL一种。SSD本地盘只包含SSD本地盘|LOCAL_SSD一种。


**MachineSizes**
- **Collection** (list) - 见 **Collection** 模型定义
- **Gpu** (int) - Gpu为GPU可支持的规格即GPU颗数,非GPU机型,Gpu为0
**DataDiskInfo**
- **Features** (list) - 数据盘可支持的服务
- **MaximalSize** (int) - MaximalSize为磁盘最大值
- **MinimalSize** (int) - 磁盘最小值,如果没有该字段,最小值取基础镜像Size值即可(linux为20G,windows为40G)。
- **Name** (str) - 数据盘类别,包含普通云盘|CLOUD_NORMAL、SSD云盘|CLOUD_SSD和RSSD云盘|CLOUD_RSSD。普通本地盘只包含普通本地盘|LOCAL_NORMAL一种。SSD本地盘只包含SSD本地盘|LOCAL_SSD一种。


**FeatureModes**
Expand All @@ -449,6 +449,17 @@ def describe_available_instance_types(
- **Name** (str) - 可支持的特性名称。目前支持的特性网络增强|NetCapability、热升级|Hotplug


**Performance**
- **Rate** (int) - 交互展示参数,可忽略
- **Value** (float) - 值,单位是TFlops


**Disks**
- **BootDisk** (list) - 见 **BootDiskInfo** 模型定义
- **DataDisk** (list) - 见 **DataDiskInfo** 模型定义
- **Name** (str) - 磁盘介质类别信息,磁盘主要分类如下:云盘|cloudDisk、普通本地盘|normalLocalDisk和SSD本地盘|ssdLocalDisk。


**AvailableInstanceTypes**
- **CpuPlatforms** (dict) - 见 **CpuPlatforms** 模型定义
- **Description** (str) - 机型描述
Expand Down Expand Up @@ -618,6 +629,12 @@ def describe_uhost_instance(

**Response Model**

**UDSetUDHostAttribute**
- **HostBinding** (bool) - 是否绑定私有专区宿主机
- **UDHostId** (str) - 私有专区宿主机
- **UDSetId** (str) - 私有专区


**UHostKeyPair**
- **KeyPairId** (str) - 密钥对ID
- **KeyPairState** (str) - 主机密钥对状态,Normal 正常,Deleted 删除
Expand Down Expand Up @@ -653,12 +670,6 @@ def describe_uhost_instance(
- **RecycleTime** (int) - 回收时间


**UDSetUDHostAttribute**
- **HostBinding** (bool) - 是否绑定私有专区宿主机
- **UDHostId** (str) - 私有专区宿主机
- **UDSetId** (str) - 私有专区


**UHostInstanceSet**
- **AutoRenew** (str) - 是否自动续费,自动续费:“Yes”,不自动续费:“No”
- **BasicImageId** (str) - 基础镜像ID(指当前自定义镜像的来源镜像)
Expand Down
90 changes: 54 additions & 36 deletions ucloud/services/uhost/schemas/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,33 @@ class CreateIsolationGroupResponseSchema(schema.ResponseSchema):
"""


class CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSHSchema(
schema.RequestSchema
):
"""CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSH -"""

fields = {
"Area": fields.Str(required=False, dump_to="Area"),
"AreaCode": fields.Str(required=False, dump_to="AreaCode"),
"Port": fields.Int(required=False, dump_to="Port"),
}


class CreateUHostInstanceParamLabelsSchema(schema.RequestSchema):
"""CreateUHostInstanceParamLabels -"""

fields = {
"Key": fields.Str(required=False, dump_to="Key"),
"Value": fields.Str(required=False, dump_to="Value"),
}


class CreateUHostInstanceParamVolumesSchema(schema.RequestSchema):
"""CreateUHostInstanceParamVolumes -"""

fields = {}


class CreateUHostInstanceParamSecGroupIdSchema(schema.RequestSchema):
"""CreateUHostInstanceParamSecGroupId -"""

Expand All @@ -159,15 +186,32 @@ class CreateUHostInstanceParamFeaturesSchema(schema.RequestSchema):
}


class CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSHSchema(
schema.RequestSchema
):
"""CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSH -"""
class CreateUHostInstanceParamDisksCustomBackupSchema(schema.RequestSchema):
"""CreateUHostInstanceParamDisksCustomBackup -"""

fields = {
"Area": fields.Str(required=False, dump_to="Area"),
"AreaCode": fields.Str(required=False, dump_to="AreaCode"),
"Port": fields.Int(required=False, dump_to="Port"),
"Day": fields.Str(required=False, dump_to="Day"),
"Hour": fields.Str(required=False, dump_to="Hour"),
"Journal": fields.Str(required=False, dump_to="Journal"),
}


class CreateUHostInstanceParamDisksSchema(schema.RequestSchema):
"""CreateUHostInstanceParamDisks -"""

fields = {
"BackupMode": fields.Str(required=False, dump_to="BackupMode"),
"BackupType": fields.Str(required=False, dump_to="BackupType"),
"CouponId": fields.Str(required=False, dump_to="CouponId"),
"CustomBackup": CreateUHostInstanceParamDisksCustomBackupSchema(
required=False, dump_to="CustomBackup"
),
"Encrypted": fields.Bool(required=False, dump_to="Encrypted"),
"IsBoot": fields.Str(required=True, dump_to="IsBoot"),
"KmsKeyId": fields.Str(required=False, dump_to="KmsKeyId"),
"Size": fields.Int(required=True, dump_to="Size"),
"SnapshotId": fields.Str(required=False, dump_to="SnapshotId"),
"Type": fields.Str(required=True, dump_to="Type"),
}


Expand All @@ -192,8 +236,8 @@ class CreateUHostInstanceParamNetworkInterfaceIPv6Schema(schema.RequestSchema):
"""CreateUHostInstanceParamNetworkInterfaceIPv6 -"""

fields = {
"Adress": fields.Str(
required=False, dump_to="Adress"
"Address": fields.Str(
required=False, dump_to="Address"
), # Deprecated, will be removed at 1.0
"ShareBandwidthId": fields.Str(
required=False, dump_to="ShareBandwidthId"
Expand All @@ -215,33 +259,6 @@ class CreateUHostInstanceParamNetworkInterfaceSchema(schema.RequestSchema):
}


class CreateUHostInstanceParamDisksCustomBackupSchema(schema.RequestSchema):
"""CreateUHostInstanceParamDisksCustomBackup -"""

fields = {}


class CreateUHostInstanceParamDisksSchema(schema.RequestSchema):
"""CreateUHostInstanceParamDisks -"""

fields = {
"BackupType": fields.Str(required=False, dump_to="BackupType"),
"CouponId": fields.Str(required=False, dump_to="CouponId"),
"Encrypted": fields.Bool(required=False, dump_to="Encrypted"),
"IsBoot": fields.Str(required=True, dump_to="IsBoot"),
"KmsKeyId": fields.Str(required=False, dump_to="KmsKeyId"),
"Size": fields.Int(required=True, dump_to="Size"),
"SnapshotId": fields.Str(required=False, dump_to="SnapshotId"),
"Type": fields.Str(required=True, dump_to="Type"),
}


class CreateUHostInstanceParamVolumesSchema(schema.RequestSchema):
"""CreateUHostInstanceParamVolumes -"""

fields = {}


class CreateUHostInstanceRequestSchema(schema.RequestSchema):
"""CreateUHostInstance - 创建UHost实例。"""

Expand Down Expand Up @@ -290,6 +307,7 @@ class CreateUHostInstanceRequestSchema(schema.RequestSchema):
required=False, dump_to="KeyPair"
), # Deprecated, will be removed at 1.0
"KeyPairId": fields.Str(required=False, dump_to="KeyPairId"),
"Labels": fields.List(CreateUHostInstanceParamLabelsSchema()),
"LoginMode": fields.Str(required=True, dump_to="LoginMode"),
"MachineType": fields.Str(required=False, dump_to="MachineType"),
"MaxCount": fields.Int(required=False, dump_to="MaxCount"),
Expand Down
Loading