Samuel A. Falvo II | 414c15c | 2013-08-01 15:16:46 -0700 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "flag" |
| 6 | "github.com/rackspace/gophercloud" |
| 7 | ) |
| 8 | |
| 9 | var quiet = flag.Bool("quiet", false, "Quiet mode, for acceptance testing. $? still indicates errors though.") |
| 10 | |
| 11 | func main() { |
| 12 | flag.Parse() |
| 13 | withIdentity(false, func(acc gophercloud.AccessProvider) { |
| 14 | withServerApi(acc, func(servers gophercloud.CloudServersProvider) { |
| 15 | log("Creating server") |
| 16 | id, err := createServer(servers, "", "", "", "") |
| 17 | if err != nil { |
| 18 | panic(err) |
| 19 | } |
| 20 | waitForServerState(servers, id, "ACTIVE") |
| 21 | defer servers.DeleteServerById(id) |
| 22 | |
| 23 | log("Rebuilding server") |
| 24 | newDetails, err := servers.RebuildServer(id, gophercloud.NewServer{ |
| 25 | Name: randomString("ACPTTEST", 32), |
| 26 | ImageRef: findAlternativeImage(), |
| 27 | FlavorRef: findAlternativeFlavor(), |
| 28 | AdminPass: randomString("", 16), |
| 29 | }) |
| 30 | if err != nil { |
| 31 | panic(err) |
| 32 | } |
| 33 | waitForServerState(servers, newDetails.Id, "ACTIVE") |
| 34 | |
| 35 | log("Done") |
| 36 | }) |
| 37 | }) |
| 38 | } |
| 39 | |
| 40 | func log(s string) { |
| 41 | if !*quiet { |
| 42 | fmt.Println(s) |
| 43 | } |
| 44 | } |