github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/interfaces.go (about) 1 // Copyright (c) 2017 Intel Corporation 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 // 5 6 package virtcontainers 7 8 import ( 9 "context" 10 "io" 11 "syscall" 12 13 "github.com/kata-containers/runtime/virtcontainers/device/api" 14 "github.com/kata-containers/runtime/virtcontainers/device/config" 15 vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types" 16 "github.com/kata-containers/runtime/virtcontainers/types" 17 specs "github.com/opencontainers/runtime-spec/specs-go" 18 "github.com/sirupsen/logrus" 19 ) 20 21 // VC is the Virtcontainers interface 22 type VC interface { 23 SetLogger(ctx context.Context, logger *logrus.Entry) 24 SetFactory(ctx context.Context, factory Factory) 25 26 CreateSandbox(ctx context.Context, sandboxConfig SandboxConfig) (VCSandbox, error) 27 DeleteSandbox(ctx context.Context, sandboxID string) (VCSandbox, error) 28 FetchSandbox(ctx context.Context, sandboxID string) (VCSandbox, error) 29 ListSandbox(ctx context.Context) ([]SandboxStatus, error) 30 RunSandbox(ctx context.Context, sandboxConfig SandboxConfig) (VCSandbox, error) 31 StartSandbox(ctx context.Context, sandboxID string) (VCSandbox, error) 32 StatusSandbox(ctx context.Context, sandboxID string) (SandboxStatus, error) 33 StopSandbox(ctx context.Context, sandboxID string, force bool) (VCSandbox, error) 34 35 CreateContainer(ctx context.Context, sandboxID string, containerConfig ContainerConfig) (VCSandbox, VCContainer, error) 36 DeleteContainer(ctx context.Context, sandboxID, containerID string) (VCContainer, error) 37 EnterContainer(ctx context.Context, sandboxID, containerID string, cmd types.Cmd) (VCSandbox, VCContainer, *Process, error) 38 KillContainer(ctx context.Context, sandboxID, containerID string, signal syscall.Signal, all bool) error 39 StartContainer(ctx context.Context, sandboxID, containerID string) (VCContainer, error) 40 StatusContainer(ctx context.Context, sandboxID, containerID string) (ContainerStatus, error) 41 StatsContainer(ctx context.Context, sandboxID, containerID string) (ContainerStats, error) 42 StatsSandbox(ctx context.Context, sandboxID string) (SandboxStats, []ContainerStats, error) 43 StopContainer(ctx context.Context, sandboxID, containerID string) (VCContainer, error) 44 ProcessListContainer(ctx context.Context, sandboxID, containerID string, options ProcessListOptions) (ProcessList, error) 45 UpdateContainer(ctx context.Context, sandboxID, containerID string, resources specs.LinuxResources) error 46 PauseContainer(ctx context.Context, sandboxID, containerID string) error 47 ResumeContainer(ctx context.Context, sandboxID, containerID string) error 48 49 AddDevice(ctx context.Context, sandboxID string, info config.DeviceInfo) (api.Device, error) 50 51 AddInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) 52 RemoveInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) 53 ListInterfaces(ctx context.Context, sandboxID string) ([]*vcTypes.Interface, error) 54 UpdateRoutes(ctx context.Context, sandboxID string, routes []*vcTypes.Route) ([]*vcTypes.Route, error) 55 ListRoutes(ctx context.Context, sandboxID string) ([]*vcTypes.Route, error) 56 57 CleanupContainer(ctx context.Context, sandboxID, containerID string, force bool) error 58 } 59 60 // VCSandbox is the Sandbox interface 61 // (required since virtcontainers.Sandbox only contains private fields) 62 type VCSandbox interface { 63 Annotations(key string) (string, error) 64 GetNetNs() string 65 GetAllContainers() []VCContainer 66 GetAnnotations() map[string]string 67 GetContainer(containerID string) VCContainer 68 ID() string 69 SetAnnotations(annotations map[string]string) error 70 71 Start() error 72 Stop(force bool) error 73 Release() error 74 Monitor() (chan error, error) 75 Delete() error 76 Status() SandboxStatus 77 CreateContainer(contConfig ContainerConfig) (VCContainer, error) 78 DeleteContainer(contID string) (VCContainer, error) 79 StartContainer(containerID string) (VCContainer, error) 80 StopContainer(containerID string, force bool) (VCContainer, error) 81 KillContainer(containerID string, signal syscall.Signal, all bool) error 82 StatusContainer(containerID string) (ContainerStatus, error) 83 StatsContainer(containerID string) (ContainerStats, error) 84 PauseContainer(containerID string) error 85 ResumeContainer(containerID string) error 86 EnterContainer(containerID string, cmd types.Cmd) (VCContainer, *Process, error) 87 UpdateContainer(containerID string, resources specs.LinuxResources) error 88 ProcessListContainer(containerID string, options ProcessListOptions) (ProcessList, error) 89 WaitProcess(containerID, processID string) (int32, error) 90 SignalProcess(containerID, processID string, signal syscall.Signal, all bool) error 91 WinsizeProcess(containerID, processID string, height, width uint32) error 92 IOStream(containerID, processID string) (io.WriteCloser, io.Reader, io.Reader, error) 93 94 AddDevice(info config.DeviceInfo) (api.Device, error) 95 96 AddInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error) 97 RemoveInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error) 98 ListInterfaces() ([]*vcTypes.Interface, error) 99 UpdateRoutes(routes []*vcTypes.Route) ([]*vcTypes.Route, error) 100 ListRoutes() ([]*vcTypes.Route, error) 101 102 GetOOMEvent() (string, error) 103 } 104 105 // VCContainer is the Container interface 106 // (required since virtcontainers.Container only contains private fields) 107 type VCContainer interface { 108 GetAnnotations() map[string]string 109 GetPid() int 110 GetToken() string 111 ID() string 112 Sandbox() VCSandbox 113 Process() Process 114 }