forked from kata-containers/runtime
-
Notifications
You must be signed in to change notification settings - Fork 1
/
implementation.go
190 lines (153 loc) · 7.8 KB
/
implementation.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
// Copyright (c) 2017 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
// Description: The true virtcontainers function of the same name.
// This indirection is required to allow an alternative implemenation to be
// used for testing purposes.
package virtcontainers
import (
"context"
"syscall"
"github.com/kata-containers/runtime/virtcontainers/device/api"
"github.com/kata-containers/runtime/virtcontainers/device/config"
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
"github.com/kata-containers/runtime/virtcontainers/types"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus"
)
// VCImpl is the official virtcontainers function of the same name.
type VCImpl struct {
factory Factory
}
// SetLogger implements the VC function of the same name.
func (impl *VCImpl) SetLogger(ctx context.Context, logger *logrus.Entry) {
SetLogger(ctx, logger)
}
// SetFactory implements the VC function of the same name.
func (impl *VCImpl) SetFactory(ctx context.Context, factory Factory) {
impl.factory = factory
}
// CreateSandbox implements the VC function of the same name.
func (impl *VCImpl) CreateSandbox(ctx context.Context, sandboxConfig SandboxConfig) (VCSandbox, error) {
return CreateSandbox(ctx, sandboxConfig, impl.factory)
}
// DeleteSandbox implements the VC function of the same name.
func (impl *VCImpl) DeleteSandbox(ctx context.Context, sandboxID string) (VCSandbox, error) {
return DeleteSandbox(ctx, sandboxID)
}
// StartSandbox implements the VC function of the same name.
func (impl *VCImpl) StartSandbox(ctx context.Context, sandboxID string) (VCSandbox, error) {
return StartSandbox(ctx, sandboxID)
}
// StopSandbox implements the VC function of the same name.
func (impl *VCImpl) StopSandbox(ctx context.Context, sandboxID string, force bool) (VCSandbox, error) {
return StopSandbox(ctx, sandboxID, force)
}
// RunSandbox implements the VC function of the same name.
func (impl *VCImpl) RunSandbox(ctx context.Context, sandboxConfig SandboxConfig) (VCSandbox, error) {
return RunSandbox(ctx, sandboxConfig, impl.factory)
}
// ListSandbox implements the VC function of the same name.
func (impl *VCImpl) ListSandbox(ctx context.Context) ([]SandboxStatus, error) {
return ListSandbox(ctx)
}
// FetchSandbox will find out and connect to an existing sandbox and
// return the sandbox structure.
func (impl *VCImpl) FetchSandbox(ctx context.Context, sandboxID string) (VCSandbox, error) {
return FetchSandbox(ctx, sandboxID)
}
// StatusSandbox implements the VC function of the same name.
func (impl *VCImpl) StatusSandbox(ctx context.Context, sandboxID string) (SandboxStatus, error) {
return StatusSandbox(ctx, sandboxID)
}
// PauseSandbox implements the VC function of the same name.
func (impl *VCImpl) PauseSandbox(ctx context.Context, sandboxID string) (VCSandbox, error) {
return PauseSandbox(ctx, sandboxID)
}
// ResumeSandbox implements the VC function of the same name.
func (impl *VCImpl) ResumeSandbox(ctx context.Context, sandboxID string) (VCSandbox, error) {
return ResumeSandbox(ctx, sandboxID)
}
// CreateContainer implements the VC function of the same name.
func (impl *VCImpl) CreateContainer(ctx context.Context, sandboxID string, containerConfig ContainerConfig) (VCSandbox, VCContainer, error) {
return CreateContainer(ctx, sandboxID, containerConfig)
}
// DeleteContainer implements the VC function of the same name.
func (impl *VCImpl) DeleteContainer(ctx context.Context, sandboxID, containerID string) (VCContainer, error) {
return DeleteContainer(ctx, sandboxID, containerID)
}
// StartContainer implements the VC function of the same name.
func (impl *VCImpl) StartContainer(ctx context.Context, sandboxID, containerID string) (VCContainer, error) {
return StartContainer(ctx, sandboxID, containerID)
}
// StopContainer implements the VC function of the same name.
func (impl *VCImpl) StopContainer(ctx context.Context, sandboxID, containerID string) (VCContainer, error) {
return StopContainer(ctx, sandboxID, containerID)
}
// EnterContainer implements the VC function of the same name.
func (impl *VCImpl) EnterContainer(ctx context.Context, sandboxID, containerID string, cmd types.Cmd) (VCSandbox, VCContainer, *Process, error) {
return EnterContainer(ctx, sandboxID, containerID, cmd)
}
// StatusContainer implements the VC function of the same name.
func (impl *VCImpl) StatusContainer(ctx context.Context, sandboxID, containerID string) (ContainerStatus, error) {
return StatusContainer(ctx, sandboxID, containerID)
}
// StatsContainer implements the VC function of the same name.
func (impl *VCImpl) StatsContainer(ctx context.Context, sandboxID, containerID string) (ContainerStats, error) {
return StatsContainer(ctx, sandboxID, containerID)
}
// StatsSandbox implements the VC function of the same name.
func (impl *VCImpl) StatsSandbox(ctx context.Context, sandboxID string) (SandboxStats, []ContainerStats, error) {
return StatsSandbox(ctx, sandboxID)
}
// KillContainer implements the VC function of the same name.
func (impl *VCImpl) KillContainer(ctx context.Context, sandboxID, containerID string, signal syscall.Signal, all bool) error {
return KillContainer(ctx, sandboxID, containerID, signal, all)
}
// ProcessListContainer implements the VC function of the same name.
func (impl *VCImpl) ProcessListContainer(ctx context.Context, sandboxID, containerID string, options ProcessListOptions) (ProcessList, error) {
return ProcessListContainer(ctx, sandboxID, containerID, options)
}
// UpdateContainer implements the VC function of the same name.
func (impl *VCImpl) UpdateContainer(ctx context.Context, sandboxID, containerID string, resources specs.LinuxResources) error {
return UpdateContainer(ctx, sandboxID, containerID, resources)
}
// PauseContainer implements the VC function of the same name.
func (impl *VCImpl) PauseContainer(ctx context.Context, sandboxID, containerID string) error {
return PauseContainer(ctx, sandboxID, containerID)
}
// ResumeContainer implements the VC function of the same name.
func (impl *VCImpl) ResumeContainer(ctx context.Context, sandboxID, containerID string) error {
return ResumeContainer(ctx, sandboxID, containerID)
}
// AddDevice will add a device to sandbox
func (impl *VCImpl) AddDevice(ctx context.Context, sandboxID string, info config.DeviceInfo) (api.Device, error) {
return AddDevice(ctx, sandboxID, info)
}
// AddInterface implements the VC function of the same name.
func (impl *VCImpl) AddInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
return AddInterface(ctx, sandboxID, inf)
}
// RemoveInterface implements the VC function of the same name.
func (impl *VCImpl) RemoveInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
return RemoveInterface(ctx, sandboxID, inf)
}
// ListInterfaces implements the VC function of the same name.
func (impl *VCImpl) ListInterfaces(ctx context.Context, sandboxID string) ([]*vcTypes.Interface, error) {
return ListInterfaces(ctx, sandboxID)
}
// UpdateRoutes implements the VC function of the same name.
func (impl *VCImpl) UpdateRoutes(ctx context.Context, sandboxID string, routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
return UpdateRoutes(ctx, sandboxID, routes)
}
// ListRoutes implements the VC function of the same name.
func (impl *VCImpl) ListRoutes(ctx context.Context, sandboxID string) ([]*vcTypes.Route, error) {
return ListRoutes(ctx, sandboxID)
}
// CleanupContaienr is used by shimv2 to stop and delete a container exclusively, once there is no container
// in the sandbox left, do stop the sandbox and delete it. Those serial operations will be done exclusively by
// locking the sandbox.
func (impl *VCImpl) CleanupContainer(ctx context.Context, sandboxID, containerID string, force bool) error {
return CleanupContainer(ctx, sandboxID, containerID, force)
}