-
Notifications
You must be signed in to change notification settings - Fork 17
/
ACS::ECS::DeleteImageByName.yml
148 lines (148 loc) · 4.27 KB
/
ACS::ECS::DeleteImageByName.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
FormatVersion: OOS-2019-06-01
Description:
name-en: ACS::ECS::DeleteImageByName
name-zh-cn: 通过名称删除镜像
en: Deletes ECS image by specified image name
zh-cn: 根据镜像名称删除ECS的镜像
Parameters:
regionId:
Type: String
Description:
en: The ID of region
zh-cn: 地域ID
imageName:
Type: String
Description:
en: The name of image
zh-cn: 镜像名称
deleteSnapshot:
Type: Boolean
Description:
en: Deletes the snapshots of specified image name or not meanwhile, the default is true
zh-cn: 删除镜像时是否同时删除快照,默认为删除
Default: true
AllowedValues:
- false
- true
Tasks:
- Name: queryImageByName
Action: 'ACS::ExecuteAPI'
Description:
en: Queries existing image id with the specified name
zh-cn: 根据镜像名称获取镜像ID
Properties:
Service: ECS
API: DescribeImages
Parameters:
RegionId: '{{ regionId }}'
ImageName: '{{ imageName }}'
Status: 'Creating,Waiting,Available,UnAvailable,CreateFailed,Deprecated'
Outputs:
imageId:
ValueSelector: 'Images.Image[0].ImageId'
Type: String
snapshotIds:
ValueSelector: '.Images.Image[0].DiskDeviceMappings.DiskDeviceMapping|select(.)|.[].SnapshotId'
Type: List
imageCount:
ValueSelector: 'Images.Image|length|tostring'
Type: String
- Name: whetherDeleteImage
Action: 'ACS::Choice'
Description:
en: Choose the next task by image count
zh-cn: 根据镜像的数量选择下一个任务
Properties:
DefaultTask: 'ACS::END'
Choices:
- When:
'Fn::Equals':
- '1'
- '{{ queryImageByName.imageCount }}'
NextTask: deleteImage
- Name: deleteImage
Action: 'ACS::CheckFor'
Description:
en: Deletes an ECS image with the specified name
zh-cn: 通过指定名称删除ECS的镜像
Properties:
Service: ECS
API: DeleteImage
Parameters:
RegionId: '{{ regionId }}'
ImageId: '{{ queryImageByName.imageId }}'
Force: true
DesiredValues:
- 'OperationDenied.ImageCopying'
- 'null'
PropertySelector: '.Code|tostring'
Outputs:
code:
ValueSelector: '.Code|tostring'
Type: String
- Name: whetherCancelCopyImage
Action: 'ACS::Choice'
Description:
en: Choose next task by DeleteImage code
zh-cn: 根据DeleteImage的错误码选择下一个任务的类型
Properties:
DefaultTask: 'whetherDeleteSnapshot'
Choices:
- When:
'Fn::Equals':
- 'OperationDenied.ImageCopying'
- '{{ deleteImage.code }}'
NextTask: cancelCopyImage
- Name: cancelCopyImage
Action: 'ACS::ExecuteAPI'
OnSuccess: whetherDeleteSnapshot
OnError: deleteImageAgain
Description:
en: Cancel the copying image
zh-cn: 取消复制镜像
Properties:
Service: ECS
API: CancelCopyImage
Parameters:
RegionId: '{{ regionId }}'
ImageId: '{{ queryImageByName.imageId }}'
- Name: deleteImageAgain
Action: 'ACS::ExecuteAPI'
OnSuccess: whetherDeleteSnapshot
Description:
en: Deletes an ECS image with the specified name
zh-cn: 通过指定名称删除ECS镜像
Properties:
Service: ECS
API: DeleteImage
Parameters:
RegionId: '{{ regionId }}'
ImageId: '{{ queryImageByName.imageId }}'
Force: true
- Name: whetherDeleteSnapshot
Action: 'ACS::Choice'
Description:
en: Choose next task by user option
zh-cn: 选择是否执行删除快照
Properties:
DefaultTask: 'ACS::END'
Choices:
- When:
'Fn::Equals':
- true
- '{{ deleteSnapshot }}'
NextTask: deleteSnapshot
- Name: deleteSnapshot
Action: 'ACS::ExecuteAPI'
Description:
en: Deletes snapshot of image with the specified name
zh-cn: 通过镜像名称删除快照
Properties:
Service: ECS
API: DeleteSnapshot
Parameters:
RegionId: '{{ regionId }}'
SnapshotId: '{{ ACS::TaskLoopItem }}'
Force: true
Loop:
Items: '{{ queryImageByName.snapshotIds }}'