百度智能云

All Product Document

          Cloud Compute Service

          Create an Instance(By the specified instance package)

          [](BCC/API Reference/Appendix.md#StorageType)Precondition

          Creating an instance requires the real name authentication. Anyone who does not pass the real name authentication can go to the [Personal Authentication](#UserGuide/Identity Verification/Individual Identity Verification.md) or [Enterprise Authentication](#UserGuide/Identity Verification/Enterprise Identity Verification.md) under the security authentication in the Baidu AI Cloud official website console for the authentication.

          BCC instance

          • Considerations for billing:

            • To create a postpaid instance, the account cash balance and the general voucher must be greater than 100 CNY. To create a prepaid instance, the account cash balance must be greater than or equal to the instance cost.
            • When you create the public IP with specified bandwidth, the billing mode is bill-by-bandwidth.
          • Considerations for instance:

            • By spec field, you can specify a vm type to be created. By a specification list API for an instance package, you can view an available instance package and its prices.
            • You can not purchase both GPU card and FPGA card for the same instance. When you purchase an instance with GPU card or FPGA card, you must specify the number of GPU cards or FPGA cards for the virtual machine to purchase through cardCount.
          • Considerations for storage:

            • When creating instances, you can specify a system disk size, of [40, 500]Gb in range. You can also specify disk type. For details, see [StorageType](#BCC/API Reference/Appendix.md#StorageType).
            • The system disk added during the creation of instance can not be changed after the creation, and it does not support to create or add the system disk separately.
            • The system disk does not support the mount, uninstall or delete.
            • When you create the CDS system disk and data disk, it supports to select the disk size at the step width 1 GB.
            • An instance can mount up to 5 CDS disks by default.
            • The system disk size of BCC instance can not exceed up to 500 GB.
            • You can purchase one temporary data disk for each instance at most. Only the hp1 type of temporary data disk exists by default.
            • To create a memory optimized instance, you must purchase the temporary data disk, and specify the storage capacity of the temporary data disk through ephemeralDisks. The temporary data disk is of nvme type by default, which does not need to specify.
          • Considerations for network:

            • BCC instances support user-defined security groups and subnets, both of which need to be specified under the same VPC If you do not specify a security group and subnet, you will automatically enter the system's default security group and subnet when you create a dedicated instance.
          • Other Precautions

            • Batch creation is supported, and if one instance fails to be created in the creation, all instances are rolled back and all creations fail. If a CDS is included when it is created, the CDS will also be rolled back.
            • If the interface is asynchronously created, the instance status can be queried via the [Designated Instance Details Interface](#BCC/API Reference/Instance Related Interface/Query the details of Designated Instances.md).

          Request

          Request Structure

          POST /v{version}/instanceBySpec?clientToken={clientToken} HTTP/1.1
          Host: bcc.bj.baidubce.com
          Authorization: authorization string
          
          {
              "spec": spec,
              “rootDiskSizeInGb":rootDiskSizeInGb,
              "rootDiskStorageType":"rootDiskStorageType",
              "ephemeralDisks": [
                  {
                      "storageType": storageType,
                      "sizeInGB": size
                  },
                  {
                      "storageType": storageType,
                      "sizeInGB": size
                  }
              ],
              "createCdsList": [
                  {
                      "storageType": storageType,
                      "cdsSizeInGB": cdsSizeInGB,
                      "snapshotId": snapshotId
                  }
              ],
              "name": "name",
              "hostname": "hostname",
              "autoSeqSuffix": autoSeqSuffix,
              "isOpenHostnameDomain": isOpenHostnameDomain,
              "imageId": "imageId",
              "networkCapacityInMbps": networkCapacityInMbps,
              "autoRenewTimeUnit": "autoRenewTimeUnit",
              "autoRenewTime": autoRenewTime,
              "cdsAutoRenew": cdsAutoRenew,
              "internetChargeType": internetChargeType,
              "dedicatedHostId": dedicatedHostId,
              "purchaseCount": purchaseCount,
              "billing":{
                  "paymentTiming": paymentTiming,
                  "reservation": {
                      "reservationLength": reservationLength
                  }
              },
              "zoneName": zoneName,
              "subnetId": subnetId,
              "securityGroupId": securityGroupId,
              "relationTag": relationTag,
              "isOpenIpv6": isOpenIpv6,
              "tags": [
                 {
                    "tagKey": tagKey,
                    "tagValue": tagValue
                 } 
              ],
              "keypairId": keypairId
          }

          Request header field

          No other special header fields are available, except for common header fields.

          Request Parameter

          Parameter name Type Required? Parameter Position Description
          version String Yes URL Parameter API version number
          clientToken String Yes Query Parameters The idempotent Token is an ASCII string with a length not exceeding 64 bits. For more information, please see the [Link.](#Idempotency Support of ClientToken)
          imageId String Yes RequestBody parameter Image ID of virtual machine instance to create,call [the query image list](http://gollum.baidu.com/BceDocumentation/BccOpenAPI#Query Image List) interface to obtain the required image ID。
          spec String No RequestBody parameter A package specification for VM instances to create( with this parameter, you can replace completing instanceType, cpuCount,memoryCapacityInGB, gpuCard, fpgaCard,cardCount, ephemeralDisks parameters), use an interface for the instance package specification to view available instance package and its specifications.
          rootDiskSizeInGb int No RequestBody parameter System disk size (GB) of the virtual machine instance to be created. Its default value is 40 GB, and its range is [40, 100] GB. If the disk size is over 40 GB, it is charged as a cloud disk. The specified system disk size needs to meet the minimum disk space limit of mirror used.
          rootDiskStorageType String No RequestBody parameter System disk media for vitual machine instance to create. The cloud disk is of hp1 type by default. For the specified type of system disk, see StorageType.
          ephemeralDisks List<EphemeralDisk> No RequestBody parameter BCC instance can only use one local disk at most. The default disk type is used, and the disk size needs to be specified. This parameter is invalid when you create a FPGA instance or a GPU instance. By default, use a local disk with a specified size.
          createCdsList List<CreateCdsModel> No RequestBody parameters List of CDS disks to create. For the specific data format, see the following CreateCdsModel
          networkCapacityInMbps int No RequestBody parameters Internet bandwidth (Mbps). It must be an integer within 0200. If it is zero, it means that no public IP is assigned. Its default value is 0 Mbps.
          internetChargeType String No RequestBody parameters For more information on optional parameters of the Internet bandwidth billing methods, see internetChargeType. If internetChargeType is not specified, the default payment method is the same with that of BCC. The default prepaid method means that you make payments yearly or monthly, while the default postpaid method means that you pay as you go.
          purchaseCount int No RequestBody parameters The number of the virtual host instances created (purchased) in batch, which is an optional parameter. It must be an integer greater than 0, whose default value is 1.
          name String No RequestBody parameters Name of virtual machine (optional). The name is not specified by default. If the name is specified: Name is used as the prefix of name in batch. The suffix is attached at the back. Suffix generation mode: name\{ - sequence number}. If no name is specified, generate the "," mode automatically: {instance8bit random stringSequence number}. The random string is generated from the digit 0~9a~z;and the sequence number is increased by the order of count. If the count is 100, the sequence number is increased from 000~100,If the count is 10, the sequence number is increased from 00~10. Supports uppercase and lowercase letters, numbers, Chinese, -, _ and /. Special characters with length 1-65, it must begin with the letter
          hostname String No RequestBody parameters server name of virtual machine (optional). The hostname is not specified by default. If the hostname is specified: hostname is used as the prefix of name in batch. The suffix is attached at the back. Suffix generation mode: name\{ sequence number}. If no name is specified, generate the "," mode automatically: {instance8bit random stringSequence number}. The random string is generated from the digit 0~9a~z;and the sequence number is increased by the order of count. If the count is 100, the sequence number is increased from 000~100,If the count is 10, the sequence number is increased from 00~10. Only support uppercase and lowercase letters, numbers, - and /. Special characters with length 2-64, it must begin with the letter
          autoSeqSuffix boolean No RequestBody parameters whether or not automatically generate name and a hostname with an ordered suffix(optional parameters) is Yes:true , No: false.
          isOpenHostnameDomain boolean No RequestBody parameters whether or not automatically generate a hostname domain (optional parameters) is Yes:true , No: false.
          adminPass String No RequestBody parameters Admin password of an instance to be specified, which is a 8-16-bit string, containing English letters, numbers and symbols at the same time. For symbols, only !, @, #, $, %, * and () can be used. The password needs to be encrypted for transmission.
          billing Billing Yes RequestBody parameters Order and billing related parameters
          zoneName String No RequestBody parameters Specify the zone information, which is null by default and is automatically selected by the system. You can query the AZ list by calling Query AZ List interface. The ZoneName naming convention is "country-region-availability zone sequence” in lowercase; for example, Beijing availability zone A is "cnbja". The dedicated instance uses the zone where the dedicated server is located, without need to specify this field.
          subnetId String No RequestBody parameters Specify the subnet information. If it is null, use the default subnet.
          securityGroupId String No RequestBody parameters Specify the security group information. If it is null, use the default security group.
          relationTag boolean No RequestBody parameters Does the tag specified by the instance to create need to associate with the existing tag key? The default value is false. Note: When the value is true, ensure that this tag key already exists.
          isOpenIpv6 boolean No RequestBody parameters Check to see if the instance to create has ipv6 enabled or not. Ipv6 can be enabled only when both mirror and subnet support ipv6, true indicates enable and false indicates off. Non-transmission indicates the conditions of whether or not an automatic adaptive mirror and subnet support ipv6.
          tags List<TagModel> No RequestBody parameters It is the list of tags to create. For the specific data format, see TagModel.
          keypairId String No RequestBody parameter a Key Pair ID to bind to for instance to be Create
          autoRenewTimeUnit String No RequestBody parameter Monthly or annual payment, "month" for monthly payment, and "year" for annual payment.
          autoRenewTime int No RequestBody parameter Time of auto renew, 1-9 for monthly renew, and 1-3 for annual renew.
          cdsAutoRenew boolean No RequestBody parameter Auto renew of CDS? Yes: true No: false
          aspId String No RequestBody parameter Automatic snapshot policy ID
          bidModel String No RequestBody parameter A bid model on bidding instance is market-oriented price. "market" user-defined:"custom". See BidModel
          bidPrice String No RequestBody parameter The bidding instance bid price is self defined and is lower than a market price, then it is not allowed to create. When bidModel='custom', it is valid.
          dedicatedHostId String No RequestBody parameters DCC id of a DCC, which needs to be specified when you need to specify this DCC’s position.
          deployId String No RequestBody parameters Specifies the id of the deployment set where the instance is located
          deployIdList List No RequestBody parameters Specifies the id list of the deployment set where the instance is located

          Return

          Return a header field

          There are no other special header fields except the common header field.

          Return Parameter

          Parameter Name Type Description
          instanceIds List<String> It is a set of IDs of the virtual machine instances. ID is in line with the BCE specification, and contains only uppercase and lowercase English letters, numbers, hyphens (), and underscores (_).

          Error Code

          Error Code Error Description HTTP status code Explanation
          Instance.InsufficientRootDiskSize Not enough root disk size. 400 The image is too large and the system disk size is not enough/
          Instance.InvalidateRootDiskStorageType Invalidate root disk storage type. 400 Invalid system disk media
          Instance.InstanceBeBanned The instance is banned, contact technical support for assistance. 403 The BCC service has been blocked.
          Instance.GlobalInstanceQuotaLimitExceeded Quota exceeds limit for regional postpaid instances pool, contact technical support for further assistance. 413 The number of post-paid virtual machines exceeds the pre-sale quota limit in the current region
          Instance.InstanceQuotaLimitExceeded Quota exceeds limit. 413 The number of instances exceeds the limit
          Instance.EipQuotaLimitExceeded The number of eip will exceed the limit. 413 The number of eip exceeds the limit during the merged purchase.
          Instance.InvalidateConfiguration Invalidate cpu memory configuration. 400 Invalid virtual machine configuration
          BadRequest spec is invalid. 400 The parameter of package specification for a virtual machine instance to create is invalid
          Instance.MKTImageInstanceNotSupportCreateSnapshotException Instance with mkt image not support create system snapshot. 403 The cloud market image does not support the creation of system Snapshot.

          Example

          Request instance ( create Instance by the specified instance package spec).

          POST /v2/instanceBySpec?clientToken=be31b98c-5e41-4838-9830-9be700de5a20 HTTP/1.1
          Host: bcc.bj.baidubce.com
          ContentType: application/json    
          Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2015-08-11T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
          
          {
              "spec": "bcc.g3.c4m12",
              "createCdsList": [
                  {
                      "storageType": "std1",
                      "cdsSizeInGB": 5
                  }
              ],
              "name": "example",
              "imageId": "m-mRjO3cjs",
              "networkCapacityInMbps": 0,
              "purchaseCount": 1,
              "billing":{
                  "paymentTiming":"Prepaid",
                  "reservation": {
                      "reservationLength": 1
                  }
              }
          }

          Return Example

          HTTP/1.1 200 OK
          x-bce-request-id: 1214cca7-4ad5-451d-9215-71cb844c0a50
          Date: Wed, 03 Dec 2014 06:42:19 GMT
          Content-Type: application/json;charset=UTF-8
          Server: BWS
          
          {
              "instanceIds": [
                  "i-T1I3OtUO"
              ]
          }
          Previous
          Add ipv6
          Next
          Query an Instance List by instance ID