blob: 12aed2697e915fe7524bb24a7dc4aea02f0ce62c [file] [log] [blame]
Samuel A. Falvo II414c15c2013-08-01 15:16:46 -07001package main
2
3import (
4 "fmt"
5 "flag"
6 "github.com/rackspace/gophercloud"
7)
8
9var quiet = flag.Bool("quiet", false, "Quiet mode, for acceptance testing. $? still indicates errors though.")
10
11func main() {
12 flag.Parse()
13 withIdentity(false, func(acc gophercloud.AccessProvider) {
14 withServerApi(acc, func(servers gophercloud.CloudServersProvider) {
15 log("Creating server")
16 id, err := createServer(servers, "", "", "", "")
17 if err != nil {
18 panic(err)
19 }
20 waitForServerState(servers, id, "ACTIVE")
21 defer servers.DeleteServerById(id)
22
23 log("Rebuilding server")
24 newDetails, err := servers.RebuildServer(id, gophercloud.NewServer{
25 Name: randomString("ACPTTEST", 32),
26 ImageRef: findAlternativeImage(),
27 FlavorRef: findAlternativeFlavor(),
28 AdminPass: randomString("", 16),
29 })
30 if err != nil {
31 panic(err)
32 }
33 waitForServerState(servers, newDetails.Id, "ACTIVE")
34
35 log("Done")
36 })
37 })
38}
39
40func log(s string) {
41 if !*quiet {
42 fmt.Println(s)
43 }
44}