• Auto Scaling

as
  1. Help Center
  2. Auto Scaling
  3. API Reference
  4. API
  5. AS Configurations
  6. Creating an AS Configuration

Creating an AS Configuration

Function

This interface is used to create an AS configuration.

An AS configuration is a template of ECSs in an AS group. It defines the specifications of the instances to be added to the AS group. The AS service automatically adds instances to an AS group based on the AS configuration.

URI

POST /autoscaling-api/v1/{project_id}/scaling_configuration
Table 1 Parameter description

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the project ID.

Request Message

  • Request parameters
    Table 2 Request parameters

    Parameter

    Mandatory

    Type

    Description

    scaling_configuration_name

    Yes

    String

    Specifies the AS configuration name. The name can contain letters, digits, underscores (_), and hyphens (-), and must be between 1 and 64 characters in length.

    instance_config

    Yes

    Dictionary data structure

    Specifies the information about instance configurations.

    Table 3 instance_config field data structure description

    Parameter

    Mandatory

    Type

    Description

    instance_id

    No

    String

    Specifies the ECS ID. When using the existing ECS specifications as the template to create AS configurations, specify this parameter. In this case, flavorRef, imageRef, disk, and security_groups fields do not take effect.

    If the instance_id field is not specified, flavorRef, imageRef, and disk fields are mandatory.

    flavorRef

    No

    String

    Specifies the ECS flavor ID. You can obtain its value from the API used to query specifications and expansion details about ECSs. For details, see section "Querying Specifications and Expansion Details About ECSs" in the Elastic Cloud Server API Reference.

    imageRef

    No

    String

    Specifies the image ID. It is the same as image_id. You can obtain its value from the API used to query IMS images. For details, see section Querying Images in the Image Management Service API Reference.

    disk

    No

    List data structure

    Specifies the disk group information. System disks are mandatory and data disks are optional.

    key_name

    Yes

    String

    Specifies the name of the SSH key pair used to log in to the ECS.

    personality

    No

    List data structure

    Specifies information about the injected file. Only text files can be injected. A maximum of five files can be injected at a time and the maximum size of each file is 1 KB.

    public_ip

    No

    Dictionary data structure

    Specifies the EIP of the ECS. The EIP can be configured in the following two ways:

    • Do not use an EIP. In this case, this parameter is unavailable.
    • Automatically assign an EIP. You need to specify the information about the new EIP.

    user_data

    No

    String

    Specifies the Cloud-Init user data.

    Text, text files, and gzip files can be injected. The file content must be encoded using Base64. The maximum size of the injected file (before encoding) is 32 KB.

    metadata

    No

    Dictionary data structure

    Specifies the metadata of ECSs to be created.

    NOTE:

    This parameter is mandatory when a Windows ECS with password authentication is created.

    This field does not allow users to write data. It is mandatory when the ECS is to be created using a Windows image.

    security_groups

    No

    List data structure

    Specifies the security group information. You can use vpc_id to obtain the parameter value from the API used to query VPC security groups. For details, see section "Querying Security Groups" in the Virtual Private Cloud API Reference.

    If the security group is specified both in the AS configuration and AS group, the security group specified in the AS configuration prevails. If the security group is not specified in either of them, the default security group is used. For your convenience, you are advised to specify the security group in the AS configuration.

    NOTE:
    • When you create an ECS using an image that supports Cloud-Init or Cloudbase-Init, only key_name can be configured. (Parameter adminPass is invalid.) When you create an ECS using an image that does not support Cloud-Init or Cloudbase-Init, both parameters adminPass and key_name are invalid. In such a case, use the password or certificate of the image to log in to the ECS.
    Table 4 disk field data structure description

    Parameter

    Mandatory

    Type

    Description

    size

    Yes

    Integer

    Specifies the disk size. The unit is GB.

    The system disk size ranges from 1 to 32768 and must be greater than or equal to the minimum size (min_disk value) of the system disk specified in the image.

    The data disk size ranges from 10 to 32768.

    volume_type

    Yes

    String

    Specifies the ECS system disk type, which must be the same as the disk type available in the system.

    Enumerated values of the disk type:

    • SATA: common I/O disk type
    • SAS: high I/O disk type
    • SSD: ultra-high I/O disk type
    • co-pl: high I/O (performance-optimized I) disk type
    • uh-l1: ultra-high I/O (latency-optimized) disk type
    NOTE:

    For HANA and HL1 ECSs, use co-p1 or uh-l1 disks. For other ECSs, do not use co-p1 or uh-l1 disks.

    disk_type

    Yes

    String

    Specifies whether the disk is a system disk or a data disk. DATA indicates a data disk. SYS indicates a system disk.

    dedicated_storage_id

    No

    String

    Specifies a DSS device ID for creating an ECS disk.

    NOTE:

    Specify DSS devices for all disks in an AS configuration or not. If DSS devices are specified, all the data stores must belong to the same AZ, and the disk types supported by a DSS device for a disk must be the same as the volume_type value.

    data_disk_image_id

    No

    String

    Specifies the ID of a data disk image used to export data disks of an ECS.

    snapshot_id

    No

    String

    Specifies the disk backup snapshot ID for restoring the system disk and data disk at the ECS level when the ECS-level image is used.

    NOTE:

    You can obtain the disk backup snapshot ID by using the mirrored ECS-level backup ID to query backup details in CSBS. Regarding snapshot_id, each disk in an AS configuration must correspond to a disk backup at the ECS-level.

    Table 5 personality field data structure description

    Parameter

    Mandatory

    Type

    Description

    path

    Yes

    String

    Specifies the path of the injected file.

    1. For Linux OSs, specify the path, for example, /etc/foo.txt, for storing the injected file.
    2. For Windows, the injected file is automatically stored in the root directory of drive C. You only need to specify the file name, for example, foo. The file name can contain only letters and digits.

    content

    Yes

    String

    Specifies the content of the injected file.

    The value must be the information after the content of the injected file is encoded using Base64.

    Table 6 public_ip field data structure description

    Parameter

    Mandatory

    Type

    Description

    eip

    Yes

    Dictionary data structure

    Specifies the configuration parameter for creating an EIP that will be automatically assigned to the ECS.

    Table 7 eip field data structure description

    Parameter

    Mandatory

    Type

    Description

    ip_type

    Yes

    String

    Specifies the EIP type.

    Enumerated value of the IP address type: 5_bgp (indicates dynamic BGP)

    bandwidth

    Yes

    Dictionary data structure

    Specifies the bandwidth.

    Table 8 bandwidth field data structure description

    Parameter

    Mandatory

    Type

    Description

    size

    Yes

    Integer

    Specifies the bandwidth (Mbit/s). The value range is 1 to 500.

    NOTE:
    • The specific range may vary depending on the configuration in each region. You can see the bandwidth range of each region on the management console.
    • The minimum unit for bandwidth varies depending on the bandwidth range.
      • The minimum unit is 1 Mbit/s if the allowed bandwidth size ranges from 0 to 300 Mbit/s (with 300 Mbit/s included).
      • The minimum unit is 50 Mbit/s if the allowed bandwidth size ranges 300 Mbit/s to 500 Mbit/s (with 500 Mbit/s included).

    share_type

    Yes

    String

    Specifies the bandwidth sharing type.

    Enumerated values of the sharing type:

    PER indicates dedicated bandwidth.

    Only exclusive bandwidth is available.

    charging_mode

    Yes

    String

    Specifies the bandwidth charging mode.

    • If the field value is traffic, the bandwidth is billed based on the amount of data used.
    • If the field value is others, the ECS creation will fail.
    Table 9 metadata field data structure description

    Parameter

    Mandatory

    Type

    Description

    User-defined field key pair

    No

    String

    The total length of the user-defined data cannot be longer than 512 bytes. The user-defined key cannot be empty, contain symbol dot (.), or start with symbol dollar ($).

    Table 10 security_groups field data structure description

    Parameter

    Mandatory

    Type

    Description

    id

    Yes

    String

    Specifies the ID of the security group.

  • Example request
    { 
        "scaling_configuration_name": "as-config-tlzq", 
        "instance_config": { 
            "flavorRef": "103", 
            "imageRef": "627a1223-2ca3-46a7-8d5f-7aef22c74ee6", 
            "disk": [ 
                { 
                    "size": 40, 
                    "volume_type": "SATA", 
                    "disk_type": "SYS" 
                } 
            ], 
            "key_name": "100vm_key" ,
    	   "security_groups": [{
    		    "id": "6c22a6c0-b5d2-4a84-ac56-51090dcc33be"
    	   }]
        } 
    }
    

