blob: 4267633709d1feca21014d1e6ab7ff36391c55dd [file] [log] [blame]
Jon Perrittfa2c65e2014-10-02 20:32:43 -05001package volumes
2
3import (
Krzysztof Szukiełojć3f41d082017-05-07 14:43:06 +02004 "gerrit.mcp.mirantis.net/debian/gophercloud.git"
Jon Perrittfa2c65e2014-10-02 20:32:43 -05005)
6
Jamie Hannafordf7a898f2014-10-06 16:14:19 +02007// WaitForStatus will continually poll the resource, checking for a particular
8// status. It will do this for the amount of seconds defined.
Jon Perrittfa2c65e2014-10-02 20:32:43 -05009func WaitForStatus(c *gophercloud.ServiceClient, id, status string, secs int) error {
10 return gophercloud.WaitFor(secs, func() (bool, error) {
11 current, err := Get(c, id).Extract()
12 if err != nil {
13 return false, err
14 }
15
16 if current.Status == status {
17 return true, nil
18 }
19
20 return false, nil
21 })
22}