CreateInstances

1. 接口描述

调用本接口用于创建一个或多个指定配置的实例。

准备工作

注意事项

  • 实例创建成功后将自动开机启动,实例状态变为RUNNING(运行中)。

  • 预付费实例的购买会预先扣除本次实例购买所需金额,如果余额不足,请求将会失败。后付费实例购买时需要确保账户账号状态正常。

  • 调用本接口创建实例,支持代金券自动抵扣,详情请参考代金券选用规则。

  • 本接口为异步接口,当创建实例请求下发成功后会返回一个实例ID列表,此时创建实例操作并未立即完成。在此期间实例的状态将会处于PENDINGCREATING,实例创建结果可以通过调用DescribeInstances 接口查询,如果实例状态(instanceStatus)由CREATING(创建中)或PENDING(等待创建)变为RUNNING(运行中),则代表实例创建成功,CREATE_FAILED代表实例创建失败,创建过程中不可对实例进行任何操作。

  • 单次最多能创建100台实例。

2. 请求参数

以下请求参数列表仅列出了接口中需要的请求参数

3. 响应结果

4. 代码示例

1. 用最简单的参数创建一台后付费的实例 在Seoul A创建一台后付费实例,规格为M6C,其带宽计费为固定带宽,密码随机生成,不安装任何镜像,带宽大小为默认的1Mbps。

POST /api/v2/bmc HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateInstances
<Common Request Params>

Request:
{
    "instanceChargeType": "POSTPAID",
    "instanceTypeId": "M6C",
    "internetChargeType": "ByBandwidth",
    "zoneId": "SEL-A"
}

Response:
{
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "response": {
        "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
        "instanceIdSet": ["instanceId1"],
        "orderNumber" : "orderNumber1"
    }
}

2. 创建2台预付费的实例 ****在Seoul A 创建2台预付费付费实例,规格为M6C,两台实例的名称分别为:SEL-M6C-01, SEL-M6C-02, 密码Password-12345~,镜像ID: 5ace1756-2230-4d1d-8fc6-84f1897ef397,指定了公网和内网网卡名称wan0和lan0, 带宽计费为固定带宽,带宽大小为10Mbps。

POST /api/v2/bmc HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateInstances
<Common Request Params>

Request:
{
    "instanceChargeType": "PREPAID",
    "amount": 2, 
    "instanceChargePrepaid":{
        "period": 2
    },
    "instanceName": "SEL-M6C-[1,2]",
    "hostname": "SEL-M6C-[1,2]",
    "internetMaxBandwidthOut": 10,
    "password": "Password-12345~",
    "nic": {
        "wanName": "wan0",
        "lanName": "lan0"
    },
    "instanceTypeId": "M6C",
    "internetChargeType": "ByBandwidth",
    "zoneId": "SEL-A", 
    "imageId": "5ace1756-2230-4d1d-8fc6-84f1897ef397"
}

Response:
{
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D4",
    "response": {
        "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D4",
        "instanceIdSet": ["instanceId3", "instanceId4"],
        "orderNumber" : "orderNumber2"
    }
}

3. 创建2台预付费的实例,其网络计费方式为流量包 ****和2类似, 不同的是本次创建的网络计费方式是流量包, 其流量包大小为 10TB。

POST /api/v2/bmc HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateInstances
<Common Request Params>

Request:
{
    "instanceChargeType": "PREPAID",
    "amount": 2, 
    "instanceChargePrepaid":{
        "period": 2
    },
    "instanceName": "SEL-M6C-[1,2]",
    "hostname": "SEL-M6C-[1,2]",
    "internetMaxBandwidthOut": 10,
    "password": "Password-12345~",
    "nic": {
        "wanName": "wan0",
        "lanName": "lan0"
    },
    "instanceTypeId": "M6C",
    "internetChargeType": "ByBandwidth",
    "zoneId": "SEL-A", 
    "imageId": "5ace1756-2230-4d1d-8fc6-84f1897ef397",
    "trafficPackageSize": 10 
}

Response:
{
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D4",
    "response": {
        "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D4",
        "instanceIdSet": ["instanceId5", "instanceId6"],
        "orderNumber" : "orderNumber3"
    }
}

5. 开发者工具

Zenlayer Cloud API 2.0 提供了配套的开发工具集(SDK),未来会陆续支持更多开发语言,方便快速接入和使用Zenlayer的产品和服务。

6. 错误码

下面包含业务逻辑中遇到的错误码,其他错误码见公共错误码

最后更新于