Samuel A. Falvo II | 2dd7d2f | 2014-06-30 16:18:08 -0700 | [diff] [blame] | 1 | // +build acceptance,old |
| 2 | |
Samuel A. Falvo II | 414c15c | 2013-08-01 15:16:46 -0700 | [diff] [blame] | 3 | package main |
| 4 | |
| 5 | import ( |
Samuel A. Falvo II | 414c15c | 2013-08-01 15:16:46 -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 | 414c15c | 2013-08-01 15:16:46 -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 | withIdentity(false, func(acc gophercloud.AccessProvider) { |
| 16 | withServerApi(acc, func(servers gophercloud.CloudServersProvider) { |
| 17 | log("Creating server") |
| 18 | id, err := createServer(servers, "", "", "", "") |
| 19 | if err != nil { |
| 20 | panic(err) |
| 21 | } |
| 22 | waitForServerState(servers, id, "ACTIVE") |
| 23 | defer servers.DeleteServerById(id) |
| 24 | |
| 25 | log("Rebuilding server") |
| 26 | newDetails, err := servers.RebuildServer(id, gophercloud.NewServer{ |
Jon Perritt | 2be65d1 | 2013-12-13 17:21:09 -0600 | [diff] [blame] | 27 | Name: randomString("ACPTTEST", 32), |
| 28 | ImageRef: findAlternativeImage(), |
Samuel A. Falvo II | 414c15c | 2013-08-01 15:16:46 -0700 | [diff] [blame] | 29 | FlavorRef: findAlternativeFlavor(), |
| 30 | AdminPass: randomString("", 16), |
| 31 | }) |
| 32 | if err != nil { |
| 33 | panic(err) |
| 34 | } |
| 35 | waitForServerState(servers, newDetails.Id, "ACTIVE") |
| 36 | |
| 37 | log("Done") |
| 38 | }) |
| 39 | }) |
| 40 | } |
| 41 | |
| 42 | func log(s string) { |
| 43 | if !*quiet { |
| 44 | fmt.Println(s) |
| 45 | } |
| 46 | } |