blob: 03fd606cb7f2d2803e9305e577416ee8e7b4f75a [file] [log] [blame]
Samuel A. Falvo II2dd7d2f2014-06-30 16:18:08 -07001// +build acceptance,old
2
Samuel A. Falvo IIe91ff6d2013-07-11 15:46:10 -07003package main
4
5import (
6 "flag"
7 "fmt"
Samuel A. Falvo IIe91ff6d2013-07-11 15:46:10 -07008 "github.com/rackspace/gophercloud"
9)
10
11var region, serverName, imageRef, flavorRef *string
12var adminPass = flag.String("a", "", "Administrator password (auto-assigned if none)")
Samuel A. Falvo II4b0ba752013-07-11 17:42:26 -070013var quiet = flag.Bool("quiet", false, "Quiet mode for acceptance tests. $? non-zero if error.")
Samuel A. Falvo IIe91ff6d2013-07-11 15:46:10 -070014
Samuel A. Falvo II4b0ba752013-07-11 17:42:26 -070015func configure() {
Samuel A. Falvo IIe4a3e422013-09-13 12:36:37 -070016 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 -070017 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 -070018 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 IIe91ff6d2013-07-11 15:46:10 -070020
21 flag.Parse()
Samuel A. Falvo II4b0ba752013-07-11 17:42:26 -070022}
Samuel A. Falvo IIe91ff6d2013-07-11 15:46:10 -070023
Samuel A. Falvo II4b0ba752013-07-11 17:42:26 -070024func main() {
25 configure()
Samuel A. Falvo IIe91ff6d2013-07-11 15:46:10 -070026
Samuel A. Falvo II887d7802013-07-29 17:55:37 -070027 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 IIe91ff6d2013-07-11 15:46:10 -070033
Samuel A. Falvo II887d7802013-07-29 17:55:37 -070034 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 IIe91ff6d2013-07-11 15:46:10 -070046 })
Samuel A. Falvo IIe91ff6d2013-07-11 15:46:10 -070047}