Samuel A. Falvo II | 2dd7d2f | 2014-06-30 16:18:08 -0700 | [diff] [blame] | 1 | // +build acceptance,old |
| 2 | |
Samuel A. Falvo II | e91ff6d | 2013-07-11 15:46:10 -0700 | [diff] [blame] | 3 | package main |
| 4 | |
| 5 | import ( |
| 6 | "flag" |
| 7 | "fmt" |
Samuel A. Falvo II | e91ff6d | 2013-07-11 15:46:10 -0700 | [diff] [blame] | 8 | "github.com/rackspace/gophercloud" |
| 9 | ) |
| 10 | |
| 11 | var region, serverName, imageRef, flavorRef *string |
| 12 | var adminPass = flag.String("a", "", "Administrator password (auto-assigned if none)") |
Samuel A. Falvo II | 4b0ba75 | 2013-07-11 17:42:26 -0700 | [diff] [blame] | 13 | var quiet = flag.Bool("quiet", false, "Quiet mode for acceptance tests. $? non-zero if error.") |
Samuel A. Falvo II | e91ff6d | 2013-07-11 15:46:10 -0700 | [diff] [blame] | 14 | |
Samuel A. Falvo II | 4b0ba75 | 2013-07-11 17:42:26 -0700 | [diff] [blame] | 15 | func configure() { |
Samuel A. Falvo II | e4a3e42 | 2013-09-13 12:36:37 -0700 | [diff] [blame] | 16 | region = flag.String("r", "", "Region in which to create the server. Leave blank for provider-default region.") |
Samuel A. Falvo II | e3b2d7a | 2013-07-12 11:08:02 -0700 | [diff] [blame] | 17 | serverName = flag.String("n", randomString("ACPTTEST--", 16), "Server name (what you see in the control panel)") |
Samuel A. Falvo II | 4b0ba75 | 2013-07-11 17:42:26 -0700 | [diff] [blame] | 18 | imageRef = flag.String("i", "", "ID of image to deploy onto the server") |
| 19 | flavorRef = flag.String("f", "", "Flavor of server to deploy image upon") |
Samuel A. Falvo II | e91ff6d | 2013-07-11 15:46:10 -0700 | [diff] [blame] | 20 | |
| 21 | flag.Parse() |
Samuel A. Falvo II | 4b0ba75 | 2013-07-11 17:42:26 -0700 | [diff] [blame] | 22 | } |
Samuel A. Falvo II | e91ff6d | 2013-07-11 15:46:10 -0700 | [diff] [blame] | 23 | |
Samuel A. Falvo II | 4b0ba75 | 2013-07-11 17:42:26 -0700 | [diff] [blame] | 24 | func main() { |
| 25 | configure() |
Samuel A. Falvo II | e91ff6d | 2013-07-11 15:46:10 -0700 | [diff] [blame] | 26 | |
Samuel A. Falvo II | 887d780 | 2013-07-29 17:55:37 -0700 | [diff] [blame] | 27 | withIdentity(false, func(auth gophercloud.AccessProvider) { |
| 28 | withServerApi(auth, func(servers gophercloud.CloudServersProvider) { |
| 29 | _, err := createServer(servers, *imageRef, *flavorRef, *serverName, *adminPass) |
| 30 | if err != nil { |
| 31 | panic(err) |
| 32 | } |
Samuel A. Falvo II | e91ff6d | 2013-07-11 15:46:10 -0700 | [diff] [blame] | 33 | |
Samuel A. Falvo II | 887d780 | 2013-07-29 17:55:37 -0700 | [diff] [blame] | 34 | allServers, err := servers.ListServers() |
| 35 | if err != nil { |
| 36 | panic(err) |
| 37 | } |
| 38 | |
| 39 | if !*quiet { |
| 40 | fmt.Printf("ID,Name,Status,Progress\n") |
| 41 | for _, i := range allServers { |
| 42 | fmt.Printf("%s,\"%s\",%s,%d\n", i.Id, i.Name, i.Status, i.Progress) |
| 43 | } |
| 44 | } |
| 45 | }) |
Samuel A. Falvo II | e91ff6d | 2013-07-11 15:46:10 -0700 | [diff] [blame] | 46 | }) |
Samuel A. Falvo II | e91ff6d | 2013-07-11 15:46:10 -0700 | [diff] [blame] | 47 | } |