blob: 1fae5ab442c04b92613ba5274a05c1dea7701d42 [file] [log] [blame]
Mark Peekd2188c42013-08-27 08:16:28 -07001package main
2
3import (
4 "flag"
5 "fmt"
6 "github.com/rackspace/gophercloud"
7)
8
9var quiet = flag.Bool("quiet", false, "Quiet mode for acceptance testing. $? non-zero on error though.")
Samuel A. Falvo IIe4a3e422013-09-13 12:36:37 -070010var rgn = flag.String("r", "", "Datacenter region to interrogate. Leave blank for provider-default region.")
Mark Peekd2188c42013-08-27 08:16:28 -070011
12func main() {
13 flag.Parse()
14
15 withIdentity(false, func(auth gophercloud.AccessProvider) {
16 withServerApi(auth, func(servers gophercloud.CloudServersProvider) {
17 log("Creating server")
18 serverId, err := createServer(servers, "", "", "", "")
19 if err != nil {
20 panic(err)
21 }
22 waitForServerState(servers, serverId, "ACTIVE")
23
24 log("Creating image")
25 name := randomString("ACPTTEST", 16)
26 createImage := gophercloud.CreateImage{
27 Name: name,
28 }
29 imageId, err := servers.CreateImage(serverId, createImage)
30 if err != nil {
31 panic(err)
32 }
33 waitForImageState(servers, imageId, "ACTIVE")
34
35 log("Deleting server")
36 servers.DeleteServerById(serverId)
37
38 log("Deleting image")
39 servers.DeleteImageById(imageId)
40
41 log("Done")
42 })
43 })
44}
45
46func log(s string) {
47 if !*quiet {
48 fmt.Println(s)
49 }
50}