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