blob: 78ab35701c46ade0dfee1cfabbaf05e4051c7d64 [file] [log] [blame]
Samuel A. Falvo IIadbecf92013-07-30 13:13:59 -07001package main
2
3import (
4 "fmt"
5 "flag"
6 "github.com/rackspace/gophercloud"
7)
8
9var quiet = flag.Bool("quiet", false, "Quiet mode, for acceptance testing. $? still indicates errors though.")
10
11func main() {
12 flag.Parse()
13
14 withIdentity(false, func(acc gophercloud.AccessProvider) {
15 withServerApi(acc, func(servers gophercloud.CloudServersProvider) {
16 log("Creating server")
17 serverId, err := createServer(servers, "", "", "", "")
18 if err != nil {
19 panic(err)
20 }
21 waitForServerState(servers, serverId, "ACTIVE")
22
23 log("Soft-rebooting server")
24 servers.RebootServer(serverId, false)
25 waitForServerState(servers, serverId, "REBOOT")
26 waitForServerState(servers, serverId, "ACTIVE")
27
28 log("Hard-rebooting server")
29 servers.RebootServer(serverId, true)
30 waitForServerState(servers, serverId, "HARD_REBOOT")
31 waitForServerState(servers, serverId, "ACTIVE")
32
33 log("Done")
34 servers.DeleteServerById(serverId)
35 })
36 })
37}
38
39func log(s string) {
40 if !*quiet {
41 fmt.Println(s)
42 }
43}