blob: 008ad9d597d2dd604837f7c50d65fcdfcd427a9d [file] [log] [blame]
Samuel A. Falvo II2dd7d2f2014-06-30 16:18:08 -07001// +build acceptance,old
2
Samuel A. Falvo II15da6ab2013-07-30 14:02:11 -07003package main
4
5import (
Samuel A. Falvo II15da6ab2013-07-30 14:02:11 -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 II15da6ab2013-07-30 14:02:11 -07009)
10
11var quiet = flag.Bool("quiet", false, "Quiet mode, for acceptance testing. $? still indicates errors though.")
12
13func main() {
14 flag.Parse()
15 withIdentity(false, func(acc gophercloud.AccessProvider) {
16 withServerApi(acc, func(servers gophercloud.CloudServersProvider) {
17 log("Creating server")
18 id, err := createServer(servers, "", "", "", "")
19 if err != nil {
20 panic(err)
21 }
22 waitForServerState(servers, id, "ACTIVE")
23 defer servers.DeleteServerById(id)
24
25 log("Rescuing server")
26 adminPass, err := servers.RescueServer(id)
27 if err != nil {
28 panic(err)
29 }
30 log(" Admin password = " + adminPass)
31 if len(adminPass) < 1 {
32 panic("Empty admin password")
33 }
34 waitForServerState(servers, id, "RESCUE")
35
36 log("Unrescuing server")
37 err = servers.UnrescueServer(id)
38 if err != nil {
39 panic(err)
40 }
41 waitForServerState(servers, id, "ACTIVE")
42
43 log("Done")
44 })
45 })
46}
47
48func log(s string) {
49 if !*quiet {
50 fmt.Println(s)
51 }
52}