blob: 657c7c821dc7bb27a490e29194a4f7fd313c6659 [file] [log] [blame]
Samuel A. Falvo II15da6ab2013-07-30 14:02:11 -07001package main
2
3import (
Samuel A. Falvo II15da6ab2013-07-30 14:02:11 -07004 "flag"
Jon Perritt2be65d12013-12-13 17:21:09 -06005 "fmt"
Max Lincoln28b49562013-12-13 13:23:44 -03006 "github.com/rackspace/gophercloud"
Samuel A. Falvo II15da6ab2013-07-30 14:02:11 -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("Rescuing server")
24 adminPass, err := servers.RescueServer(id)
25 if err != nil {
26 panic(err)
27 }
28 log(" Admin password = " + adminPass)
29 if len(adminPass) < 1 {
30 panic("Empty admin password")
31 }
32 waitForServerState(servers, id, "RESCUE")
33
34 log("Unrescuing server")
35 err = servers.UnrescueServer(id)
36 if err != nil {
37 panic(err)
38 }
39 waitForServerState(servers, id, "ACTIVE")
40
41 log("Done")
42 })
43 })
44}
45
46func log(s string) {
47 if !*quiet {
48 fmt.Println(s)
49 }
50}