Commit be606418 authored by Ross Smith II's avatar Ross Smith II

Merge pull request #1304 from lflux/fix-openstack-serverid-crash

Fix openstack ServerById crash
parents 753a990c 3af14d3d
......@@ -30,15 +30,25 @@ type StateChangeConf struct {
}
// ServerStateRefreshFunc returns a StateRefreshFunc that is used to watch
// an openstacn server.
// an openstack server.
func ServerStateRefreshFunc(csp gophercloud.CloudServersProvider, s *gophercloud.Server) StateRefreshFunc {
return func() (interface{}, string, int, error) {
resp, err := csp.ServerById(s.Id)
servers, err := csp.ListServers()
if err != nil {
log.Printf("Error on ServerStateRefresh: %s", err)
return nil, "", 0, err
}
var resp *gophercloud.Server
found := false
for _, server := range servers {
if server.Id == s.Id {
found = true
resp = &server
}
}
if found == false {
return nil, "DELETED", 0, nil
}
return resp, resp.Status, resp.Progress, nil
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment