Add ability to change admin password on a server
diff --git a/acceptance/09-change-admin-password.go b/acceptance/09-change-admin-password.go
new file mode 100644
index 0000000..4804726
--- /dev/null
+++ b/acceptance/09-change-admin-password.go
@@ -0,0 +1,54 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "github.com/rackspace/gophercloud"
+)
+
+var quiet = flag.Bool("quiet", false, "Quiet mode, for acceptance testing. $? still indicates errors though.")
+var serverId = flag.String("i", "", "ID of server whose admin password is to be changed.")
+var newPass = flag.String("p", "", "New password for the server.")
+
+func main() {
+ provider, username, password := getCredentials()
+ flag.Parse()
+
+ if *serverId == "" {
+ panic("Server ID expected [use -i option]")
+ }
+
+ if *newPass == "" {
+ panic("Password expected [use -p option]")
+ }
+
+ acc, err := gophercloud.Authenticate(
+ provider,
+ gophercloud.AuthOptions{
+ Username: username,
+ Password: password,
+ },
+ )
+ if err != nil {
+ panic(err)
+ }
+
+ api, err := gophercloud.ServersApi(acc, gophercloud.ApiCriteria{
+ Name: "cloudServersOpenStack",
+ Region: "DFW",
+ VersionId: "2",
+ UrlChoice: gophercloud.PublicURL,
+ })
+ if err != nil {
+ panic(err)
+ }
+
+ err = api.SetAdminPassword(*serverId, *newPass)
+ if err != nil {
+ panic(err)
+ }
+
+ if !*quiet {
+ fmt.Println("Password change request submitted.")
+ }
+}