Response Message

  • Response parameters
    Table 11 Response parameters

    Parameter

    Type

    Description

    scaling_configuration_id

    String

    Specifies the AS configuration ID.

  • Example response
    {
        "scaling_configuration_id": "f8327883-6a07-4497-9a61-68c03e8e72a2"
    }

Returned Value

  • Normal

    200

  • Abnormal

    Returned Value

    Description

    400 Bad Request

    The server failed to process the request.

    401 Unauthorized

    You must enter the username and password to access the requested page.

    403 Forbidden

    You are forbidden to access the requested page.

    404 Not Found

    The server could not find the requested page.

    405 Method Not Allowed

    You are not allowed to use the method specified in the request.

    406 Not Acceptable

    The response generated by the server could not be accepted by the client.

    407 Proxy Authentication Required

    You must use the proxy server for authentication so that the request can be processed.

    408 Request Timeout

    The request timed out.

    409 Conflict

    The request could not be processed due to a conflict.

    500 Internal Server Error

    Failed to complete the request because of an internal service error.

    501 Not Implemented

    Failed to complete the request because the server does not support the requested function.

    502 Bad Gateway

    Failed to complete the request because the request is invalid.

    503 Service Unavailable

    Failed to complete the request because the system is unavailable.

    504 Gateway Timeout

    A gateway timeout error occurred.

Error Codes

See section Error Codes.