blob: ff2174eceecc22dcd3c386932c5ee6e3dd90f495 [file] [log] [blame]
Samuel A. Falvo IIe91ff6d2013-07-11 15:46:10 -07001package main
2
3import (
4 "flag"
5 "fmt"
Samuel A. Falvo IIe91ff6d2013-07-11 15:46:10 -07006 "github.com/rackspace/gophercloud"
7)
8
9var region, serverName, imageRef, flavorRef *string
10var adminPass = flag.String("a", "", "Administrator password (auto-assigned if none)")
Samuel A. Falvo II4b0ba752013-07-11 17:42:26 -070011var quiet = flag.Bool("quiet", false, "Quiet mode for acceptance tests. $? non-zero if error.")
Samuel A. Falvo IIe91ff6d2013-07-11 15:46:10 -070012
Samuel A. Falvo II4b0ba752013-07-11 17:42:26 -070013func configure() {
Samuel A. Falvo IIe4a3e422013-09-13 12:36:37 -070014 region = flag.String("r", "", "Region in which to create the server. Leave blank for provider-default region.")
Samuel A. Falvo IIe3b2d7a2013-07-12 11:08:02 -070015 serverName = flag.String("n", randomString("ACPTTEST--", 16), "Server name (what you see in the control panel)")
Samuel A. Falvo II4b0ba752013-07-11 17:42:26 -070016 imageRef = flag.String("i", "", "ID of image to deploy onto the server")
17 flavorRef = flag.String("f", "", "Flavor of server to deploy image upon")
Samuel A. Falvo IIe91ff6d2013-07-11 15:46:10 -070018
19 flag.Parse()
Samuel A. Falvo II4b0ba752013-07-11 17:42:26 -070020}
Samuel A. Falvo IIe91ff6d2013-07-11 15:46:10 -070021
Samuel A. Falvo II4b0ba752013-07-11 17:42:26 -070022func main() {
23 configure()
Samuel A. Falvo IIe91ff6d2013-07-11 15:46:10 -070024
Samuel A. Falvo II887d7802013-07-29 17:55:37 -070025 withIdentity(false, func(auth gophercloud.AccessProvider) {
26 withServerApi(auth, func(servers gophercloud.CloudServersProvider) {
27 _, err := createServer(servers, *imageRef, *flavorRef, *serverName, *adminPass)
28 if err != nil {
29 panic(err)
30 }
Samuel A. Falvo IIe91ff6d2013-07-11 15:46:10 -070031
Samuel A. Falvo II887d7802013-07-29 17:55:37 -070032 allServers, err := servers.ListServers()
33 if err != nil {
34 panic(err)
35 }
36
37 if !*quiet {
38 fmt.Printf("ID,Name,Status,Progress\n")
39 for _, i := range allServers {
40 fmt.Printf("%s,\"%s\",%s,%d\n", i.Id, i.Name, i.Status, i.Progress)
41 }
42 }
43 })
Samuel A. Falvo IIe91ff6d2013-07-11 15:46:10 -070044 })
Samuel A. Falvo IIe91ff6d2013-07-11 15:46:10 -070045}