github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/servers/util.go (about) 1 package servers 2 3 import "github.com/huaweicloud/golangsdk" 4 5 // WaitForStatus will continually poll a server until it successfully 6 // transitions to a specified status. It will do this for at most the number 7 // of seconds specified. 8 func WaitForStatus(c *golangsdk.ServiceClient, id, status string, secs int) error { 9 return golangsdk.WaitFor(secs, func() (bool, error) { 10 current, err := Get(c, id).Extract() 11 if err != nil { 12 return false, err 13 } 14 15 if current.Status == status { 16 return true, nil 17 } 18 19 return false, nil 20 }) 21 }