schema1.go 13 KB

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