blob: 48745a6a497a2f9d8e3d4e55e983aff5c4c9619e [file] [log] [blame]
Samuel A. Falvo II414c15c2013-08-01 15:16:46 -07001package main
2
3import (
Samuel A. Falvo II414c15c2013-08-01 15:16:46 -07004 "flag"
Jon Perritt2be65d12013-12-13 17:21:09 -06005 "fmt"
Max Lincoln28b49562013-12-13 13:23:44 -03006 "github.com/rackspace/gophercloud"
Samuel A. Falvo II414c15c2013-08-01 15:16:46 -07007)
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{
Jon Perritt2be65d12013-12-13 17:21:09 -060025 Name: randomString("ACPTTEST", 32),
26 ImageRef: findAlternativeImage(),
Samuel A. Falvo II414c15c2013-08-01 15:16:46 -070027 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}