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