-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvscale.go
More file actions
148 lines (140 loc) · 3.28 KB
/
vscale.go
File metadata and controls
148 lines (140 loc) · 3.28 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package main
import (
"fmt"
"os"
"sort"
"strconv"
"github.com/urfave/cli"
)
const (
ver = "0.1.0"
)
var (
token = ""
)
func main() {
if os.Getenv("VSCALE") != "" {
token = os.Getenv("VSCALE")
} else {
fmt.Println("VSCALE environment variable is not set")
}
app := cli.NewApp()
app.Name = "vscale"
app.Usage = "vscale.io command line interface"
app.Version = ver
app.Action = func(c *cli.Context) error {
return nil
}
app.Commands = []cli.Command{
{
Name: "account",
Aliases: []string{"a"},
Usage: "Gets account info",
Action: func(c *cli.Context) error {
getAccountInfo()
return nil
},
},
{
Name: "key",
Aliases: []string{"k"},
Usage: "Lists ssh keys",
Action: func(c *cli.Context) error {
listKeys()
return nil
},
},
{
Name: "scalet",
Aliases: []string{"s"},
Usage: "Manages scalets",
Subcommands: []cli.Command{
{
Name: "list",
Usage: "Gets the list of scalets",
Action: func(c *cli.Context) error {
listScalet()
return nil
},
},
{
Name: "create",
Usage: "Creates a new scalet",
Flags: []cli.Flag{
cli.StringFlag{Name: "name", Value: "", Usage: "set the hostname (required)"},
cli.StringFlag{Name: "key", Usage: "set the SSH keys, --key key1[,key2,key3] (required)"},
cli.StringFlag{Name: "from", Value: "ubuntu_16.04_64_001_master", Usage: "set the template for a scalet"},
cli.StringFlag{Name: "rplan", Value: "small", Usage: "set the rplan"},
cli.StringFlag{Name: "do_start", Value: "true", Usage: "set the do_start"},
cli.StringFlag{Name: "location", Value: "msk0", Usage: "set the location"},
},
Action: func(c *cli.Context) error {
dostart, _ := strconv.ParseBool(c.String("do_start"))
createScalet(c.String("from"),
c.String("rplan"),
c.String("name"),
c.String("location"),
dostart,
c.String("key"))
return nil
},
},
{
Name: "remove",
Usage: "Removes a scalet",
Flags: []cli.Flag{
cli.Int64Flag{Name: "id", Usage: "the ID of scalet to remove"},
},
Action: func(c *cli.Context) error {
removeScalet(c.Int64("id"))
return nil
},
},
{
Name: "restart",
Usage: "Restarts a scalet",
Flags: []cli.Flag{
cli.Int64Flag{Name: "id", Usage: "the ID of scalet to restart"},
},
Action: func(c *cli.Context) error {
restartScalet(c.Int64("id"))
return nil
},
},
{
Name: "stop",
Usage: "Stops a scalet",
Flags: []cli.Flag{
cli.StringFlag{Name: "id", Usage: "the ID of scalet to list to stop"},
},
Action: func(c *cli.Context) error {
stopScalet(c.Int64("id"))
return nil
},
},
{
Name: "start",
Usage: "Stops a scalet",
Flags: []cli.Flag{
cli.StringFlag{Name: "id", Usage: "the ID of scalet to start"},
},
Action: func(c *cli.Context) error {
startScalet(c.Int64("id"))
return nil
},
},
{
Name: "rplans",
Aliases: []string{"p"},
Usage: "Lists list rplans",
Action: func(c *cli.Context) error {
listRplans()
return nil
},
},
},
},
}
sort.Sort(cli.CommandsByName(app.Commands))
app.Run(os.Args)
}