Updated on 2022-08-02 GMT+08:00

Adding Template Information

Function

This API is used to add information to a template.

URI

POST /v1/sms/vm/template

Request

Request parameters

For details about the request parameters, see Table 1.

Table 1 Parameter description

Parameter

Mandatory

Type

Description

template

Yes

String

Template information. For details, see Table 2.

disks

Yes

String

Disk information. For details, see Table 7.

Table 2 template information

Parameter

Mandatory

Type

Description

name

Yes

String

Template name

is_template

Yes

Boolean

Whether the object is a template. The value is true if a user saves the template, and false if the user does not save the template and directly create a task.

region

Yes

String

Region name

target_server_name

Yes

String

Name of the target ECS

availability_zone

Yes

String

AZ

volumetype

Yes

String

Disk type

vpc

Yes

Object

VPC information. The value is {} if the VPC is automatically created. For details, see Table 3.

security_groups

Yes

Array

Security group. The value is [] if the security group is automatically created. For details, see Table 4.

nics

Yes

Array

Subnet information. The value is [] if the subnet is automatically created. For details, see Table 5.

flavors

No

Array

ECS specifications. The value is [] if the ECS is automatically created.

publicip

No

Object

EIP information. For details, see Table 6.

Table 3 vpc information

Parameter

Mandatory

Type

Description

id

Yes

String

VPC ID

name

Yes

String

VPC name

Table 4 security_groups information

Parameter

Mandatory

Type

Description

id

Yes

String

Security group ID

name

Yes

String

Security group name

Table 5 nics information

Parameter

Mandatory

Type

Description

id

Yes

String

Subnet ID

name

Yes

String

Subnet name

cidr

Yes

String

Gateway/mask

ip

No

String

Private IP address

Table 6 publicip information

Parameter

Mandatory

Type

Description

id

No

String

EIP ID, which is mandatory for a newly assigned one.

ip

No

String

EIP address, which is mandatory for a newly assigned one.

type

Yes

String

EIP type. The default value is 5_bgp.

bandwidth_size

Yes

Integer

Bandwidth size (Mbit/s). The value ranges from 1 to 2000.

The minimum increment for bandwidth adjustment varies depending on the bandwidth range. The minimum increment is 1 Mbit/s if the allowed bandwidth ranges from 0 to 300 Mbit/s (with 300 Mbit/s included). The minimum increment is 50 Mbit/s if the allowed bandwidth ranges 300 Mbit/s to 1000 Mbit/s (with 1000 Mbit/s included). The minimum increment is 500 Mbit/s if the allowed bandwidth is greater than 1000 Mbit/s.

NOTE:

This parameter is mandatory when sharetype is set to PER and is optional when sharetype is set to WHOLE with an ID specified.

bandwidth_share_type

No

String

Bandwidth sharing type. Enumerated values: PER (indicates exclusive bandwidth) and WHOLE (indicates sharing). The default value is PER.

Table 7 disk information

Parameter

Mandatory

Type

Description

index

Yes

Integer

Disk number, starting from 0

name

No

String

Disk name

disktype

Yes

String

Disk type. The value is the same as that of volumetype.

size

Yes

Integer

Disk size (GB)

Response

Table 8 Response message

Parameter

Type

Description

id

String

ID

Example

  • Example request

    POST /v1/sms/vm/template

    {
        "template": {       
            "name": "template name",
            "is_template":"false",// false indicates creating a task, and true indicates saving the template.
            
            
            
            
            "region":"my-kualalumpur-1",
            
            "target_server_name":"target server 1",
            "availability_zone":"az1-dc1", //AZ name
            "volumetype": "DESS_SSD_FC",
            "vpc": {
              "id":"0dae26c9-9a70-4392-93f3-87d53115d171",
              "name":"vpc1" 
            },
            "security_groups":[
              {
    	    "id":"507ca48f-814c-4293-8706-300564d54620", 
                "name":"default"
    	   }
             ], 
            "nics":[
              {
                "id":"157ee789-03ea-45b1-a698-76c92660dd83",
                "name": "subnet-1637",
                "cidr": "192.168.0.0/24",
    	    "ip":"192.168.0.0"
               }
            ],
            "flavors":c3.2xlarge.4,               
            "publicip":  {
                 "id":"1111",
                 "ip ":"x.x.x.x",
                 "type": "5_bgp",
                 "bandwidth_size":10,
                 "bandwidth_share_type":"PER"
            }
        },
        "disks":[
          {
            "index":0,
            "name":"Disk 01",
            "disktype":"DESS_SSD_FC",
            "size":40
         }
        ]
    }

  • Example response
    {
      "id": "aaaa-bbbb-cccc-dddd"
    }

Status Codes

See Status Codes.