provider/alicloud: Fix allocating public ip bug (#15049)

* fix allocating public ip bug

* modify
This commit is contained in:
He Guimin 2017-06-06 01:27:32 +08:00 committed by Paul Stack
parent e7628c39ce
commit 4c16fa9dbb
1 changed files with 10 additions and 12 deletions

View File

@ -191,25 +191,23 @@ func resourceAliyunInstanceCreate(d *schema.ResourceData, meta interface{}) erro
d.SetId(instanceID) d.SetId(instanceID)
d.Set("password", d.Get("password")) 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, // after instance created, its status is pending,
// so we need to wait it become to stopped and then start it // so we need to wait it become to stopped and then start it
if err := conn.WaitForInstance(d.Id(), ecs.Stopped, defaultTimeout); err != nil { if err := conn.WaitForInstanceAsyn(d.Id(), ecs.Stopped, defaultTimeout); err != nil {
log.Printf("[DEBUG] WaitForInstance %s got error: %#v", ecs.Stopped, err) 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 { if err := conn.StartInstance(d.Id()); err != nil {
return fmt.Errorf("Start instance got error: %#v", err) return fmt.Errorf("Start instance got error: %#v", err)
} }
if err := conn.WaitForInstance(d.Id(), ecs.Running, defaultTimeout); err != nil { 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) 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 // after instance created, its status change from pending, starting to running
if err := conn.WaitForInstanceAsyn(d.Id(), ecs.Running, defaultTimeout); err != nil { 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 { 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 { 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) return resourceAliyunInstanceUpdate(d, meta)