GPU服务API文档
磁盘与云存储
扩容云盘

ResizeCompShareDisk — 扩容云盘

接口说明

扩容一块已有的云盘。仅支持扩容,不支持缩容。

使用限制

  • 云盘所在实例需处于 Stopped(已关机)状态。
  • 只能扩大容量,不能缩小。

请求参数

名称类型必填描述示例值
ActionString接口名称ResizeCompShareDisk
RegionString地域cn-wlcb
ZoneString可用区cn-wlcb-01
UDiskIdString云盘 IDudisk-xxxx
UHostIdString云盘所在实例 IDuhost-xxxx
SizeInteger目标磁盘大小,单位 GB。必须大于当前容量200

响应参数

名称类型描述示例值
ActionString响应名称ResizeCompShareDiskResponse
RetCodeInteger返回码,0 为成功0
UDiskIdString云盘 IDudisk-xxxx

请求示例

Python(使用 UCloud SDK)

from ucloud.core import exc
from ucloud.client import Client
 
 
def main():
    client = Client({
        "region": "cn-wlcb",
        "public_key": "my_public_key",    # 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取
        "private_key": "my_private_key",   # 替换为你的私钥
        "base_url": "https://api.compshare.cn",
    })
 
    try:
        resp = client.ucompshare().resize_comp_share_disk({
            "Zone": "cn-wlcb-01",
            "UDiskId": "udisk-xxxx",  # 云盘 ID,通过 DescribeCompShareInstance 的 DiskSet 获取
            "Size": 200,
        })
        print("扩容成功:", resp.get("UDiskId"))
    except exc.UCloudException as e:
        print(e)
 
 
if __name__ == "__main__":
    main()

Go(使用 UCloud SDK)

package main
 
import (
	"fmt"
 
	"github.com/ucloud/ucloud-sdk-go/services/ucompshare"
	"github.com/ucloud/ucloud-sdk-go/ucloud"
	"github.com/ucloud/ucloud-sdk-go/ucloud/auth"
)
 
func main() {
	cfg := ucloud.NewConfig()
	cfg.Region = "cn-wlcb"
	cfg.Zone = "cn-wlcb-01"
	cfg.BaseUrl = "https://api.compshare.cn"
 
	credential := auth.NewCredential()
	credential.PublicKey = "my_public_key"   // 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取
	credential.PrivateKey = "my_private_key" // 替换为你的私钥
	client := ucompshare.NewClient(&cfg, &credential)
 
	req := client.NewResizeCompShareDiskRequest()
	req.UDiskId = ucloud.String("udisk-xxxx") // 云盘 ID,通过 DescribeCompShareInstance 的 DiskSet 获取
	req.Size = ucloud.Int(200)
 
	resp, err := client.ResizeCompShareDisk(req)
	if err != nil {
		fmt.Printf("扩容失败: %s\n", err)
		return
	}
	fmt.Printf("扩容成功: %s\n", resp.UDiskId)
}

响应示例

{
  "Action": "ResizeCompShareDiskResponse",
  "RetCode": 0,
  "UDiskId": "udisk-xxxx"
}
Copyright © 2026 沪ICP备12020087号-61