-
Notifications
You must be signed in to change notification settings - Fork 192
/
Copy pathtypes.go
148 lines (124 loc) · 4.12 KB
/
types.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
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 types
import (
"fmt"
"time"
)
type InstanceState string
const (
InstanceState_Running InstanceState = "running"
InstanceState_Stopped InstanceState = "stopped"
InstanceState_Pending InstanceState = "pending"
InstanceState_Unknown InstanceState = "unknown"
InstanceState_Terminated InstanceState = "terminated"
InstanceState_Error InstanceState = "error"
InstanceState_Paused InstanceState = "paused"
InstanceState_Suspended InstanceState = "suspended"
)
type Infrastructure string
const (
Infrastructure_AWS Infrastructure = "AWS"
Infrastructure_GCLOUD Infrastructure = "GCLOUD"
Infrastructure_VSPHERE Infrastructure = "VSPHERE"
Infrastructure_VIRTUALBOX Infrastructure = "VIRTUALBOX"
Infrastructure_QEMU Infrastructure = "QEMU"
Infrastructure_PHOTON Infrastructure = "PHOTON"
Infrastructure_XEN Infrastructure = "XEN"
Infrastructure_OPENSTACK Infrastructure = "OPENSTACK"
Infrastructure_UKVM Infrastructure = "UKVM"
Infrastructure_FIRECRACKER Infrastructure = "FIRECRACKER"
)
type Image struct {
Id string `json:"Id"`
Name string `json:"Name"`
SizeMb int64 `json:"SizeMb"`
Infrastructure Infrastructure `json:"Infrastructure"`
Created time.Time `json:"Created"`
StageSpec StageSpec `json:"StageSpec"`
RunSpec RunSpec `json:"RunSpec"`
}
// For Unik Hub
type UserImage struct {
*Image `json:"image"`
Owner string `json:"owner"`
}
func (image *Image) String() string {
if image == nil {
return "<nil>"
}
return fmt.Sprintf("%-v", *image)
}
type Instance struct {
Id string `json:"Id"`
Name string `json:"Name"`
State InstanceState `json:"State"`
IpAddress string `json:"IpAddress"`
ImageId string `json:"ImageId"`
Infrastructure Infrastructure `json:"Infrastructure"`
Created time.Time `json:"Created"`
}
func (instance *Instance) String() string {
if instance == nil {
return "<nil>"
}
return fmt.Sprintf("%+v", *instance)
}
type Volume struct {
Id string `json:"Id"`
Name string `json:"Name"`
SizeMb int64 `json:"SizeMb"`
Attachment string `json:"Attachment"` //instanceId
Infrastructure Infrastructure `json:"Infrastructure"`
Created time.Time `json:"Created"`
}
func (volume *Volume) String() string {
if volume == nil {
return "<nil>"
}
return fmt.Sprintf("%+v", *volume)
}
type RawImage struct {
LocalImagePath string `json:"LocalImagePath"`
StageSpec StageSpec `json:"StageSpec"`
RunSpec RunSpec `json:"RunSpec"`
}
type ImageFormat string
const (
ImageFormat_RAW ImageFormat = "raw"
ImageFormat_QCOW2 ImageFormat = "qcow2"
ImageFormat_VHD ImageFormat = "vhd"
ImageFormat_VMDK ImageFormat = "vmdk"
ImageFormat_Folder ImageFormat = "folder"
)
type XenVirtualizationType string
const (
XenVirtualizationType_HVM = "hvm"
XenVirtualizationType_Paravirtual = "paravirtual"
)
type StageSpec struct {
ImageFormat ImageFormat `json:"ImageFormat"` //required for all compilers
XenVirtualizationType XenVirtualizationType `json:"XenVirtualizationType,omitempty"`
}
type StorageDriver string
const (
StorageDriver_SCSI = "SCSI"
StorageDriver_SATA = "SATA"
StorageDriver_IDE = "IDE"
)
type VsphereNetworkType string
const (
VsphereNetworkType_E1000 = "e1000"
VsphereNetworkType_VMXNET3 = "vmxnet3"
)
type RunSpec struct {
DeviceMappings []DeviceMapping `json:"DeviceMappings"` //required for all compilers
// DefaultInstanceMemory is in MB
DefaultInstanceMemory int `json:"DefaultInstanceMemory"` //required for all compilers
MinInstanceDiskMB int `json:"MinInstanceDiskMB"`
StorageDriver StorageDriver `json:"StorageDriver,omitempty"`
VsphereNetworkType VsphereNetworkType `json:"VsphereNetworkType"`
Compiler string `json:"Compiler,omitempty"`
}
type DeviceMapping struct {
MountPoint string `json:"MountPoint"`
DeviceName string `json:"DeviceName"`
}