You need to enable JavaScript to run this app.
文档中心
云服务器

云服务器

复制全文
下载 pdf
动作
原子动作
复制全文
下载 pdf
原子动作
本文主要介绍原子动作相关demo。​
API动作​
API相关动作包括VOS::ExecuteAPI、VOS::WaitFor和VOS::CheckFor。​
VOS::ExecuteAPI示例​
​
{​
"Tasks": [​
{​
"Name": "RebootInstance",​
"Description": "{\"zh-cn\":\"重启实例\",\"en\":\"RebootInstance\"}",​
"Action": "VOS::ExecuteAPI",​
"Parameters": {​
"APIInfo": {​
"Service": "ecs",​
"APIName": "RebootInstance",​
"Version": "2020-04-01",​
"Parameters": {​
"ForceStop": "Value1",​
"InstanceId": "Value2"​
}​
}​
},​
"Outputs": {​
"Result1": {​
"Type": "List",​
"Value": [​
​
]​
}​
}​
}​
]​
}​
​
VOS::WaitFor示例​
​
{​
"Tasks": [​
{​
"Name": "untilInstanceRunningOrStopped",​
"Description": "等待ECS实例至运行中或停止中状态",​
"Action": "VOS::WaitFor",​
"Parameters": {​
"APIInfo": {​
"Service": "ecs",​
"APIName": "DescribeInstances",​
"Version": "2020-04-01",​
"Parameters": {​
"InstanceIds": "{{ [.\"describeVolumeStatus.attachedInstanceId\"] }}"​
},​
"DesiredValues": [​
"RUNNING",​
"STOPPED"​
],​
"NotDesiredValues": [​
"STOPPING"​
],​
"ValueSelector": "{{ [.Instances[].Status] }}"​
}​
}​
}​
]​
}​
​
VOS::CheckFor示例​
​
{​
"Tasks": [​
{​
"Name": "checkInstanceReady",​
"Description": "检查实例状态",​
"Action": "VOS::CheckFor",​
"Parameters": {​
"APIInfo": {​
"Service": "ecs",​
"APIName": "DescribeInstances",​
"Version": "2020-04-01",​
"Parameters": {​
"InstanceIds": "{{ [.instanceId] }}"​
},​
"DesiredValues": [​
"RUNNING",​
"STOPPED"​
],​
"NotDesiredValues": [​
"ERROR"​
],​
"ValueSelector": "{{ [.Instances[].Status] }}"​
}​
}​
}​
]​
}​
​
PeriodTriggerInfo(触发类)​
VOS::PeriodicTrigger示例​
​
{​
"Tasks": [​
{​
"Name": "periodicTask",​
"Action": "VOS::PeriodicTrigger",​
"Description": "通过指定任务类型和周期表达式按计划触发任务",​
"Parameters": {​
"PeriodTriggerInfo": {​
"RepeatMode": "{{ .repeatMode }}",​
"LaunchTime": "{{ .launchTime }}",​
"RecurrenceEndTime": "{{ .recurrenceEndTime }}",​
"Frequency": "{{ .frequency }}"​
}​
}​
}​
]​
}​
​
ChoiceInfo(控制类)​
ChoiceInfo包括VOS::Choice和VOS::SelectTargetInstances​
VOS::Choice示例​
​
{​
"Tasks": [​
{​
"Name": "whetherToDeleteLaunchTemplateVersion",​
"Description": "是否删除启动模版的原最新版本",​
"Action": "VOS::Choice",​
"Parameters": {​
"ChoiceInfo": {​
"Condition": [​
{​
"When": {​
"FN::Equals": [​
"{{ .deleteSourceTemplateVersion }}",​
true​
]​
},​
"Next": "whetherToModifyTemplateDefaultVersion"​
}​
],​
"Default": "VOS::END"​
}​
}​
}​
]​
}​
​
VOS::SelectTargetInstances示例​
使用Action的自定义模版​
​
{​
"Parameters": {​
"targets":{​
"Type":"Map"​
},​
"ForceStop": {​
"Type": "Boolean"​
}​
},​
"Tasks": [​
{​
"Name": "getInstance",​
"Action": "VOS::SelectTargetInstances",​
"Parameters": {​
"Filters": "{{ targets }}"​
},​
"Outputs": {​
"instanceIds": {​
"Type": "List",​
"ValueSelector": "Instances.Instance[].InstanceId"​
}​
},​
"Description": "{\"zh-cn\":\"选择实例\",\"en\":\"SelectTargetInstances\"}"​
},​
{​
"Name": "RebootInstances",​
"ActionId": "ac-ycc8brgqe5f10****",​
"Parameters": {​
"InstanceId": "{{ VOS::LoopItem }}",​
"ForceStop": "{{ .ForceStop }}"​
},​
"Outputs": {​
"InstanceStatus": {​
"Type": "String",​
"Value": "{{ .InstanceStatus }}"​
}​
},​
"Loop": {​
"LoopItem": "{{ getInstance.instanceIds }}",​
"Outputs": {​
"LoopInstanceStatus": {​
"SelectedOutputFiled": "InstanceStatus"​
}​
},​
"Concurrency": 1​
},​
"Description": "{\"zh-cn\":\"批量重启实例\",\"en\":\"RebootInstances\"}"​
}​
],​
"Outputs": {​
"InstanceStatus": {​
"Type": "List",​
"Value": "{{ .\"RebootInstances.LoopInstanceStatus\" }}"​
}​
}​
}​
​
调用传参:​
Type表示选择实例的方式,取值:​
  • Tags:按照标签键值对选择实例。​
  • Project:选择指定项目下的所有实例。​
  • All:选择所有实例。​
