-
Notifications
You must be signed in to change notification settings - Fork 7
/
instance.go
62 lines (47 loc) · 1.19 KB
/
instance.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
package compute
type Instance struct {
ID string
Name string
Region string
IP string
PrivateIP string
Image Image
Flavor Flavor
PublicKey PublicKey
Status InstanceStatus
Username string
Password string
// A temporary identifier that can be used to get additional details on the
// instance immediately after it has been provisioned. For example, some
// providers return the instance password this way.
JobID string
// Bytes of bandwidth used.
BandwidthUsed int64
// Tenant network ID.
NetworkID string
// Key-value additional details of the instance.
Details map[string]string
// Additional custom actions supported for this instance.
Actions []InstanceAction
}
func (instance *Instance) Detail(k string, d string) string {
v, ok := instance.Details[k]
if ok {
return v
} else {
return d
}
}
type InstanceStatus string
const (
StatusOnline InstanceStatus = "online"
StatusOffline InstanceStatus = "offline"
)
type InstanceAction struct {
Label string
Description string
// map of options from option value to description
// if nil, then this action can take any string value
Options map[string]string
Func func(string) error
}