schema1.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. package schema1
  2. import (
  3. "encoding/json"
  4. "time"
  5. )
  6. // ProcessConfig is used as both the input of Container.CreateProcess
  7. // and to convert the parameters to JSON for passing onto the HCS
  8. type ProcessConfig struct {
  9. ApplicationName string `json:",omitempty"`
  10. CommandLine string `json:",omitempty"`
  11. CommandArgs []string `json:",omitempty"` // Used by Linux Containers on Windows
  12. User string `json:",omitempty"`
  13. WorkingDirectory string `json:",omitempty"`
  14. Environment map[string]string `json:",omitempty"`
  15. EmulateConsole bool `json:",omitempty"`
  16. CreateStdInPipe bool `json:",omitempty"`
  17. CreateStdOutPipe bool `json:",omitempty"`
  18. CreateStdErrPipe bool `json:",omitempty"`
  19. ConsoleSize [2]uint `json:",omitempty"`
  20. CreateInUtilityVm bool `json:",omitempty"` // Used by Linux Containers on Windows
  21. OCISpecification *json.RawMessage `json:",omitempty"` // Used by Linux Containers on Windows
  22. }
  23. type Layer struct {
  24. ID string
  25. Path string
  26. }
  27. type MappedDir struct {
  28. HostPath string
  29. ContainerPath string
  30. ReadOnly bool
  31. BandwidthMaximum uint64
  32. IOPSMaximum uint64
  33. CreateInUtilityVM bool
  34. // LinuxMetadata - Support added in 1803/RS4+.
  35. LinuxMetadata bool `json:",omitempty"`
  36. }
  37. type MappedPipe struct {
  38. HostPath string
  39. ContainerPipeName string
  40. }
  41. type HvRuntime struct {
  42. ImagePath string `json:",omitempty"`
  43. SkipTemplate bool `json:",omitempty"`
  44. LinuxInitrdFile string `json:",omitempty"` // File under ImagePath on host containing an initrd image for starting a Linux utility VM
  45. LinuxKernelFile string `json:",omitempty"` // File under ImagePath on host containing a kernel for starting a Linux utility VM
  46. LinuxBootParameters string `json:",omitempty"` // Additional boot parameters for starting a Linux Utility VM in initrd mode
  47. BootSource string `json:",omitempty"` // "Vhd" for Linux Utility VM booting from VHD
  48. WritableBootSource bool `json:",omitempty"` // Linux Utility VM booting from VHD
  49. }
  50. type MappedVirtualDisk struct {
  51. HostPath string `json:",omitempty"` // Path to VHD on the host
  52. ContainerPath string // Platform-specific mount point path in the container
  53. CreateInUtilityVM bool `json:",omitempty"`
  54. ReadOnly bool `json:",omitempty"`
  55. Cache string `json:",omitempty"` // "" (Unspecified); "Disabled"; "Enabled"; "Private"; "PrivateAllowSharing"
  56. AttachOnly bool `json:",omitempty:`
  57. }
  58. // AssignedDevice represents a device that has been directly assigned to a container
  59. //
  60. // NOTE: Support added in RS5
  61. type AssignedDevice struct {
  62. // InterfaceClassGUID of the device to assign to container.
  63. InterfaceClassGUID string `json:"InterfaceClassGuid,omitempty"`
  64. }
  65. // ContainerConfig is used as both the input of CreateContainer
  66. // and to convert the parameters to JSON for passing onto the HCS
  67. type ContainerConfig struct {
  68. SystemType string // HCS requires this to be hard-coded to "Container"
  69. Name string // Name of the container. We use the docker ID.
  70. Owner string `json:",omitempty"` // The management platform that created this container
  71. VolumePath string `json:",omitempty"` // Windows volume path for scratch space. Used by Windows Server Containers only. Format \\?\\Volume{GUID}
  72. IgnoreFlushesDuringBoot bool `json:",omitempty"` // Optimization hint for container startup in Windows
  73. LayerFolderPath string `json:",omitempty"` // Where the layer folders are located. Used by Windows Server Containers only. Format %root%\windowsfilter\containerID
  74. Layers []Layer // List of storage layers. Required for Windows Server and Hyper-V Containers. Format ID=GUID;Path=%root%\windowsfilter\layerID
  75. Credentials string `json:",omitempty"` // Credentials information
  76. ProcessorCount uint32 `json:",omitempty"` // Number of processors to assign to the container.
  77. ProcessorWeight uint64 `json:",omitempty"` // CPU shares (relative weight to other containers with cpu shares). Range is from 1 to 10000. A value of 0 results in default shares.
  78. ProcessorMaximum int64 `json:",omitempty"` // Specifies the portion of processor cycles that this container can use as a percentage times 100. Range is from 1 to 10000. A value of 0 results in no limit.
  79. StorageIOPSMaximum uint64 `json:",omitempty"` // Maximum Storage IOPS
  80. StorageBandwidthMaximum uint64 `json:",omitempty"` // Maximum Storage Bandwidth in bytes per second
  81. StorageSandboxSize uint64 `json:",omitempty"` // Size in bytes that the container system drive should be expanded to if smaller
  82. MemoryMaximumInMB int64 `json:",omitempty"` // Maximum memory available to the container in Megabytes
  83. HostName string `json:",omitempty"` // Hostname
  84. MappedDirectories []MappedDir `json:",omitempty"` // List of mapped directories (volumes/mounts)
  85. MappedPipes []MappedPipe `json:",omitempty"` // List of mapped Windows named pipes
  86. HvPartition bool // True if it a Hyper-V Container
  87. NetworkSharedContainerName string `json:",omitempty"` // Name (ID) of the container that we will share the network stack with.
  88. EndpointList []string `json:",omitempty"` // List of networking endpoints to be attached to container
  89. HvRuntime *HvRuntime `json:",omitempty"` // Hyper-V container settings. Used by Hyper-V containers only. Format ImagePath=%root%\BaseLayerID\UtilityVM
  90. Servicing bool `json:",omitempty"` // True if this container is for servicing
  91. AllowUnqualifiedDNSQuery bool `json:",omitempty"` // True to allow unqualified DNS name resolution
  92. DNSSearchList string `json:",omitempty"` // Comma seperated list of DNS suffixes to use for name resolution
  93. ContainerType string `json:",omitempty"` // "Linux" for Linux containers on Windows. Omitted otherwise.
  94. TerminateOnLastHandleClosed bool `json:",omitempty"` // Should HCS terminate the container once all handles have been closed
  95. MappedVirtualDisks []MappedVirtualDisk `json:",omitempty"` // Array of virtual disks to mount at start
  96. AssignedDevices []AssignedDevice `json:",omitempty"` // Array of devices to assign. NOTE: Support added in RS5
  97. }
  98. type ComputeSystemQuery struct {
  99. IDs []string `json:"Ids,omitempty"`
  100. Types []string `json:",omitempty"`
  101. Names []string `json:",omitempty"`
  102. Owners []string `json:",omitempty"`
  103. }
  104. type PropertyType string
  105. const (
  106. PropertyTypeStatistics PropertyType = "Statistics"
  107. PropertyTypeProcessList = "ProcessList"
  108. PropertyTypeMappedVirtualDisk = "MappedVirtualDisk"
  109. )
  110. type PropertyQuery struct {
  111. PropertyTypes []PropertyType `json:",omitempty"`
  112. }
  113. // ContainerProperties holds the properties for a container and the processes running in that container
  114. type ContainerProperties struct {
  115. ID string `json:"Id"`
  116. State string
  117. Name string
  118. SystemType string
  119. Owner string
  120. SiloGUID string `json:"SiloGuid,omitempty"`
  121. RuntimeID string `json:"RuntimeId,omitempty"`
  122. IsRuntimeTemplate bool `json:",omitempty"`
  123. RuntimeImagePath string `json:",omitempty"`
  124. Stopped bool `json:",omitempty"`
  125. ExitType string `json:",omitempty"`
  126. AreUpdatesPending bool `json:",omitempty"`
  127. ObRoot string `json:",omitempty"`
  128. Statistics Statistics `json:",omitempty"`
  129. ProcessList []ProcessListItem `json:",omitempty"`
  130. MappedVirtualDiskControllers map[int]MappedVirtualDiskController `json:",omitempty"`
  131. }
  132. // MemoryStats holds the memory statistics for a container
  133. type MemoryStats struct {
  134. UsageCommitBytes uint64 `json:"MemoryUsageCommitBytes,omitempty"`
  135. UsageCommitPeakBytes uint64 `json:"MemoryUsageCommitPeakBytes,omitempty"`
  136. UsagePrivateWorkingSetBytes uint64 `json:"MemoryUsagePrivateWorkingSetBytes,omitempty"`
  137. }
  138. // ProcessorStats holds the processor statistics for a container
  139. type ProcessorStats struct {
  140. TotalRuntime100ns uint64 `json:",omitempty"`
  141. RuntimeUser100ns uint64 `json:",omitempty"`
  142. RuntimeKernel100ns uint64 `json:",omitempty"`
  143. }
  144. // StorageStats holds the storage statistics for a container
  145. type StorageStats struct {
  146. ReadCountNormalized uint64 `json:",omitempty"`
  147. ReadSizeBytes uint64 `json:",omitempty"`
  148. WriteCountNormalized uint64 `json:",omitempty"`
  149. WriteSizeBytes uint64 `json:",omitempty"`
  150. }
  151. // NetworkStats holds the network statistics for a container
  152. type NetworkStats struct {
  153. BytesReceived uint64 `json:",omitempty"`
  154. BytesSent uint64 `json:",omitempty"`
  155. PacketsReceived uint64 `json:",omitempty"`
  156. PacketsSent uint64 `json:",omitempty"`
  157. DroppedPacketsIncoming uint64 `json:",omitempty"`
  158. DroppedPacketsOutgoing uint64 `json:",omitempty"`
  159. EndpointId string `json:",omitempty"`
  160. InstanceId string `json:",omitempty"`
  161. }
  162. // Statistics is the structure returned by a statistics call on a container
  163. type Statistics struct {
  164. Timestamp time.Time `json:",omitempty"`
  165. ContainerStartTime time.Time `json:",omitempty"`
  166. Uptime100ns uint64 `json:",omitempty"`
  167. Memory MemoryStats `json:",omitempty"`
  168. Processor ProcessorStats `json:",omitempty"`
  169. Storage StorageStats `json:",omitempty"`
  170. Network []NetworkStats `json:",omitempty"`
  171. }
  172. // ProcessList is the structure of an item returned by a ProcessList call on a container
  173. type ProcessListItem struct {
  174. CreateTimestamp time.Time `json:",omitempty"`
  175. ImageName string `json:",omitempty"`
  176. KernelTime100ns uint64 `json:",omitempty"`
  177. MemoryCommitBytes uint64 `json:",omitempty"`
  178. MemoryWorkingSetPrivateBytes uint64 `json:",omitempty"`
  179. MemoryWorkingSetSharedBytes uint64 `json:",omitempty"`
  180. ProcessId uint32 `json:",omitempty"`
  181. UserTime100ns uint64 `json:",omitempty"`
  182. }
  183. // MappedVirtualDiskController is the structure of an item returned by a MappedVirtualDiskList call on a container
  184. type MappedVirtualDiskController struct {
  185. MappedVirtualDisks map[int]MappedVirtualDisk `json:",omitempty"`
  186. }
  187. // Type of Request Support in ModifySystem
  188. type RequestType string
  189. // Type of Resource Support in ModifySystem
  190. type ResourceType string
  191. // RequestType const
  192. const (
  193. Add RequestType = "Add"
  194. Remove RequestType = "Remove"
  195. Network ResourceType = "Network"
  196. )
  197. // ResourceModificationRequestResponse is the structure used to send request to the container to modify the system
  198. // Supported resource types are Network and Request Types are Add/Remove
  199. type ResourceModificationRequestResponse struct {
  200. Resource ResourceType `json:"ResourceType"`
  201. Data interface{} `json:"Settings"`
  202. Request RequestType `json:"RequestType,omitempty"`
  203. }