forked from canonical/lxd
/
storage_mock.go
234 lines (176 loc) · 5.33 KB
/
storage_mock.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
package main
import (
"fmt"
"github.com/gorilla/websocket"
"github.com/lxc/lxd/lxd/migration"
"github.com/lxc/lxd/shared/api"
"github.com/lxc/lxd/shared/idmap"
"github.com/lxc/lxd/shared/logger"
)
type storageMock struct {
storageShared
}
func (s *storageMock) StorageCoreInit() error {
s.sType = storageTypeMock
typeName, err := storageTypeToString(s.sType)
if err != nil {
return err
}
s.sTypeName = typeName
logger.Debugf("Initializing a MOCK driver.")
return nil
}
func (s *storageMock) StoragePoolInit() error {
err := s.StorageCoreInit()
if err != nil {
return err
}
return nil
}
func (s *storageMock) StoragePoolCheck() error {
logger.Debugf("Checking MOCK storage pool \"%s\".", s.pool.Name)
return nil
}
func (s *storageMock) StoragePoolCreate() error {
logger.Infof("Creating MOCK storage pool \"%s\".", s.pool.Name)
logger.Infof("Created MOCK storage pool \"%s\".", s.pool.Name)
return nil
}
func (s *storageMock) StoragePoolDelete() error {
logger.Infof("Deleting MOCK storage pool \"%s\".", s.pool.Name)
logger.Infof("Deleted MOCK storage pool \"%s\".", s.pool.Name)
return nil
}
func (s *storageMock) StoragePoolMount() (bool, error) {
return true, nil
}
func (s *storageMock) StoragePoolUmount() (bool, error) {
return true, nil
}
func (s *storageMock) GetStoragePoolWritable() api.StoragePoolPut {
return s.pool.StoragePoolPut
}
func (s *storageMock) GetStoragePoolVolumeWritable() api.StorageVolumePut {
return api.StorageVolumePut{}
}
func (s *storageMock) SetStoragePoolWritable(writable *api.StoragePoolPut) {
s.pool.StoragePoolPut = *writable
}
func (s *storageMock) SetStoragePoolVolumeWritable(writable *api.StorageVolumePut) {
s.volume.StorageVolumePut = *writable
}
func (s *storageMock) GetContainerPoolInfo() (int64, string, string) {
return s.poolID, s.pool.Name, s.pool.Name
}
func (s *storageMock) StoragePoolVolumeCreate() error {
return nil
}
func (s *storageMock) StoragePoolVolumeDelete() error {
return nil
}
func (s *storageMock) StoragePoolVolumeMount() (bool, error) {
return true, nil
}
func (s *storageMock) StoragePoolVolumeUmount() (bool, error) {
return true, nil
}
func (s *storageMock) StoragePoolVolumeUpdate(writable *api.StorageVolumePut, changedConfig []string) error {
return nil
}
func (s *storageMock) StoragePoolVolumeRename(newName string) error {
return nil
}
func (s *storageMock) StoragePoolUpdate(writable *api.StoragePoolPut, changedConfig []string) error {
return nil
}
func (s *storageMock) ContainerStorageReady(name string) bool {
return true
}
func (s *storageMock) ContainerCreate(container container) error {
return nil
}
func (s *storageMock) ContainerCreateFromImage(
container container, imageFingerprint string) error {
return nil
}
func (s *storageMock) ContainerCanRestore(container container, sourceContainer container) error {
return nil
}
func (s *storageMock) ContainerDelete(container container) error {
return nil
}
func (s *storageMock) ContainerCopy(target container, source container, containerOnly bool) error {
return nil
}
func (s *storageMock) ContainerMount(c container) (bool, error) {
return true, nil
}
func (s *storageMock) ContainerUmount(name string, path string) (bool, error) {
return true, nil
}
func (s *storageMock) ContainerRename(
container container, newName string) error {
return nil
}
func (s *storageMock) ContainerRestore(
container container, sourceContainer container) error {
return nil
}
func (s *storageMock) ContainerGetUsage(
container container) (int64, error) {
return 0, nil
}
func (s *storageMock) ContainerSnapshotCreate(
snapshotContainer container, sourceContainer container) error {
return nil
}
func (s *storageMock) ContainerSnapshotDelete(
snapshotContainer container) error {
return nil
}
func (s *storageMock) ContainerSnapshotRename(
snapshotContainer container, newName string) error {
return nil
}
func (s *storageMock) ContainerSnapshotStart(container container) (bool, error) {
return true, nil
}
func (s *storageMock) ContainerSnapshotStop(container container) (bool, error) {
return true, nil
}
func (s *storageMock) ContainerSnapshotCreateEmpty(snapshotContainer container) error {
return nil
}
func (s *storageMock) ImageCreate(fingerprint string) error {
return nil
}
func (s *storageMock) ImageDelete(fingerprint string) error {
return nil
}
func (s *storageMock) ImageMount(fingerprint string) (bool, error) {
return true, nil
}
func (s *storageMock) ImageUmount(fingerprint string) (bool, error) {
return true, nil
}
func (s *storageMock) MigrationType() migration.MigrationFSType {
return migration.MigrationFSType_RSYNC
}
func (s *storageMock) PreservesInodes() bool {
return false
}
func (s *storageMock) MigrationSource(container container, containerOnly bool) (MigrationStorageSourceDriver, error) {
return nil, fmt.Errorf("not implemented")
}
func (s *storageMock) MigrationSink(live bool, container container, snapshots []*migration.Snapshot, conn *websocket.Conn, srcIdmap *idmap.IdmapSet, op *operation, containerOnly bool) error {
return nil
}
func (s *storageMock) StorageEntitySetQuota(volumeType int, size int64, data interface{}) error {
return nil
}
func (s *storageMock) StoragePoolResources() (*api.ResourcesStoragePool, error) {
return &api.ResourcesStoragePool{}, nil
}
func (s *storageMock) StoragePoolVolumeCopy(source *api.StorageVolumeSource) error {
return nil
}