-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscalet.go
More file actions
60 lines (51 loc) · 1.3 KB
/
scalet.go
File metadata and controls
60 lines (51 loc) · 1.3 KB
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
package main
import (
"strconv"
"github.com/vscale/go-vscale"
)
// (makeFrom, rplan, name, password, location string, doStart bool,keys []int64, wait bool)
func createScalet(from, rplan, name, location string, doStart bool, sshkeys string) *vscale_api_go.Scalet {
client := vscale_api_go.NewClient(token)
keys := stringToKeys(sshkeys)
scalet, _, _ := client.Scalet.CreateWithoutPassword(from,
rplan,
name,
location,
doStart,
keys,
false)
return scalet
}
func listScalet() {
client := vscale_api_go.NewClient(token)
scalets, _, _ := client.Scalet.List()
var data [][]string
for _, s := range *scalets {
data = append(data, []string{strconv.Itoa(int(s.CTID)),
s.Hostname, s.MadeFrom, s.Rplan, s.Location, s.PublicAddresses.Address, s.Status})
}
header := []string{"id",
"Hostname",
"template",
"Rplan",
"Location",
"Address",
"status"}
printTable(header, data)
}
func removeScalet(id int64) {
client := vscale_api_go.NewClient(token)
client.Scalet.Remove(id, false)
}
func restartScalet(id int64) {
client := vscale_api_go.NewClient(token)
client.Scalet.Restart(id, false)
}
func startScalet(id int64) {
client := vscale_api_go.NewClient(token)
client.Scalet.Start(id, false)
}
func stopScalet(id int64) {
client := vscale_api_go.NewClient(token)
client.Scalet.Stop(id, false)
}