Add server action: change admin password
diff --git a/acceptance/openstack/compute_test.go b/acceptance/openstack/compute_test.go
index 4c487c7..f8c80f5 100644
--- a/acceptance/openstack/compute_test.go
+++ b/acceptance/openstack/compute_test.go
@@ -184,3 +184,30 @@
return
}
}
+
+func TestServerAction(t *testing.T) {
+ ts, err := setupForCRUD()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ err = createServer(ts)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ defer func(){
+ servers.Delete(ts.client, ts.createdServer.Id)
+ }()
+
+ err = waitForStatus(ts, "ACTIVE")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ err = changeAdminPassword(ts)
+ if err != nil {
+ t.Fatal(err)
+ }
+}
+
diff --git a/acceptance/openstack/tools_test.go b/acceptance/openstack/tools_test.go
index c9a004f..0743221 100644
--- a/acceptance/openstack/tools_test.go
+++ b/acceptance/openstack/tools_test.go
@@ -169,13 +169,13 @@
}
if ts.gottenServer.Status == s {
- fmt.Printf("Server created after %d seconds (approximately)\n", 300-timeout)
+ fmt.Printf("Server reached state %s after %d seconds (approximately)\n", s, 300-timeout)
break
}
}
if err == errTimeout {
- fmt.Printf("I'm not waiting around.\n")
+ fmt.Printf("Time out -- I'm not waiting around.\n")
err = nil
}
@@ -229,6 +229,27 @@
return err
}
+func changeAdminPassword(ts *testState) error {
+ fmt.Println("Current password: "+ts.createdServer.AdminPass)
+ randomPassword := randomString("", 16)
+ for randomPassword == ts.createdServer.AdminPass {
+ randomPassword = randomString("", 16)
+ }
+ fmt.Println(" New password: "+randomPassword)
+
+ err := servers.ChangeAdminPassword(ts.client, ts.createdServer.Id, randomPassword)
+ if err != nil {
+ return err
+ }
+
+ err = waitForStatus(ts, "PASSWORD")
+ if err != nil {
+ return err
+ }
+
+ return waitForStatus(ts, "ACTIVE")
+}
+
// randomString generates a string of given length, but random content.
// All content will be within the ASCII graphic character set.
// (Implementation from Even Shaw's contribution on