-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathACS-ECS-RescueUnreachableInstance-Linux.json
893 lines (893 loc) · 26.3 KB
/
ACS-ECS-RescueUnreachableInstance-Linux.json
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
{
"FormatVersion": "OOS-2019-06-01",
"Description": {
"en": "When using ECS instances, some situations can lead to system disk corruption, such as instances being forced to stop or restart, or sudden downtime, failure to update /etc/fstab when the disk is unloaded, or even loss or corruption of /etc/fstab or initrd files. When the instance cannot be accessed, the state of the instance displayed in the ECS instance console may still be Running, but the application in the instance cannot be accessed, the network in the instance cannot be reached, and the connection cannot be established through workbench or SSH. If you can connect to an instance from the console with VNC, you will probably see a page that indicates a system startup failure. At this point, you can consider executing the template to cure the damaged instance. The cure process is that the system disk of the damaged instance will be mounted to the newly created temporary instance, then a cure script will be executed in the temporary instance, and finally the cured system disk will be mounted back to the original instance.",
"zh-cn": "使用ECS实例时,有些情况可能导致系统盘损伤,比如实例被强制地停止或重启,抑或突然发生了宕机,以及数据盘被卸载后未更新/etc/fstab,甚至于/etc/fstab或initrd文件丢失或损坏。当无法访问实例时,该实例在ECS实例控制台显示的状态可能还是运行中,但实例内的应用不可访问,实例内的网络不可达,更无法通过workbench或者ssh建立连接。如果您在控制台通过vnc能连接上实例,看到的页面大概是系统启动失败的提示信息。此时您可考虑执行该模板对损伤实例进行救治,救治流程主要是损伤的实例的系统盘将被挂载到新创建的临时实例上,接着在临时实例中会执行一段救治脚本,最后救治过的系统盘将被挂载回原实例",
"name-en": "ACS-ECS-RescueUnreachableInstance-Linux",
"name-zh-cn": "自助救治损伤的ECS实例Linux系统盘",
"categories": [
"diagnose"
]
},
"Parameters": {
"unreachableInstanceId": {
"Label": {
"en": "UnreachableInstanceId",
"zh-cn": "将自救的ECS实例ID"
},
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::InstanceId",
"AssociationPropertyMetadata": {
"RegionId": "{{ ACS::RegionId }}"
}
},
"credentialType": {
"Description": {
"en": "Credential Type for your unreachable ECS instance after being rescued, either KeyPairName or Password type can be chosen.",
"zh-cn": "当执行自救ECS实例后,实例root登录凭证类型,可选择密钥对或自定义密码"
},
"Label": {
"en": "CredentialType",
"zh-cn": "登录凭证类型"
},
"Type": "String",
"AllowedValues": [
"KeyPairName",
"Password"
]
},
"credentialValue": {
"Description": {
"en": "Credential value for your unreachable ECS instance after being rescued, the value of KeyPairName or Password.",
"zh-cn": "当执行自救ECS实例后,实例root登录凭证值,如果凭证类型选择密钥对,则此处填写密钥对名称;如果凭证类型选择了自定义密码,则此处填写将设置的密码"
},
"Type": "String",
"Label": {
"en": "Credential",
"zh-cn": "登录凭证"
}
},
"imagePrefix": {
"Label": {
"en": "ImagePrefix",
"zh-cn": "用来备份ECS实例的镜像名称的前缀"
},
"Type": "String",
"Default": "OOSRescueBackup-"
},
"helperInstanceTypes": {
"Label": {
"en": "HelperInstanceTypes",
"zh-cn": "自救执行过程中,被创建的临时实例规格的选择范围"
},
"Type": "List",
"Default": [
"ecs.t6-c4m1.large",
"ecs.t5-lc1m1.small",
"ecs.t5-lc1m2.small",
"ecs.s6-c1m1.small",
"ecs.s6-c1m2.small",
"ecs.n1.small",
"ecs.mn4.small",
"ecs.e3.small",
"ecs.e4.small",
"ecs.n2.small",
"ecs.n4.small",
"ecs.t5-lc1m2.large",
"ecs.c6.large",
"ecs.sn2ne.large"
]
},
"OOSAssumeRole": {
"Label": {
"en": "OOSAssumeRole",
"zh-cn": "OOS扮演的RAM角色"
},
"Type": "String",
"Default": ""
}
},
"RamRole": "{{ OOSAssumeRole }}",
"Tasks": [
{
"Name": "checkInstanceReady",
"Action": "ACS::CheckFor",
"Description": {
"en": "Checks ECS instance is linux os",
"zh-cn": "确认将救治ECS实例为Linux系统的"
},
"OnError": "ACS::END",
"Properties": {
"Service": "ECS",
"API": "DescribeInstances",
"Parameters": {
"InstanceIds": [
"{{ unreachableInstanceId }}"
]
},
"DesiredValues": [
"linux"
],
"PropertySelector": "Instances.Instance[].OSType"
},
"Outputs": {
"status": {
"Type": "String",
"ValueSelector": "Instances.Instance[].Status"
},
"vSwitchId": {
"Type": "String",
"ValueSelector": "Instances.Instance[].VpcAttributes.VSwitchId"
},
"zoneId": {
"Type": "String",
"ValueSelector": "Instances.Instance[].ZoneId"
},
"oSNameEn": {
"Type": "String",
"ValueSelector": "Instances.Instance[].OSNameEn"
},
"oSName": {
"Type": "String",
"ValueSelector": "Instances.Instance[].OSName"
},
"imageID": {
"Type": "String",
"ValueSelector": "Instances.Instance[].ImageId"
}
}
},
{
"Name": "querySystemDisks",
"Action": "ACS::CheckFor",
"Description": {
"en": "Checks system disk of the ECS instance",
"zh-cn": "检查将救治的系统盘情况"
},
"OnError": "ACS::END",
"Properties": {
"Service": "ECS",
"API": "DescribeDisks",
"Parameters": {
"InstanceId": "{{ unreachableInstanceId }}",
"DiskType": "system"
},
"DesiredValues": [
"true"
],
"PropertySelector": ".Disks.Disk[] as $disk|$disk.Category|startswith(\"cloud\") and ($disk.Encrypted|not)|tostring"
},
"Outputs": {
"diskId": {
"Type": "String",
"ValueSelector": "Disks.Disk[].DiskId"
},
"category": {
"Type": "String",
"ValueSelector": "Disks.Disk[].Category"
},
"encrypted": {
"Type": "String",
"ValueSelector": "Disks.Disk[].Encrypted"
}
}
},
{
"Name": "whetherStopInstance",
"Action": "ACS::Choice",
"Description": {
"en": "Choose next task by Instance status",
"zh-cn": "根据实例状态选择要执行的任务"
},
"Properties": {
"DefaultTask": "stopInstance",
"Choices": [
{
"When": {
"Fn::Equals": [
"Stopped",
"{{ checkInstanceReady.status }}"
]
},
"NextTask": "checkAvailableInstanceTypesExist"
}
]
}
},
{
"Name": "stopInstance",
"Action": "ACS::ExecuteAPI",
"Description": {
"en": "Stops the ECS instances",
"zh-cn": "停止实例"
},
"Properties": {
"Service": "ECS",
"API": "StopInstance",
"Parameters": {
"InstanceId": "{{ unreachableInstanceId }}"
}
}
},
{
"Name": "Sleep3Minutes",
"Description": {
"en": "Wait instance Stopped",
"zh-cn": "等待实例停止成功"
},
"Action": "ACS::Sleep",
"Properties": {
"Duration": "PT3M"
}
},
{
"Name": "queryUnreachableInstanceStatus",
"Action": "ACS::ExecuteAPI",
"Description": {
"en": "Query status of unreachable instance",
"zh-cn": "查询损伤系统盘的实例状态"
},
"Properties": {
"Service": "ECS",
"API": "DescribeInstances",
"Parameters": {
"InstanceIds": [
"{{ unreachableInstanceId }}"
]
}
},
"Outputs": {
"status": {
"Type": "String",
"ValueSelector": "Instances.Instance[].Status"
}
}
},
{
"Name": "whetherForceStopInstance",
"Action": "ACS::Choice",
"Description": {
"en": "Choose next task by Instance status",
"zh-cn": "根据实例状态选择要执行的任务"
},
"Properties": {
"DefaultTask": "forceStopInstance",
"Choices": [
{
"When": {
"Fn::Equals": [
"Stopped",
"{{ queryUnreachableInstanceStatus.status }}"
]
},
"NextTask": "checkAvailableInstanceTypesExist"
}
]
}
},
{
"Name": "forceStopInstance",
"Action": "ACS::ExecuteAPI",
"Description": {
"en": "Stops the ECS instances forcibly",
"zh-cn": "强制停止实例"
},
"Properties": {
"Service": "ECS",
"API": "StopInstance",
"Parameters": {
"InstanceId": "{{ unreachableInstanceId }}",
"ForceStop": "true"
}
}
},
{
"Name": "untilStopUnreachableInstanceSuccess",
"Action": "ACS::WaitFor",
"Description": {
"en": "Waits for the ECS instance to enter stopped status",
"zh-cn": "等待实例停止"
},
"Properties": {
"Service": "ECS",
"API": "DescribeInstances",
"Parameters": {
"InstanceIds": [
"{{ unreachableInstanceId }}"
]
},
"DesiredValues": [
"Stopped"
],
"PropertySelector": "Instances.Instance[].Status"
}
},
{
"Name": "checkAvailableInstanceTypesExist",
"Action": "ACS::Template",
"OnError": "ACS::END",
"Description": {
"en": "Query current available instance type for creating helper instance in the zone of the unreachable",
"zh-cn": "查询将创建的目标临时实例规格是否有库存"
},
"Properties": {
"TemplateName": "ACS::ECS::CheckAvailableInstanceTypes",
"Parameters": {
"zoneId": "{{ checkInstanceReady.zoneId }}",
"instanceTypes": "{{ helperInstanceTypes }}"
}
},
"Outputs": {
"availableInstanceType": {
"Type": "String",
"ValueSelector": ".availableInstanceTypes[0]"
}
}
},
{
"Name": "createImage",
"Action": "ACS::ExecuteAPI",
"Description": {
"en": "Creates a custom image",
"zh-cn": "创建一个自定义镜像"
},
"Properties": {
"Service": "ECS",
"API": "CreateImage",
"Parameters": {
"ImageName": "{{imagePrefix}}{{ ACS::ExecutionId }}",
"InstanceId": "{{ unreachableInstanceId }}",
"DetectionStrategy": "Standard",
"Tag": [
{
"Key": "instance_to_rescue",
"Value": "{{unreachableInstanceId}}"
},
{
"Key": "oos_exec",
"Value": "{{ ACS::ExecutionId }}"
}
]
}
},
"Outputs": {
"imageId": {
"Type": "String",
"ValueSelector": "ImageId"
}
}
},
{
"Name": "createStack",
"Action": "ACS::ExecuteAPI",
"Description": {
"en": "Create a Ros resource stack",
"zh-cn": "创建Ros资源栈"
},
"Properties": {
"Service": "ROS",
"API": "CreateStack",
"Parameters": {
"StackName": "OOS-{{ACS::ExecutionId}}",
"TimeoutInMinutes": 10,
"DisableRollback": false,
"Parameters": [
{
"ParameterKey": "helperInstanceType",
"ParameterValue": "{{checkAvailableInstanceTypesExist.availableInstanceType}}"
},
{
"ParameterKey": "zoneId",
"ParameterValue": "{{ checkInstanceReady.zoneId }}"
},
{
"ParameterKey": "resourcePrefix",
"ParameterValue": "OOS-{{ACS::ExecutionId}}"
},
{
"ParameterKey": "imageId",
"ParameterValue": "centos_8_0_x64_20G_alibase_20191225.vhd"
},
{
"ParameterKey": "instanceIdToRescue",
"ParameterValue": "{{unreachableInstanceId}}"
},
{
"ParameterKey": "executionId",
"ParameterValue": "{{ ACS::ExecutionId }}"
}
],
"TemplateURL": "https://oos-debug.oss-cn-hangzhou.aliyuncs.com/ros_template.json"
}
},
"Outputs": {
"StackId": {
"Type": "String",
"ValueSelector": "StackId"
}
}
},
{
"Name": "untilImageReady",
"Action": "ACS::WaitFor",
"Description": {
"en": "Wait for the image to be available",
"zh-cn": "等待镜像创建成功"
},
"OnError": "deleteStack",
"Properties": {
"Service": "ECS",
"API": "DescribeImages",
"Parameters": {
"ImageId": "{{ createImage.imageId }}"
},
"DesiredValues": [
"Available"
],
"PropertySelector": "Images.Image[].Status"
},
"Retries": 50,
"Delay": 36,
"DelayType": "Constant"
},
{
"Name": "untilStackReady",
"Action": "ACS::WaitFor",
"OnError": "queryStackStatusReason",
"OnSuccess": "putRTToHelperInstance",
"Description": {
"en": "Wait for the stack status CREATE_COMPLETE.",
"zh-cn": "等待资源栈创建成功。"
},
"Properties": {
"Service": "ROS",
"API": "GetStack",
"Parameters": {
"StackId": "{{createStack.StackId}}"
},
"DesiredValues": [
"CREATE_COMPLETE"
],
"StopRetryValues": [
"CREATE_FAILED",
"CHECK_FAILED",
"ROLLBACK_FAILED",
"ROLLBACK_COMPLETE",
"CREATE_ROLLBACK_COMPLETE"
],
"PropertySelector": "Status"
},
"Outputs": {
"helperInstanceId": {
"Type": "String",
"ValueSelector": "Outputs[0].OutputValue"
},
"statusReason": {
"Type": "String",
"ValueSelector": "StatusReason"
}
}
},
{
"Name": "queryStackStatusReason",
"Action": "ACS::ExecuteAPI",
"OnError": "deleteStack",
"OnSuccess": "deleteStack",
"Description": {
"en": "Query the reson of failed created stack.",
"zh-cn": "查询资源栈未创建成功的原因。"
},
"Properties": {
"Service": "ROS",
"API": "GetStack",
"Parameters": {
"StackId": "{{createStack.StackId}}"
}
},
"Outputs": {
"statusReason": {
"Type": "String",
"ValueSelector": "StatusReason"
}
}
},
{
"Name": "putRTToHelperInstance",
"Action": "ACS::ECS::RunCommand",
"OnError": "deleteStack",
"Description": {
"en": "Run cloud assistant command on ECS instance to download rt",
"zh-cn": "在实例中运行云助手命令下载修复脚本"
},
"Properties": {
"commandContent": "cd /tmp ; wget https://oos-debug.oss-cn-hangzhou.aliyuncs.com/guestos-scripts-0.0.1.tar.gz; tar -zxvf guestos-scripts-0.0.1.tar.gz",
"commandType": "RunShellScript",
"instanceId": "{{ untilStackReady.helperInstanceId }}"
}
},
{
"Name": "addTags",
"Action": "ACS::ExecuteAPI",
"OnError": "deleteStack",
"Description": {
"en": "Add Tags of system disk to instance to rescue",
"zh-cn": "给要救治的实例添加上其系统盘信息的标签"
},
"Properties": {
"Service": "ECS",
"API": "AddTags",
"Parameters": {
"ResourceType": "instance",
"ResourceId": "{{ unreachableInstanceId }}",
"Tag": [
{
"Key": "source_sys_disk",
"Value": "{{ querySystemDisks.diskId }}"
}
]
}
}
},
{
"Name": "detachDisk",
"Action": "ACS::ECS::DetachDisk",
"OnError": "deleteStack",
"Description": {
"en": "Detaches the system disk from unreachable instance",
"zh-cn": "卸载有损伤的系统盘"
},
"Properties": {
"instanceId": "{{ unreachableInstanceId }}",
"diskId": "{{ querySystemDisks.diskId }}"
}
},
{
"Name": "attachAsDataDisk",
"Action": "ACS::ECS::AttachDisk",
"OnError": "deleteStack",
"Description": {
"en": "Attaches the system disk to the helper instance as a data disk",
"zh-cn": "将损伤的系统盘作为数据盘挂载到临时实例上"
},
"Properties": {
"instanceId": "{{ untilStackReady.helperInstanceId }}",
"diskId": "{{ querySystemDisks.diskId }}"
}
},
{
"Name": "runCommand",
"Action": "ACS::ECS::RunCommand",
"OnError": "deleteStack",
"Description": {
"en": "Run a cloud assistant command of rescuing disk on ECS instance",
"zh-cn": "在实例中通过云助手运行救治损伤盘的脚本"
},
"Properties": {
"commandContent": "cd /tmp/guestos-scripts-0.0.1;./rescue_system_disk.sh",
"commandType": "RunShellScript",
"instanceId": "{{ untilStackReady.helperInstanceId }}"
},
"Outputs": {
"commandOutput": {
"Type": "String",
"ValueSelector": "invocationOutput"
}
}
},
{
"Name": "forceStopHelperInstance",
"Action": "ACS::ExecuteAPI",
"OnError": "deleteStack",
"Description": {
"en": "Stops the helper instance forcibly",
"zh-cn": "强制停止实例"
},
"Properties": {
"Service": "ECS",
"API": "StopInstance",
"Parameters": {
"InstanceId": "{{ untilStackReady.helperInstanceId }}",
"ForceStop": "true"
}
}
},
{
"Name": "untilforceStopHelperInstanceSuccess",
"Action": "ACS::WaitFor",
"OnError": "deleteStack",
"Description": {
"en": "Waits for the helper instance to enter stopped status",
"zh-cn": "等待临时实例停止"
},
"Properties": {
"Service": "ECS",
"API": "DescribeInstances",
"Parameters": {
"InstanceIds": [
"{{ untilStackReady.helperInstanceId }}"
]
},
"DesiredValues": [
"Stopped"
],
"PropertySelector": "Instances.Instance[].Status"
}
},
{
"Name": "detachHelperInstanceDataDisk",
"Action": "ACS::ECS::DetachDisk",
"OnError": "deleteStack",
"Description": {
"en": "Detaches data disk from the helper instance",
"zh-cn": "卸载临时实例的数据盘"
},
"Properties": {
"instanceId": "{{ untilStackReady.helperInstanceId }}",
"diskId": "{{ querySystemDisks.diskId }}"
}
},
{
"Name": "untilUnreachableInstanceSystemDiskAvailable",
"Action": "ACS::WaitFor",
"OnError": "ACS::NEXT",
"Description": {
"en": "Waits for the disk to be detached",
"zh-cn": "等待磁盘卸载成功"
},
"Properties": {
"Service": "ECS",
"API": "DescribeDisks",
"Parameters": {
"DiskIds": [
"{{ querySystemDisks.diskId }}"
]
},
"DesiredValues": [
"Available"
],
"PropertySelector": "Disks.Disk[].Status"
}
},
{
"Name": "deleteStack",
"Action": "ACS::ExecuteApi",
"OnError": "ACS::NEXT",
"Description": {
"en": "Delete the ros resource stack",
"zh-cn": "删除Ros资源栈"
},
"Properties": {
"Service": "ROS",
"API": "DeleteStack",
"Parameters": {
"StackId": "{{createStack.StackId}}"
}
}
},
{
"Name": "untilStackDeleted",
"Action": "ACS::WaitFor",
"OnError": "ACS::NEXT",
"Description": {
"en": "Wait for the ros stack status DELETE_COMPLETE",
"zh-cn": "等待Ros资源栈至删除成功"
},
"Properties": {
"Service": "ROS",
"API": "GetStack",
"Parameters": {
"StackId": "{{createStack.StackId}}"
},
"DesiredValues": [
"DELETE_COMPLETE"
],
"StopRetryValues": [
"DELETE_FAILED",
"CHECK_FAILED"
],
"PropertySelector": "Status"
}
},
{
"Name": "checkForUnreachableInstanceSystemDiskAvailable",
"Action": "ACS::CheckFor",
"OnError": "ACS::END",
"Description": {
"en": "Check for the disk to be detached",
"zh-cn": "检查损伤的系统盘是否可挂载"
},
"Properties": {
"Service": "ECS",
"API": "DescribeDisks",
"Parameters": {
"DiskIds": [
"{{ querySystemDisks.diskId }}"
]
},
"DesiredValues": [
"Available"
],
"PropertySelector": "Disks.Disk[].Status"
}
},
{
"Name": "whetherCredentialTypeIsKeyPairName",
"Action": "ACS::Choice",
"OnError": "ACS::NEXT",
"Description": {
"en": "Choose next task by credential type input",
"zh-cn": "根据输入的登录凭证类型确定后续任务"
},
"Properties": {
"DefaultTask": "attachAsSysDiskWithKeyPairName",
"Choices": [
{
"When": {
"Fn::Equals": [
"Password",
"{{ credentialType }}"
]
},
"NextTask": "attachAsSysDisk"
}
]
}
},
{
"Name": "attachAsSysDiskWithKeyPairName",
"Action": "ACS::ExecuteAPI",
"OnSuccess": "untilDiskAttached",
"OnError": "ACS::NEXT",
"Description": {
"en": "Attaches the source system disk to unreachable instance and set PairName credential type for root",
"zh-cn": "将救治过的损伤系统盘挂回原实例,并且为root设置密钥对形式的登录凭证"
},
"Properties": {
"Service": "ECS",
"API": "AttachDisk",
"Parameters": {
"DiskId": "{{ querySystemDisks.diskId }}",
"InstanceId": "{{ unreachableInstanceId }}",
"Bootable": "true",
"KeyPairName": "{{credentialValue}}"
}
}
},
{
"Name": "attachAsSysDisk",
"Action": "ACS::ExecuteAPI",
"OnError": "ACS::NEXT",
"Description": {
"en": "Attaches the source system disk to unreachable instance and set Password credential type for root",
"zh-cn": "将救治过的损伤系统盘挂回原实例,并且为root设置自定义密码形式的登录凭证"
},
"Properties": {
"Service": "ECS",
"API": "AttachDisk",
"Parameters": {
"DiskId": "{{ querySystemDisks.diskId }}",
"InstanceId": "{{ unreachableInstanceId }}",
"Bootable": "true",
"Password": "{{credentialValue}}"
}
}
},
{
"Name": "untilDiskAttached",
"Action": "ACS::WaitFor",
"OnError": "ACS::NEXT",
"Description": {
"en": "Waits for the system disk to be attached",
"zh-cn": "等待系统盘挂回原实例成功"
},
"Retries": 7,
"Properties": {
"Service": "ECS",
"API": "DescribeDisks",
"Parameters": {
"DiskIds": [
"{{ querySystemDisks.diskId }}"
]
},
"DesiredValues": [
"In_use"
],
"PropertySelector": "Disks.Disk[].Status"
}
},
{
"Name": "whetherStartUnreachableInstance",
"Action": "ACS::Choice",
"OnError": "ACS::NEXT",
"Description": {
"en": "Choose next task by original instance status",
"zh-cn": "根据实例初始状态选择后续任务"
},
"Properties": {
"DefaultTask": "ACS::END",
"Choices": [
{
"When": {
"Fn::Equals": [
"Running",
"{{ checkInstanceReady.status }}"
]
},
"NextTask": "startUnreachableInstance"
}
]
}
},
{
"Name": "startUnreachableInstance",
"Action": "ACS::ECS::StartInstance",
"Description": {
"en": "Starts the unreachable instance",
"zh-cn": "启动被救治的实例"
},
"Properties": {
"instanceId": "{{ unreachableInstanceId}}"
}
}
],
"Outputs": {
"diskId": {
"Type": "String",
"Value": "{{ querySystemDisks.diskId }}"
},
"imageId": {
"Type": "String",
"Value": "{{ createImage.imageId }}"
},
"rtCommandOutput": {
"Type": "String",
"Value": "{{ runcommand.commandOutput }}"
},
"finalHelperInstanceType": {
"Type": "String",
"Value": "{{checkAvailableInstanceTypesExist.availableInstanceType}}"
}
},
"Metadata": {
"ALIYUN::OOS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"credentialType",
"credentialValue",
"imagePrefix",
"helperInstanceTypes"
],
"Label": {
"default": {
"zh-cn": "设置参数",
"en": "Configure Parameters"
}
}
},
{
"Parameters": [
"unreachableInstanceId"
],
"Label": {
"default": {
"zh-cn": "选择实例",
"en": "Select ECS Instance"
}
}
},
{
"Parameters": [
"OOSAssumeRole"
],
"Label": {
"default": {
"zh-cn": "高级选项",
"en": "Control Options"
}
}
}
]
}
}
}