Samuel A. Falvo II | 72ac2dd | 2013-07-31 13:45:05 -0700 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
Samuel A. Falvo II | 72ac2dd | 2013-07-31 13:45:05 -0700 | [diff] [blame] | 4 | "flag" |
Jon Perritt | 2be65d1 | 2013-12-13 17:21:09 -0600 | [diff] [blame^] | 5 | "fmt" |
Max Lincoln | 28b4956 | 2013-12-13 13:23:44 -0300 | [diff] [blame] | 6 | "github.com/rackspace/gophercloud" |
Samuel A. Falvo II | 72ac2dd | 2013-07-31 13:45:05 -0700 | [diff] [blame] | 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("Updating name of server") |
| 24 | newName := randomString("ACPTTEST", 32) |
| 25 | newDetails, err := servers.UpdateServer(id, gophercloud.NewServerSettings{ |
| 26 | Name: newName, |
| 27 | }) |
| 28 | if err != nil { |
| 29 | panic(err) |
| 30 | } |
| 31 | if newDetails.Name != newName { |
| 32 | panic("Name change didn't appear to take") |
| 33 | } |
| 34 | |
| 35 | log("Done") |
| 36 | }) |
| 37 | }) |
| 38 | } |
| 39 | |
| 40 | func log(s string) { |
| 41 | if !*quiet { |
| 42 | fmt.Println(s) |
| 43 | } |
| 44 | } |