blob: 203b37d3eaaf5429e82b60a074ede87e23ca52d9 [file] [log] [blame]
Samuel A. Falvo II72ac2dd2013-07-31 13:45:05 -07001package main
2
3import (
4 "fmt"
5 "flag"
Max Lincoln28b49562013-12-13 13:23:44 -03006 "github.com/rackspace/gophercloud"
Samuel A. Falvo II72ac2dd2013-07-31 13:45:05 -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("Updating name of server")
24 newName := randomString("ACPTTEST", 32)
25 newDetails, err := servers.UpdateServer(id, gophercloud.NewServerSettings{
26 Name: newName,
27 })
28 if err != nil {
29 panic(err)
30 }
31 if newDetails.Name != newName {
32 panic("Name change didn't appear to take")
33 }
34
35 log("Done")
36 })
37 })
38}
39
40func log(s string) {
41 if !*quiet {
42 fmt.Println(s)
43 }
44}