Implement Rebuild server functionality.
I thought I'd had this in already. Apparently not.
diff --git a/acceptance/13-rebuild-server.go b/acceptance/13-rebuild-server.go
new file mode 100644
index 0000000..12aed26
--- /dev/null
+++ b/acceptance/13-rebuild-server.go
@@ -0,0 +1,44 @@
+package main
+
+import (
+ "fmt"
+ "flag"
+ "github.com/rackspace/gophercloud"
+)
+
+var quiet = flag.Bool("quiet", false, "Quiet mode, for acceptance testing. $? still indicates errors though.")
+
+func main() {
+ flag.Parse()
+ withIdentity(false, func(acc gophercloud.AccessProvider) {
+ withServerApi(acc, func(servers gophercloud.CloudServersProvider) {
+ log("Creating server")
+ id, err := createServer(servers, "", "", "", "")
+ if err != nil {
+ panic(err)
+ }
+ waitForServerState(servers, id, "ACTIVE")
+ defer servers.DeleteServerById(id)
+
+ log("Rebuilding server")
+ newDetails, err := servers.RebuildServer(id, gophercloud.NewServer{
+ Name: randomString("ACPTTEST", 32),
+ ImageRef: findAlternativeImage(),
+ FlavorRef: findAlternativeFlavor(),
+ AdminPass: randomString("", 16),
+ })
+ if err != nil {
+ panic(err)
+ }
+ waitForServerState(servers, newDetails.Id, "ACTIVE")
+
+ log("Done")
+ })
+ })
+}
+
+func log(s string) {
+ if !*quiet {
+ fmt.Println(s)
+ }
+}
diff --git a/acceptance/libargs.go b/acceptance/libargs.go
index 932e61e..5edb445 100644
--- a/acceptance/libargs.go
+++ b/acceptance/libargs.go
@@ -130,6 +130,12 @@
return "3" // 1GB image, up from 512MB image
}
+// findAlternativeImage locates an image to resize or rebuild a server with. It is guaranteed to be
+// different than what aSuitableImage() returns. If none could be found, this function will panic.
+func findAlternativeImage() string {
+ return "c6f9c411-e708-4952-91e5-62ded5ea4d3e"
+}
+
// withIdentity authenticates the user against the provider's identity service, and provides an
// accessor for additional services.
func withIdentity(ar bool, f func(gophercloud.AccessProvider)) {