Example 1: Creating an AS Configuration
Scenarios
This section describes how to create an AS configuration by calling APIs. For details, see Calling APIs.
An AS configuration defines the specifications of the ECSs to be added to an AS group. The specifications include the ECS flavor, image, and disk size. You can use specifications of an existing ECS or create an AS configuration.
Constraints
- The AS configuration is decoupled from the AS group. An AS configuration can be used by multiple AS groups.
- Up to 100 AS configurations per account can be created by default.
Involved APIs
To create an AS configuration, you need to perform several operations, such as querying a user token, ECS flavors, and images. The following APIs are required:
- Obtaining a User Token: Determine the user token that can be used to authenticate the calling of other APIs.
- Querying Details About ECS Flavors: Determine the ECS flavor to be used to create the AS configuration.
- Querying Images: Determine the image for the AS configuration.
- Querying SSH Key Pairs: Set the login mode to key pair.
- Creating an AS Configuration: Create an AS configuration using the flavor and image you specify.
- Querying an AS Configuration: Verify the AS configuration creation.
Procedure
- Determine the user token that can be used to authenticate the calling of other APIs.
- View the user token. For details, see Obtaining a User Token.
- Obtain the value of X-Subject-Token in the response header.
- Determine the ECS flavor.
- View ECS flavors. For details, see Querying Details About ECS Flavors.
- Select a flavor based on site requirements and record the flavor ID.
- Determine the image.
- View images. For details, see Querying Images.
- Select an image based on site requirements and record the image ID.
- Set the login mode to Key pair.
- View SSH key pairs. For details, see Querying SSH Key Pairs.
- Select a key pair as required and record the key pair name.
- Create an AS configuration using the flavor and image you specify.
- API
URI format: POST /autoscaling-api/v1/{project_id}/scaling_configuration
For details about API request parameters, see Creating an AS Configuration.
- Example request
POST: https://{Endpoint}/autoscaling-api/v1/0605767c2e80d5762fd0c0146a10aaf2/scaling_configuration
Obtain {endpoint} from Regions and Endpoints.
Body:
{ "scaling_configuration_name": "as-config-tlzq", "instance_config": { "flavorRef": "s3.xlarge.4", "imageRef": "627a1223-2ca3-46a7-8d5f-7aef22c74ee6", "disk": [ { "size": 40, "volume_type": "SATA", "disk_type": "SYS" } ], "key_name": "100vm_key", "multi_flavor_priority_policy": "PICK_FIRST" } }
- Example response
{ "scaling_configuration_id": "f8327883-6a07-4497-9a61-68c03e8e72a2" }
- API
- Verify the AS configuration creation.
- API
URI format: GET /autoscaling-api/v1/{project_id}/scaling_configuration/{scaling_configuration_id}
For details, see Querying an AS Configuration.
- Example request
GET: https://{Endpoint}/autoscaling-api/v1/0605767c2e80d5762fd0c0146a10aaf2/scaling_configuration/f8327883-6a07-4497-9a61-68c03e8e72a2
where
f8327883-6a07-4497-9a61-68c03e8e72a2 is the UUID of the created AS configuration.
Obtain {endpoint} from Regions and Endpoints.
- Example response
{ "scaling_configuration": { "tenant": "0605767c2e80d5762fd0c0146a10aaf2", "scaling_configuration_id": "f8327883-6a07-4497-9a61-68c03e8e72a2", "scaling_configuration_name": " config_name_1", "instance_config": { "disk": [ { "size": 40, "volume_type": "SATA", "disk_type": "SYS" }, { "size": 100, "volume_type": "SATA", "disk_type": "DATA" } ], "adminPass": "***", "personality": null, "instance_name": null, "instance_id": null, "flavorRef": "103", "imageRef": "627a1223-2ca3-46a7-8d5f-7aef22c74ee6", "key_name": "keypair01", "public_ip": null, "user_data": null, "metadata": {}, "security_groups": null, "multi_flavor_priority_policy": "PICK_FIRST" }, "create_time": "2015-07-23T01:04:07Z" } }
- API
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot