-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
78 lines (59 loc) · 1.63 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
import (
"fmt"
log "github.com/Sirupsen/logrus"
docopt "github.com/docopt/docopt-go"
)
const version = "v0.1.9"
func main() {
usage := `Usage:
onlabs images [--verbose|-v]
onlabs servers [--verbose|-v]
onlabs volumes [--verbose|-v]
onlabs snapshots [--verbose|-v]
onlabs ips [--verbose|-v]
onlabs actions --server=SERVERID [--verbose|-v]
onlabs reboot --server=SERVERID [--verbose|-v]
onlabs poweron --server=SERVERID [--verbose|-v]
onlabs poweroff --server=SERVERID [--verbose|-v]
onlabs terminate --server=SERVERID [--verbose|-v]
Options:
-h --help this message
-v --verbose verbose mode`
ver := fmt.Sprintf("Online Labs Client: %s", version)
arguments, _ := docopt.Parse(usage, nil, true, ver, false)
if arguments["--verbose"].(bool) {
log.SetLevel(log.DebugLevel)
}
log.Debugf("args: %v", arguments)
if arguments["images"].(bool) {
cmdListImages()
}
if arguments["servers"].(bool) {
cmdListServers()
}
if arguments["volumes"].(bool) {
cmdListVolumes()
}
if arguments["snapshots"].(bool) {
cmdListSnapshots()
}
if arguments["ips"].(bool) {
cmdListIPs()
}
if arguments["actions"].(bool) {
cmdListActions(arguments["--server"].(string))
}
if arguments["reboot"].(bool) {
cmdDoActions(arguments["--server"].(string), "reboot")
}
if arguments["poweron"].(bool) {
cmdDoActions(arguments["--server"].(string), "poweron")
}
if arguments["poweroff"].(bool) {
cmdDoActions(arguments["--server"].(string), "poweroff")
}
if arguments["terminate"].(bool) {
cmdDoActions(arguments["--server"].(string), "terminate")
}
}