Alibaba Cloud SDK for Python allows you to access Alibaba Cloud services without the need to perform complex coding. This topic describes how to use Alibaba Cloud SDK for Python to call API operations provided by Operation Orchestration Service (OOS) to execute rolling update tasks on Linux computers.
Prerequisites
- A scaling group is created and Elastic Compute Service (ECS) instances are added to the scaling group.
- Python is installed on your computer.
- A RAM user is created and an AccessKey pair is obtained for the RAM user.
Background information
Procedure
Step 1: Install Alibaba Cloud SDK for Python
Step 2: Execute a rolling update task
Sample code is provided in this step to demonstrate how to execute a script on ECS instances.
Execute rollback tasks to handle exceptions in rolling update tasks
If exceptions occur during rolling update tasks or if you want to use previous configurations after rolling upgrade tasks are executed, you can execute rollback tasks to restore the configurations of the ECS instances. Sample code is provided in this section to demonstrate how to roll back rolling update tasks that have been executed.
OOS template parameters
Parameter | Description |
---|---|
invokeType | The type of the task. Valid values:
|
scalingGroupId | The ID of the scaling group in which the task is to be executed. |
commandType | The type of the script to be executed. The value of RunShellScript indicates a shell script. |
invokeScript | The script that is executed on ECS instances during a rolling update task. |
rollbackScript | The script that is executed on ECS instances during a rollback task. |
OOSAssumeRole | The RAM role used to execute the task. Default value: OOSServiceRole. |
enterProcess | The scaling process that is suspended before the task is executed. |
exitProcess | The scaling process that is resumed when the task is completed. |
batchNumber | The number of batches in which the ECS instances in the scaling group are divided. The task is executed in these batches. Each batch contains at least one ECS instance. |
batchPauseOption | Specifies whether and how to suspend the task. Valid values:
|
sourceExecutionId | The execution ID of the source rolling update task when a rollback task is executed. |