util.go 532 B

1234567891011121314151617181920212223
  1. package volumes
  2. import (
  3. "devel.mephi.ru/iacherepanov/openstack-gophercloud"
  4. )
  5. // WaitForStatus will continually poll the resource, checking for a particular
  6. // status. It will do this for the amount of seconds defined.
  7. func WaitForStatus(c *gophercloud.ServiceClient, id, status string, secs int) error {
  8. return gophercloud.WaitFor(secs, func() (bool, error) {
  9. current, err := Get(c, id).Extract()
  10. if err != nil {
  11. return false, err
  12. }
  13. if current.Status == status {
  14. return true, nil
  15. }
  16. return false, nil
  17. })
  18. }