This repository has been archived by the owner on Jun 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
/
instance.go
254 lines (239 loc) · 10.7 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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
package model
import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/blkiodev"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/strslice"
"github.com/docker/go-connections/nat"
"github.com/docker/go-units"
)
type Instance struct {
AccountID int `json:"accountId"`
AllocationState string `json:"allocationState"`
Created int64 `json:"created"`
Data InstanceFieldsData
Ports []Port
Description string `json:"description"`
Hostname string `json:"hostname"`
ID int `json:"id"`
Image Image
ImageID int `json:"imageId"`
Kind string `json:"kind"`
Name string `json:"name"`
Nics []Nic
Offering interface{} `json:"offering"`
OfferingID interface{} `json:"offeringId"`
OnCrash string `json:"onCrash"`
PostComputeState string `json:"postComputeState"`
RemoveTime interface{} `json:"removeTime"`
Removed interface{} `json:"removed"`
RequestedOfferingID interface{} `json:"requestedOfferingId"`
RequestedState interface{} `json:"requestedState"`
State string `json:"state"`
Type string `json:"type"`
UUID string `json:"uuid"`
Volumes []Volume
ZoneID int `json:"zoneId"`
ExternalID string `json:"externalId"`
AgentID int
InstanceLinks []Link
NetworkContainer *Instance
NativeContainer bool
DataVolumesFromContainers []*Instance
CommandArgs []string
Labels map[string]interface{}
ProcessData ProcessData
VolumesFromDataVolumeMounts []Volume
Token string
MilliCPUReservation int64
MemoryReservation int64
System bool
}
type InstanceFieldsData struct {
Fields InstanceFields
IPSec map[string]struct {
Nat float64
Isakmp float64
} `json:"ipsec"`
DockerInspect ContainerJSON `json:"dockerInspect,omitempty" yaml:"dockerInspect,omitempty"`
Process ProcessData
}
type ContainerJSON struct {
ID string `json:"Id"`
Created string
Path string
Args []string
State interface{}
Image string
ResolvConfPath string
HostnamePath string
HostsPath string
LogPath string
Node types.ContainerNode `json:",omitempty"`
Name string
RestartCount int
Driver string
MountLabel string
ProcessLabel string
AppArmorProfile string
ExecIDs []string
HostConfig HostConfig
GraphDriver types.GraphDriverData
SizeRw int64 `json:",omitempty"`
SizeRootFs int64 `json:",omitempty"`
Mounts []types.MountPoint
Config container.Config
NetworkSettings types.NetworkSettings
}
type HostConfig struct {
// Applicable to all platforms
Binds []string // List of volume bindings for this container
ContainerIDFile string // File (path) where the containerId is written
LogConfig LogConfig // Configuration of the logs for this container
NetworkMode container.NetworkMode // Network mode to use for the container
PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host
RestartPolicy container.RestartPolicy // Restart policy to be used for the container
AutoRemove bool // Automatically remove container when it exits
VolumeDriver string // Name of the volume driver used to mount volumes
VolumesFrom []string // List of volumes to take from other container
// Applicable to UNIX platforms
CapAdd strslice.StrSlice // List of kernel capabilities to add to the container
CapDrop strslice.StrSlice // List of kernel capabilities to remove from the container
DNS []string `json:"Dns"` // List of DNS server to lookup
DNSOptions []string `json:"DnsOptions"` // List of DNSOption to look for
DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for
ExtraHosts []string // List of extra hosts
GroupAdd []string // List of additional groups that the container process will run as
IpcMode container.IpcMode // IPC namespace to use for the container
Cgroup container.CgroupSpec // Cgroup to use for the container
Links []string // List of links (in the name:alias form)
OomScoreAdj int // Container preference for OOM-killing
PidMode container.PidMode // PID namespace to use for the container
Privileged bool // Is the container in privileged mode
PublishAllPorts bool // Should docker publish all exposed port for the container
ReadonlyRootfs bool // Is the container root filesystem in read-only
SecurityOpt []string // List of string values to customize labels for MLS systems, such as SELinux.
StorageOpt map[string]string `json:",omitempty"` // Storage driver options per container.
Tmpfs map[string]string `json:",omitempty"` // List of tmpfs (mounts) used for the container
UTSMode container.UTSMode // UTS namespace to use for the container
UsernsMode container.UsernsMode // The user namespace to use for the container
ShmSize int64 // Total shm memory usage
Sysctls map[string]string `json:",omitempty"` // List of Namespaced sysctls used for the container
Runtime string `json:",omitempty"` // Runtime to use with this container
// Applicable to Windows
//ConsoleSize [2]int // Initial console size
Isolation container.Isolation // Isolation technology of the container (eg default, hyperv)
// Contains container's resources (cgroups, ulimits)
Resources
// Mounts specs used by the container
Mounts []mount.Mount `json:",omitempty"`
}
type Resources struct {
// Applicable to all platforms
CPUShares int64 `json:"CpuShares"` // CPU shares (relative weight vs. other containers)
Memory int64 // Memory limit (in bytes)
// Applicable to UNIX platforms
CgroupParent string // Parent cgroup.
BlkioWeight uint16 // Block IO weight (relative weight vs. other containers)
BlkioWeightDevice []*blkiodev.WeightDevice
BlkioDeviceReadBps []*blkiodev.ThrottleDevice
BlkioDeviceWriteBps []*blkiodev.ThrottleDevice
BlkioDeviceReadIOps []*blkiodev.ThrottleDevice
BlkioDeviceWriteIOps []*blkiodev.ThrottleDevice
CPUPeriod int64 `json:"CpuPeriod"` // CPU CFS (Completely Fair Scheduler) period
CPUQuota int64 `json:"CpuQuota"` // CPU CFS (Completely Fair Scheduler) quota
CpusetCpus string // CpusetCpus 0-2, 0,1
CpusetMems string // CpusetMems 0-2, 0,1
Devices []container.DeviceMapping // List of devices to map inside the container
DiskQuota int64 // Disk limit (in bytes)
KernelMemory int64 // Kernel memory limit (in bytes)
MemoryReservation int64 // Memory soft limit (in bytes)
MemorySwap int64 // Total memory usage (memory + swap); set `-1` to enable unlimited swap
MemorySwappiness *int64 // Tuning container memory swappiness behaviour
OomKillDisable *bool // Whether to disable OOM Killer or not
PidsLimit int64 // Setting pids limit for a container
Ulimits []*units.Ulimit // List of ulimits to be set in the container
// Applicable to Windows
CPUCount int64 `json:"CpuCount"` // CPU count
CPUPercent int64 `json:"CpuPercent"` // CPU percent
IOMaximumIOps uint64 // Maximum IOps for the container system drive
IOMaximumBandwidth uint64 // Maximum IO in bytes per second for the container system drive
}
type InstanceFields struct {
ImageUUID string `json:"imageUuid"`
PublishAllPorts bool
DataVolumes []string
Privileged bool
ReadOnly bool
BlkioDeviceOptions map[string]DeviceOptions
CommandArgs []string
ExtraHosts []string
PidMode container.PidMode
LogConfig LogConfig
SecurityOpt []string
Devices []string
DNS []string `json:"dns"`
DNSSearch []string `json:"dnsSearch"`
CapAdd []string
CapDrop []string
RestartPolicy container.RestartPolicy
CPUShares int64 `json:"cpuShares"`
VolumeDriver string
CPUSet string
BlkioWeight uint16
CgroupParent string
CPUPeriod int64 `json:"cpuPeriod"`
CPUQuota int64 `json:"cpuQuota"`
CPUsetMems string `json:"cpuSetMems"`
DNSOpt []string
GroupAdd []string
Isolation container.Isolation
KernelMemory int64
Memory int64
MemorySwap int64
MemorySwappiness *int64
OomKillDisable *bool
OomScoreAdj int
ShmSize int64
Tmpfs map[string]string
Ulimits []*units.Ulimit
Uts container.UTSMode
IpcMode container.IpcMode
ConsoleSize [2]int
CPUCount int64
CPUPercent int64
IOMaximumIOps uint64
IOMaximumBandwidth uint64
Command interface{} // this one is so weird
Environment map[string]string
WorkingDir string
EntryPoint []string
Tty bool
StdinOpen bool
DomainName string
Labels map[string]string
StopSignal string
User string
Sysctls map[string]string
HealthCmd []string
HealthTimeout int
HealthInterval int
HealthRetries int
StorageOpt map[string]string
PidsLimit int64
Cgroup container.CgroupSpec
DiskQuota int64
UsernsMode container.UsernsMode
}
type LogConfig struct {
Driver string
Config map[string]string
}
type DeviceOptions struct {
Weight uint16
ReadIops uint64
WriteIops uint64
ReadBps uint64
WriteBps uint64
}