Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Auto Scaling/ API Reference/ Application Examples/ Example 5: Performing Operations on Instances in Batches

Example 5: Performing Operations on Instances in Batches

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

Scenarios

This section describes how to perform operations on instances in batches by calling APIs. For details, see Calling APIs.

An instance is an ECS in an AS group. AS allows you to add or remove instances to or from an AS group in batches, configure instance protection or cancel the configuration for the instances in an AS group in batches, and set the standby mode or cancel the setting for the instances in an AS group in batches.

Constraints

  • After instances are removed from an AS group, the number of instances in the AS group cannot be less than the minimum number of instances.
  • After instances are added to an AS group, the number of instances in the AS group cannot be greater than the maximum number of instances.
  • Instances can be added to an AS group only when the AS group is in the INSERVICE state and has no scaling action in progress.
  • Instances can be removed from an AS group only when no scaling action is in progress. Only instances in INSERVICE state can be removed from an AS group.
  • To add instances to an AS group, ensure that the AZ of the instances must be within that of the AS group and that the instances are in the same VPC as the AS group.

Involved APIs

Procedure

  1. Determine the user token that can be used to authenticate the calling of other APIs.

    1. View the user token. For details, see Obtaining a User Token.
    2. Obtain the value of X-Subject-Token in the response header.

  1. Determine the AS group.

    1. View AS groups.
      • API

        URI format: GET /autoscaling-api/v1/{project_id}/scaling_group

        For details, see Querying AS Groups.

      • Example request

        GET: https://{Endpoint}/autoscaling-api/v1/0605767c2e80d5762fd0c0146a10aaf2/scaling_group

        Obtain {endpoint} from Regions and Endpoints.

      • Example response
        {
          "limit": 20,
          "scaling_groups": [
              {
                  "networks": [
                      {
                          "id": "a8327883-6b07-4497-9c61-68d03ee193a",
                          "ipv6_enable": true,
                          "ipv6_bandwidth": 
                          {
                              "id": "076ee2ff-f23e-4338-b8ac-1bc7278532d5"
                          }
                      }
                  ],
                  "available_zones": [
                      "XXXa",
                      "XXXb"
                  ],
                  "detail": null,
                  "scaling_group_name": "as-group-test",
                  "scaling_group_id": "77a7a397-7d2f-4e79-9da9-6a35e2709150",
                  "scaling_group_status": "INSERVICE",
                  "scaling_configuration_id": "1d281494-6085-4579-b817-c1f813be835f",
                  "scaling_configuration_name": "healthCheck",
                  "current_instance_number": 0,
                  "desire_instance_number": 1,
                  "min_instance_number": 0,
                  "max_instance_number": 500,
                  "cool_down_time": 300,
                  "lb_listener_id": "f06c0112570743b51c0e8fbe1f235bab",
                  "security_groups": [
                      {
                          "id": "8a4b1d5b-0054-419f-84b1-5c8a59ebc829"
                      }
                  ],
                  "create_time": "2015-07-23T02:46:29Z",
                  "vpc_id": "863ccae2-ee85-4d27-bc5b-3ba2a198a9e2",
                  "health_periodic_audit_method": "ELB_AUDIT",
                  "health_periodic_audit_time": 5,
                  "health_periodic_audit_grace_period": 600,
                  "instance_terminate_policy": "OLD_CONFIG_OLD_INSTANCE",
                  "is_scaling": false,
                  "delete_publicip": false,
                  "enterprise_project_id": "c92b1a5d-6f20-43f2-b1b7-7ce35e58e413",
                  "multi_az_priority_policy": "PICK_FIRST"
              }
        ],
        "total_number": 1,
        "start_number": 0
        }
    1. Select an AS group and record the AS group ID.

  1. Determine the instances.

    1. View the instances in the specified AS group.
      • Example request

        This example shows how to query enabled, healthy instances in the AS group with ID e5d27f5c-dd76-4a61-b4bc-a67c5686719a.

        GET: https://{Endpoint}/autoscaling-api/v1/0605767c2e80d5762fd0c0146a10aaf2/scaling_group_instance/e5d27f5c-dd76-4a61-b4bc-a67c5686719a/list?life_cycle_state=INSERVICE&health_status=NORMAL

        Obtain {endpoint} from Regions and Endpoints.

      • Example response
        {
            "limit": 10,
            "total_number": 1,
            "start_number": 0,
            "scaling_group_instances": [
                {
                    "instance_id": "b25c1589-c96c-465b-9fef-d06540d1945c",
                    "scaling_group_id": "e5d27f5c-dd76-4a61-b4bc-a67c5686719a",
                    "scaling_group_name": "discuz",
                    "life_cycle_state": "INSERVICE",
                    "health_status": "NORMAL",
                    "scaling_configuration_name": "discuz",
                    "scaling_configuration_id": "ca3dcd84-d197-4c4f-af2a-cf8ba39696ac",
                    "create_time": "2015-07-23T06:47:33Z",
                    "instance_name": "discuz_3D210808",
                    "protect_from_scaling_down": false
                }
            ]
        }
    1. Select instances and record their IDs.

  1. Remove the instances from the AS group in a batch.

    • API

      URI format: POST /autoscaling-api/v1/{project_id}/scaling_group_instance/{scaling_group_id}/action

      For details, see Batch Managing Instances.

    • Example request

      This example shows how to remove and delete instances with IDs instance_id_1 and instance_id_2 from the AS group with ID e5d27f5c-dd76-4a61-b4bc-a67c5686719a in a batch.

      POST: https://{Endpoint}/autoscaling-api/v1/0605767c2e80d5762fd0c0146a10aaf2/scaling_group_instance/e5d27f5c-dd76-4a61-b4bc-a67c5686719a/action

      Obtain {endpoint} from Regions and Endpoints.

      Body:

      {
      "action": "REMOVE",
      "instances_id": [
      "instance_id_1",
      "instance_id_2"
      ],
      "instance_delete": "yes"
      }
    • Example response

      The HTTP status code 204 is returned.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback