blob: 25d8c7253e43a08b97b8fad4018d293b8a024adf [file] [log] [blame]
Mark Peekd2188c42013-08-27 08:16:28 -07001package main
2
3import (
4 "flag"
5 "fmt"
Max Lincoln28b49562013-12-13 13:23:44 -03006 "github.com/rackspace/gophercloud"
Mark Peekd2188c42013-08-27 08:16:28 -07007)
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) {
Jon Perritt2be65d12013-12-13 17:21:09 -060047 if !*quiet {
48 fmt.Println(s)
49 }
Mark Peekd2188c42013-08-27 08:16:28 -070050}