-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
68 lines (54 loc) · 1.02 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
package main
import (
"log"
"os"
"github.com/luthermonson/go-proxmox"
)
var nodes = []ProxmoxNode{}
var client = connect()
var proxmoxLogger = &proxmox.LeveledLogger{Level: proxmox.LevelWarn}
var logger = log.New(os.Stdout, "", log.Default().Flags())
// Main function
func main() {
args := os.Args
// set verbose logging
if checkParams(args, "debug", false) {
logger.SetFlags(log.LstdFlags | log.Lshortfile)
proxmoxLogger.Level = proxmox.LevelDebug
}
if os.Args == nil || len(args) < 2 {
help()
os.Exit(1)
}
// switch operation
switch os.Args[1] {
case "resources":
updateNodes()
resources()
os.Exit(0)
case "list":
updateNodes()
list()
os.Exit(0)
case "clone":
updateNodes()
cloneMapper()
os.Exit(0)
case "delete":
updateNodes()
delete()
os.Exit(0)
case "nextNode":
updateNodes()
print("The next least used node is ", getLeastUsedNode().Name)
os.Exit(0)
default:
help()
os.Exit(1)
}
}
// update node loop
func updateNodes() {
// get nodes from config
getNodes()
}