provider/alicloud: Fix allocating public ip bug (#15049)
* fix allocating public ip bug * modify
This commit is contained in:
parent
e7628c39ce
commit
4c16fa9dbb
|
@ -191,25 +191,23 @@ func resourceAliyunInstanceCreate(d *schema.ResourceData, meta interface{}) erro
|
|||
d.SetId(instanceID)
|
||||
|
||||
d.Set("password", d.Get("password"))
|
||||
//d.Set("system_disk_category", d.Get("system_disk_category"))
|
||||
//d.Set("system_disk_size", d.Get("system_disk_size"))
|
||||
|
||||
if err := allocateIpAndBandWidthRelative(d, meta); err != nil {
|
||||
return fmt.Errorf("allocateIpAndBandWidthRelative err: %#v", err)
|
||||
}
|
||||
|
||||
// after instance created, its status is pending,
|
||||
// so we need to wait it become to stopped and then start it
|
||||
if err := conn.WaitForInstance(d.Id(), ecs.Stopped, defaultTimeout); err != nil {
|
||||
log.Printf("[DEBUG] WaitForInstance %s got error: %#v", ecs.Stopped, err)
|
||||
if err := conn.WaitForInstanceAsyn(d.Id(), ecs.Stopped, defaultTimeout); err != nil {
|
||||
return fmt.Errorf("[DEBUG] WaitForInstance %s got error: %#v", ecs.Stopped, err)
|
||||
}
|
||||
|
||||
if err := allocateIpAndBandWidthRelative(d, meta); err != nil {
|
||||
return fmt.Errorf("allocateIpAndBandWidthRelative err: %#v", err)
|
||||
}
|
||||
|
||||
if err := conn.StartInstance(d.Id()); err != nil {
|
||||
return fmt.Errorf("Start instance got error: %#v", err)
|
||||
}
|
||||
|
||||
if err := conn.WaitForInstance(d.Id(), ecs.Running, defaultTimeout); err != nil {
|
||||
log.Printf("[DEBUG] WaitForInstance %s got error: %#v", ecs.Running, err)
|
||||
if err := conn.WaitForInstanceAsyn(d.Id(), ecs.Running, defaultTimeout); err != nil {
|
||||
return fmt.Errorf("[DEBUG] WaitForInstance %s got error: %#v", ecs.Running, err)
|
||||
}
|
||||
|
||||
return resourceAliyunInstanceUpdate(d, meta)
|
||||
|
@ -252,7 +250,7 @@ func resourceAliyunRunInstance(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
// after instance created, its status change from pending, starting to running
|
||||
if err := conn.WaitForInstanceAsyn(d.Id(), ecs.Running, defaultTimeout); err != nil {
|
||||
log.Printf("[DEBUG] WaitForInstance %s got error: %#v", ecs.Running, err)
|
||||
return fmt.Errorf("[DEBUG] WaitForInstance %s got error: %#v", ecs.Running, err)
|
||||
}
|
||||
|
||||
if err := allocateIpAndBandWidthRelative(d, meta); err != nil {
|
||||
|
@ -260,7 +258,7 @@ func resourceAliyunRunInstance(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
if err := conn.WaitForInstanceAsyn(d.Id(), ecs.Running, defaultTimeout); err != nil {
|
||||
log.Printf("[DEBUG] WaitForInstance %s got error: %#v", ecs.Running, err)
|
||||
return fmt.Errorf("[DEBUG] WaitForInstance %s got error: %#v", ecs.Running, err)
|
||||
}
|
||||
|
||||
return resourceAliyunInstanceUpdate(d, meta)
|
||||
|
|
Loading…
Reference in New Issue