schema1.go 13 KB

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