Samuel A. Falvo II | 2dd7d2f | 2014-06-30 16:18:08 -0700 | [diff] [blame] | 1 | // +build acceptance,old |
| 2 | |
Samuel A. Falvo II | adbecf9 | 2013-07-30 13:13:59 -0700 | [diff] [blame] | 3 | package main |
| 4 | |
| 5 | import ( |
Samuel A. Falvo II | adbecf9 | 2013-07-30 13:13:59 -0700 | [diff] [blame] | 6 | "flag" |
Jon Perritt | 2be65d1 | 2013-12-13 17:21:09 -0600 | [diff] [blame] | 7 | "fmt" |
Max Lincoln | 28b4956 | 2013-12-13 13:23:44 -0300 | [diff] [blame] | 8 | "github.com/rackspace/gophercloud" |
Samuel A. Falvo II | adbecf9 | 2013-07-30 13:13:59 -0700 | [diff] [blame] | 9 | ) |
| 10 | |
| 11 | var quiet = flag.Bool("quiet", false, "Quiet mode, for acceptance testing. $? still indicates errors though.") |
| 12 | |
| 13 | func main() { |
| 14 | flag.Parse() |
| 15 | |
| 16 | withIdentity(false, func(acc gophercloud.AccessProvider) { |
| 17 | withServerApi(acc, func(servers gophercloud.CloudServersProvider) { |
| 18 | log("Creating server") |
| 19 | serverId, err := createServer(servers, "", "", "", "") |
| 20 | if err != nil { |
| 21 | panic(err) |
| 22 | } |
| 23 | waitForServerState(servers, serverId, "ACTIVE") |
| 24 | |
| 25 | log("Soft-rebooting server") |
| 26 | servers.RebootServer(serverId, false) |
| 27 | waitForServerState(servers, serverId, "REBOOT") |
| 28 | waitForServerState(servers, serverId, "ACTIVE") |
| 29 | |
| 30 | log("Hard-rebooting server") |
| 31 | servers.RebootServer(serverId, true) |
| 32 | waitForServerState(servers, serverId, "HARD_REBOOT") |
| 33 | waitForServerState(servers, serverId, "ACTIVE") |
| 34 | |
| 35 | log("Done") |
| 36 | servers.DeleteServerById(serverId) |
| 37 | }) |
| 38 | }) |
| 39 | } |
| 40 | |
| 41 | func log(s string) { |
| 42 | if !*quiet { |
| 43 | fmt.Println(s) |
| 44 | } |
| 45 | } |