@@ -415,7 +415,7 @@ func NewCmdUHostCreate() *cobra.Command {
415
415
wg := & sync.WaitGroup {}
416
416
tokens := make (chan struct {}, concurrent )
417
417
wg .Add (count )
418
- batchRename , err := regexp .Match (`[%d,%d ]` , []byte (* req .Name ))
418
+ batchRename , err := regexp .Match (`\[\d+,\d+\ ]` , []byte (* req .Name ))
419
419
if err != nil || ! batchRename {
420
420
batchRename = false
421
421
}
@@ -610,6 +610,11 @@ func createUhostWrapper(req *uhost.CreateUHostInstanceRequest, updateEIPReq *une
610
610
}
611
611
612
612
func createMultipleUhost (req * uhost.CreateUHostInstanceRequest , count int , updateEIPReq * unet.UpdateEIPAttributeRequest , bindEipIDs []string , async bool ) (bool , []string ) {
613
+ if req .MaxCount == nil {
614
+ req .MaxCount = sdk .Int (1 )
615
+ }
616
+ req .MaxCount = sdk .Int (count )
617
+
613
618
resp , err := base .BizClient .CreateUHostInstance (req )
614
619
block := ux .NewBlock ()
615
620
ux .Doc .Append (block )
@@ -626,15 +631,15 @@ func createMultipleUhost(req *uhost.CreateUHostInstanceRequest, count int, updat
626
631
}
627
632
628
633
logs = append (logs , fmt .Sprintf ("resp:%#v" , resp ))
629
- if req .MaxCount == nil {
630
- req .MaxCount = sdk .Int (1 )
631
- }
632
- req .MaxCount = sdk .Int (count )
634
+
633
635
if len (resp .UHostIds ) != * req .MaxCount {
634
636
block .Append (fmt .Sprintf ("expect uhost count %d, accept %d" , count , len (resp .UHostIds )))
635
637
return false , logs
636
638
}
637
639
for i , uhostID := range resp .UHostIds {
640
+ block = ux .NewBlock ()
641
+ ux .Doc .Append (block )
642
+
638
643
text := fmt .Sprintf ("the uhost[%s]" , uhostID )
639
644
if len (req .Disks ) > 1 {
640
645
text = fmt .Sprintf ("%s which attached a data disk" , text )
@@ -649,9 +654,13 @@ func createMultipleUhost(req *uhost.CreateUHostInstanceRequest, count int, updat
649
654
if async {
650
655
block .Append (text )
651
656
} else {
652
- uhostSpoller .Sspoll (resp .UHostIds [0 ], text , []string {status .HOST_RUNNING , status .HOST_FAIL }, block , & req .CommonBase )
657
+ uhostSpoller .Sspoll (uhostID , text , []string {status .HOST_RUNNING , status .HOST_FAIL }, block , & req .CommonBase )
658
+ }
659
+ bindEipID := ""
660
+ if len (bindEipIDs ) > i {
661
+ bindEipID = bindEipIDs [i ]
653
662
}
654
- bindEipID := bindEipIDs [ i ]
663
+
655
664
if bindEipID != "" {
656
665
eip := base .PickResourceID (bindEipID )
657
666
logs = append (logs , fmt .Sprintf ("bind eip: %s" , eip ))
0 commit comments