​
{"targets":{"Type":"Tags","Tags":[{"Key":"tagKey1","Value":"tagValue1"}]}}​
{"targets":{"Type":"Project","Project":"projectName"}}​
{"targets":{"Type":"All"}}​
​
执行函数​
VOS::InvokeInnerFunction示例​
当前已预置的计算Function如下:​
  • FN::Equals​
  • FN::Now​
  • FN::AddMinute​
  • FN::FormatUTCTime​
  • FN::ExecuteJQExpression​
  • FN::GetExecutionId​
​
{​
"Tasks": [​
{​
"Name": "getSplitInstanceIdList",​
"Description": "获取分割后的实例ID列表",​
"Action": "VOS::InvokeInnerFunction",​
"Parameters": {​
"FunctionName": "FN::ExecuteJQExpression",​
"Input": " def split($array; $len):\n if $array | length > $len then $array | .[0:$len] as $temp | [$temp] + split(.[$len:]; $len) else [$array] end; split(.InstanceIds; 100) "​
},​
"Outputs": {​
"instanceIdList": {​
"Type": "List",​
"Value": "{{ . }}"​
}​
}​
}​
]​
}​
​
嵌套​
VOS::InvokeTemplate示例​
​
{​
"Tasks": [​
{​
"Name": "BulkyModifyInstanceVpcAttribute",​
"Action": "VOS::InvokeTemplate",​
"Description": {​
"zh-cn": "批量修改实例VPC信息",​
"en": "BulkyModifyInstanceVpcAttribute"​
},​
"Parameters": {​
"TemplateId": "tl-ydsu3hnja4kkk1k****",​
"VPCInfo": "{{ VOS::LoopItem }}",​
"NeedStart": "{{ .NeedStart }}"​
},​
"Outputs": {​
"NetworkInterfaceId": {​
"Type": "String",​
"Value": "{{ .NetworkInterfaceId }}"​
}​
},​
"Loop": {​
"LoopItem": "{{ .AllVPCInfo }}",​
"Outputs": {​
"NetworkInterfaceIds": {​
"SelectedOutputFiled": "NetworkInterfaceId"​
}​
},​
"RateControl": "{{ .RateControl }}"​
}​
}​
]​
}​
​
​
最近更新时间:2026.10.30 17:01:32
这个页面对您有帮助吗?
有用
有用
无用
无用