]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/volumes/module.py
import ceph pacific 16.2.5
[ceph.git] / ceph / src / pybind / mgr / volumes / module.py
CommitLineData
11fdf7f2 1import errno
f91f0fd5
TL
2import logging
3import traceback
4import threading
11fdf7f2 5
f67539c2 6from mgr_module import MgrModule, Option
11fdf7f2
TL
7import orchestrator
8
81eedcae 9from .fs.volume import VolumeClient
11fdf7f2 10
f91f0fd5
TL
11log = logging.getLogger(__name__)
12
f67539c2
TL
13goodchars = '[A-Za-z0-9-_.]'
14
f91f0fd5
TL
15class VolumesInfoWrapper():
16 def __init__(self, f, context):
17 self.f = f
18 self.context = context
19 def __enter__(self):
20 log.info("Starting {}".format(self.context))
21 def __exit__(self, exc_type, exc_value, tb):
22 if exc_type is not None:
23 log.error("Failed {}:\n{}".format(self.context, "".join(traceback.format_exception(exc_type, exc_value, tb))))
24 else:
25 log.info("Finishing {}".format(self.context))
26
27def mgr_cmd_wrap(f):
28 def wrap(self, inbuf, cmd):
29 astr = []
30 for k in cmd:
31 astr.append("{}:{}".format(k, cmd[k]))
32 context = "{}({}) < \"{}\"".format(f.__name__, ", ".join(astr), inbuf)
33 with VolumesInfoWrapper(f, context):
34 return f(self, inbuf, cmd)
35 return wrap
36
11fdf7f2
TL
37class Module(orchestrator.OrchestratorClientMixin, MgrModule):
38 COMMANDS = [
39 {
40 'cmd': 'fs volume ls',
41 'desc': "List volumes",
42 'perm': 'r'
43 },
44 {
45 'cmd': 'fs volume create '
f67539c2 46 f'name=name,type=CephString,goodchars={goodchars} '
9f95a23c 47 'name=placement,type=CephString,req=false ',
11fdf7f2
TL
48 'desc': "Create a CephFS volume",
49 'perm': 'rw'
50 },
51 {
52 'cmd': 'fs volume rm '
eafe8130
TL
53 'name=vol_name,type=CephString '
54 'name=yes-i-really-mean-it,type=CephString,req=false ',
55 'desc': "Delete a FS volume by passing --yes-i-really-mean-it flag",
11fdf7f2
TL
56 'perm': 'rw'
57 },
eafe8130
TL
58 {
59 'cmd': 'fs subvolumegroup ls '
60 'name=vol_name,type=CephString ',
61 'desc': "List subvolumegroups",
62 'perm': 'r'
63 },
81eedcae
TL
64 {
65 'cmd': 'fs subvolumegroup create '
66 'name=vol_name,type=CephString '
f67539c2 67 f'name=group_name,type=CephString,goodchars={goodchars} '
81eedcae 68 'name=pool_layout,type=CephString,req=false '
92f5a8d4
TL
69 'name=uid,type=CephInt,req=false '
70 'name=gid,type=CephInt,req=false '
81eedcae
TL
71 'name=mode,type=CephString,req=false ',
72 'desc': "Create a CephFS subvolume group in a volume, and optionally, "
73 "with a specific data pool layout, and a specific numeric mode",
74 'perm': 'rw'
75 },
76 {
77 'cmd': 'fs subvolumegroup rm '
78 'name=vol_name,type=CephString '
79 'name=group_name,type=CephString '
80 'name=force,type=CephBool,req=false ',
81 'desc': "Delete a CephFS subvolume group in a volume",
82 'perm': 'rw'
83 },
eafe8130
TL
84 {
85 'cmd': 'fs subvolume ls '
86 'name=vol_name,type=CephString '
87 'name=group_name,type=CephString,req=false ',
88 'desc': "List subvolumes",
89 'perm': 'r'
90 },
11fdf7f2
TL
91 {
92 'cmd': 'fs subvolume create '
93 'name=vol_name,type=CephString '
f67539c2 94 f'name=sub_name,type=CephString,goodchars={goodchars} '
81eedcae
TL
95 'name=size,type=CephInt,req=false '
96 'name=group_name,type=CephString,req=false '
97 'name=pool_layout,type=CephString,req=false '
92f5a8d4
TL
98 'name=uid,type=CephInt,req=false '
99 'name=gid,type=CephInt,req=false '
e306af50
TL
100 'name=mode,type=CephString,req=false '
101 'name=namespace_isolated,type=CephBool,req=false ',
81eedcae
TL
102 'desc': "Create a CephFS subvolume in a volume, and optionally, "
103 "with a specific size (in bytes), a specific data pool layout, "
e306af50
TL
104 "a specific mode, in a specific subvolume group and in separate "
105 "RADOS namespace",
11fdf7f2
TL
106 'perm': 'rw'
107 },
108 {
109 'cmd': 'fs subvolume rm '
110 'name=vol_name,type=CephString '
81eedcae
TL
111 'name=sub_name,type=CephString '
112 'name=group_name,type=CephString,req=false '
adb31ebb
TL
113 'name=force,type=CephBool,req=false '
114 'name=retain_snapshots,type=CephBool,req=false ',
81eedcae 115 'desc': "Delete a CephFS subvolume in a volume, and optionally, "
adb31ebb
TL
116 "in a specific subvolume group, force deleting a cancelled or failed "
117 "clone, and retaining existing subvolume snapshots",
81eedcae
TL
118 'perm': 'rw'
119 },
cd265ab1
TL
120 {
121 'cmd': 'fs subvolume authorize '
122 'name=vol_name,type=CephString '
123 'name=sub_name,type=CephString '
124 'name=auth_id,type=CephString '
125 'name=group_name,type=CephString,req=false '
126 'name=access_level,type=CephString,req=false '
127 'name=tenant_id,type=CephString,req=false '
128 'name=allow_existing_id,type=CephBool,req=false ',
129 'desc': "Allow a cephx auth ID access to a subvolume",
130 'perm': 'rw'
131 },
132 {
133 'cmd': 'fs subvolume deauthorize '
134 'name=vol_name,type=CephString '
135 'name=sub_name,type=CephString '
136 'name=auth_id,type=CephString '
137 'name=group_name,type=CephString,req=false ',
138 'desc': "Deny a cephx auth ID access to a subvolume",
139 'perm': 'rw'
140 },
141 {
142 'cmd': 'fs subvolume authorized_list '
143 'name=vol_name,type=CephString '
144 'name=sub_name,type=CephString '
145 'name=group_name,type=CephString,req=false ',
146 'desc': "List auth IDs that have access to a subvolume",
147 'perm': 'r'
148 },
149 {
150 'cmd': 'fs subvolume evict '
151 'name=vol_name,type=CephString '
152 'name=sub_name,type=CephString '
153 'name=auth_id,type=CephString '
154 'name=group_name,type=CephString,req=false ',
155 'desc': "Evict clients based on auth IDs and subvolume mounted",
156 'perm': 'rw'
157 },
494da23a
TL
158 {
159 'cmd': 'fs subvolumegroup getpath '
160 'name=vol_name,type=CephString '
161 'name=group_name,type=CephString ',
162 'desc': "Get the mountpath of a CephFS subvolume group in a volume",
163 'perm': 'r'
164 },
81eedcae
TL
165 {
166 'cmd': 'fs subvolume getpath '
167 'name=vol_name,type=CephString '
168 'name=sub_name,type=CephString '
169 'name=group_name,type=CephString,req=false ',
170 'desc': "Get the mountpath of a CephFS subvolume in a volume, "
171 "and optionally, in a specific subvolume group",
172 'perm': 'rw'
173 },
1911f103
TL
174 {
175 'cmd': 'fs subvolume info '
176 'name=vol_name,type=CephString '
177 'name=sub_name,type=CephString '
178 'name=group_name,type=CephString,req=false ',
179 'desc': "Get the metadata of a CephFS subvolume in a volume, "
180 "and optionally, in a specific subvolume group",
181 'perm': 'r'
182 },
f6b5b4d7
TL
183 {
184 'cmd': 'fs subvolumegroup pin'
185 ' name=vol_name,type=CephString'
186 ' name=group_name,type=CephString,req=true'
187 ' name=pin_type,type=CephChoices,strings=export|distributed|random'
188 ' name=pin_setting,type=CephString,req=true',
189 'desc': "Set MDS pinning policy for subvolumegroup",
190 'perm': 'rw'
191 },
eafe8130
TL
192 {
193 'cmd': 'fs subvolumegroup snapshot ls '
194 'name=vol_name,type=CephString '
195 'name=group_name,type=CephString ',
196 'desc': "List subvolumegroup snapshots",
197 'perm': 'r'
198 },
81eedcae
TL
199 {
200 'cmd': 'fs subvolumegroup snapshot create '
201 'name=vol_name,type=CephString '
202 'name=group_name,type=CephString '
203 'name=snap_name,type=CephString ',
204 'desc': "Create a snapshot of a CephFS subvolume group in a volume",
205 'perm': 'rw'
206 },
207 {
208 'cmd': 'fs subvolumegroup snapshot rm '
209 'name=vol_name,type=CephString '
210 'name=group_name,type=CephString '
211 'name=snap_name,type=CephString '
212 'name=force,type=CephBool,req=false ',
213 'desc': "Delete a snapshot of a CephFS subvolume group in a volume",
214 'perm': 'rw'
215 },
eafe8130
TL
216 {
217 'cmd': 'fs subvolume snapshot ls '
218 'name=vol_name,type=CephString '
219 'name=sub_name,type=CephString '
220 'name=group_name,type=CephString,req=false ',
221 'desc': "List subvolume snapshots",
222 'perm': 'r'
223 },
81eedcae
TL
224 {
225 'cmd': 'fs subvolume snapshot create '
226 'name=vol_name,type=CephString '
227 'name=sub_name,type=CephString '
228 'name=snap_name,type=CephString '
229 'name=group_name,type=CephString,req=false ',
230 'desc': "Create a snapshot of a CephFS subvolume in a volume, "
231 "and optionally, in a specific subvolume group",
232 'perm': 'rw'
233 },
e306af50
TL
234 {
235 'cmd': 'fs subvolume snapshot info '
236 'name=vol_name,type=CephString '
237 'name=sub_name,type=CephString '
238 'name=snap_name,type=CephString '
239 'name=group_name,type=CephString,req=false ',
240 'desc': "Get the metadata of a CephFS subvolume snapshot "
241 "and optionally, in a specific subvolume group",
242 'perm': 'r'
243 },
81eedcae
TL
244 {
245 'cmd': 'fs subvolume snapshot rm '
246 'name=vol_name,type=CephString '
247 'name=sub_name,type=CephString '
248 'name=snap_name,type=CephString '
249 'name=group_name,type=CephString,req=false '
250 'name=force,type=CephBool,req=false ',
251 'desc': "Delete a snapshot of a CephFS subvolume in a volume, "
252 "and optionally, in a specific subvolume group",
11fdf7f2
TL
253 'perm': 'rw'
254 },
92f5a8d4
TL
255 {
256 'cmd': 'fs subvolume resize '
257 'name=vol_name,type=CephString '
258 'name=sub_name,type=CephString '
259 'name=new_size,type=CephString,req=true '
260 'name=group_name,type=CephString,req=false '
261 'name=no_shrink,type=CephBool,req=false ',
262 'desc': "Resize a CephFS subvolume",
263 'perm': 'rw'
264 },
f6b5b4d7
TL
265 {
266 'cmd': 'fs subvolume pin'
267 ' name=vol_name,type=CephString'
268 ' name=sub_name,type=CephString'
269 ' name=pin_type,type=CephChoices,strings=export|distributed|random'
270 ' name=pin_setting,type=CephString,req=true'
271 ' name=group_name,type=CephString,req=false',
272 'desc': "Set MDS pinning policy for subvolume",
273 'perm': 'rw'
274 },
92f5a8d4
TL
275 {
276 'cmd': 'fs subvolume snapshot protect '
277 'name=vol_name,type=CephString '
278 'name=sub_name,type=CephString '
279 'name=snap_name,type=CephString '
280 'name=group_name,type=CephString,req=false ',
f6b5b4d7 281 'desc': "(deprecated) Protect snapshot of a CephFS subvolume in a volume, "
92f5a8d4
TL
282 "and optionally, in a specific subvolume group",
283 'perm': 'rw'
284 },
285 {
286 'cmd': 'fs subvolume snapshot unprotect '
287 'name=vol_name,type=CephString '
288 'name=sub_name,type=CephString '
289 'name=snap_name,type=CephString '
290 'name=group_name,type=CephString,req=false ',
f6b5b4d7 291 'desc': "(deprecated) Unprotect a snapshot of a CephFS subvolume in a volume, "
92f5a8d4
TL
292 "and optionally, in a specific subvolume group",
293 'perm': 'rw'
294 },
295 {
296 'cmd': 'fs subvolume snapshot clone '
297 'name=vol_name,type=CephString '
298 'name=sub_name,type=CephString '
299 'name=snap_name,type=CephString '
300 'name=target_sub_name,type=CephString '
301 'name=pool_layout,type=CephString,req=false '
302 'name=group_name,type=CephString,req=false '
303 'name=target_group_name,type=CephString,req=false ',
304 'desc': "Clone a snapshot to target subvolume",
305 'perm': 'rw'
306 },
307 {
308 'cmd': 'fs clone status '
309 'name=vol_name,type=CephString '
310 'name=clone_name,type=CephString '
311 'name=group_name,type=CephString,req=false ',
312 'desc': "Get status on a cloned subvolume.",
313 'perm': 'r'
314 },
9f95a23c
TL
315 {
316 'cmd': 'fs clone cancel '
317 'name=vol_name,type=CephString '
318 'name=clone_name,type=CephString '
319 'name=group_name,type=CephString,req=false ',
320 'desc': "Cancel an pending or ongoing clone operation.",
321 'perm': 'r'
322 },
11fdf7f2
TL
323 # volume ls [recursive]
324 # subvolume ls <volume>
325 # volume authorize/deauthorize
326 # subvolume authorize/deauthorize
327
328 # volume describe (free space, etc)
329 # volume auth list (vc.get_authorized_ids)
330
331 # snapshots?
332
333 # FIXME: we're doing CephFSVolumeClient.recover on every
334 # path where we instantiate and connect a client. Perhaps
335 # keep clients alive longer, or just pass a "don't recover"
336 # flag in if it's the >1st time we connected a particular
337 # volume in the lifetime of this module instance.
338 ]
339
f91f0fd5 340 MODULE_OPTIONS = [
f67539c2
TL
341 Option(
342 'max_concurrent_clones',
343 type='int',
344 default=4,
345 desc='Number of asynchronous cloner threads',
346 )
f91f0fd5
TL
347 ]
348
11fdf7f2 349 def __init__(self, *args, **kwargs):
f91f0fd5
TL
350 self.inited = False
351 # for mypy
352 self.max_concurrent_clones = None
353 self.lock = threading.Lock()
11fdf7f2 354 super(Module, self).__init__(*args, **kwargs)
f91f0fd5
TL
355 # Initialize config option members
356 self.config_notify()
357 with self.lock:
358 self.vc = VolumeClient(self)
f91f0fd5 359 self.inited = True
11fdf7f2 360
92f5a8d4
TL
361 def __del__(self):
362 self.vc.shutdown()
11fdf7f2 363
92f5a8d4
TL
364 def shutdown(self):
365 self.vc.shutdown()
11fdf7f2 366
f91f0fd5
TL
367 def config_notify(self):
368 """
369 This method is called whenever one of our config options is changed.
370 """
371 with self.lock:
372 for opt in self.MODULE_OPTIONS:
373 setattr(self,
374 opt['name'], # type: ignore
375 self.get_module_option(opt['name'])) # type: ignore
376 self.log.debug(' mgr option %s = %s',
377 opt['name'], getattr(self, opt['name'])) # type: ignore
378 if self.inited:
379 if opt['name'] == "max_concurrent_clones":
380 self.vc.cloner.reconfigure_max_concurrent_clones(self.max_concurrent_clones)
381
11fdf7f2 382 def handle_command(self, inbuf, cmd):
11fdf7f2
TL
383 handler_name = "_cmd_" + cmd['prefix'].replace(" ", "_")
384 try:
385 handler = getattr(self, handler_name)
386 except AttributeError:
387 return -errno.EINVAL, "", "Unknown command"
388
389 return handler(inbuf, cmd)
390
f91f0fd5 391 @mgr_cmd_wrap
11fdf7f2 392 def _cmd_fs_volume_create(self, inbuf, cmd):
81eedcae 393 vol_id = cmd['name']
9f95a23c
TL
394 placement = cmd.get('placement', '')
395 return self.vc.create_fs_volume(vol_id, placement)
11fdf7f2 396
f91f0fd5 397 @mgr_cmd_wrap
81eedcae 398 def _cmd_fs_volume_rm(self, inbuf, cmd):
11fdf7f2 399 vol_name = cmd['vol_name']
eafe8130 400 confirm = cmd.get('yes-i-really-mean-it', None)
92f5a8d4 401 return self.vc.delete_fs_volume(vol_name, confirm)
11fdf7f2 402
f91f0fd5 403 @mgr_cmd_wrap
81eedcae 404 def _cmd_fs_volume_ls(self, inbuf, cmd):
92f5a8d4 405 return self.vc.list_fs_volumes()
11fdf7f2 406
f91f0fd5 407 @mgr_cmd_wrap
81eedcae
TL
408 def _cmd_fs_subvolumegroup_create(self, inbuf, cmd):
409 """
410 :return: a 3-tuple of return code(int), empty string(str), error message (str)
411 """
494da23a 412 return self.vc.create_subvolume_group(
92f5a8d4
TL
413 vol_name=cmd['vol_name'], group_name=cmd['group_name'],
414 pool_layout=cmd.get('pool_layout', None), mode=cmd.get('mode', '755'),
415 uid=cmd.get('uid', None), gid=cmd.get('gid', None))
11fdf7f2 416
f91f0fd5 417 @mgr_cmd_wrap
81eedcae
TL
418 def _cmd_fs_subvolumegroup_rm(self, inbuf, cmd):
419 """
420 :return: a 3-tuple of return code(int), empty string(str), error message (str)
421 """
92f5a8d4 422 return self.vc.remove_subvolume_group(vol_name=cmd['vol_name'],
494da23a
TL
423 group_name=cmd['group_name'],
424 force=cmd.get('force', False))
11fdf7f2 425
f91f0fd5 426 @mgr_cmd_wrap
eafe8130 427 def _cmd_fs_subvolumegroup_ls(self, inbuf, cmd):
92f5a8d4 428 return self.vc.list_subvolume_groups(vol_name=cmd['vol_name'])
eafe8130 429
f91f0fd5 430 @mgr_cmd_wrap
81eedcae
TL
431 def _cmd_fs_subvolume_create(self, inbuf, cmd):
432 """
433 :return: a 3-tuple of return code(int), empty string(str), error message (str)
434 """
92f5a8d4 435 return self.vc.create_subvolume(vol_name=cmd['vol_name'],
494da23a
TL
436 sub_name=cmd['sub_name'],
437 group_name=cmd.get('group_name', None),
438 size=cmd.get('size', None),
439 pool_layout=cmd.get('pool_layout', None),
92f5a8d4
TL
440 uid=cmd.get('uid', None),
441 gid=cmd.get('gid', None),
e306af50
TL
442 mode=cmd.get('mode', '755'),
443 namespace_isolated=cmd.get('namespace_isolated', False))
11fdf7f2 444
f91f0fd5 445 @mgr_cmd_wrap
11fdf7f2 446 def _cmd_fs_subvolume_rm(self, inbuf, cmd):
81eedcae
TL
447 """
448 :return: a 3-tuple of return code(int), empty string(str), error message (str)
449 """
92f5a8d4 450 return self.vc.remove_subvolume(vol_name=cmd['vol_name'],
494da23a
TL
451 sub_name=cmd['sub_name'],
452 group_name=cmd.get('group_name', None),
adb31ebb
TL
453 force=cmd.get('force', False),
454 retain_snapshots=cmd.get('retain_snapshots', False))
11fdf7f2 455
cd265ab1
TL
456 @mgr_cmd_wrap
457 def _cmd_fs_subvolume_authorize(self, inbuf, cmd):
458 """
459 :return: a 3-tuple of return code(int), secret key(str), error message (str)
460 """
461 return self.vc.authorize_subvolume(vol_name=cmd['vol_name'],
462 sub_name=cmd['sub_name'],
463 auth_id=cmd['auth_id'],
464 group_name=cmd.get('group_name', None),
465 access_level=cmd.get('access_level', 'rw'),
466 tenant_id=cmd.get('tenant_id', None),
467 allow_existing_id=cmd.get('allow_existing_id', False))
468
469 @mgr_cmd_wrap
470 def _cmd_fs_subvolume_deauthorize(self, inbuf, cmd):
471 """
472 :return: a 3-tuple of return code(int), empty string(str), error message (str)
473 """
474 return self.vc.deauthorize_subvolume(vol_name=cmd['vol_name'],
475 sub_name=cmd['sub_name'],
476 auth_id=cmd['auth_id'],
477 group_name=cmd.get('group_name', None))
478
479 @mgr_cmd_wrap
480 def _cmd_fs_subvolume_authorized_list(self, inbuf, cmd):
481 """
482 :return: a 3-tuple of return code(int), list of authids(json), error message (str)
483 """
484 return self.vc.authorized_list(vol_name=cmd['vol_name'],
485 sub_name=cmd['sub_name'],
486 group_name=cmd.get('group_name', None))
487
488 @mgr_cmd_wrap
489 def _cmd_fs_subvolume_evict(self, inbuf, cmd):
490 """
491 :return: a 3-tuple of return code(int), empyt string(str), error message (str)
492 """
493 return self.vc.evict(vol_name=cmd['vol_name'],
494 sub_name=cmd['sub_name'],
495 auth_id=cmd['auth_id'],
496 group_name=cmd.get('group_name', None))
497
f91f0fd5 498 @mgr_cmd_wrap
eafe8130 499 def _cmd_fs_subvolume_ls(self, inbuf, cmd):
92f5a8d4 500 return self.vc.list_subvolumes(vol_name=cmd['vol_name'],
eafe8130
TL
501 group_name=cmd.get('group_name', None))
502
f91f0fd5 503 @mgr_cmd_wrap
494da23a
TL
504 def _cmd_fs_subvolumegroup_getpath(self, inbuf, cmd):
505 return self.vc.getpath_subvolume_group(
92f5a8d4 506 vol_name=cmd['vol_name'], group_name=cmd['group_name'])
11fdf7f2 507
f91f0fd5 508 @mgr_cmd_wrap
81eedcae 509 def _cmd_fs_subvolume_getpath(self, inbuf, cmd):
92f5a8d4 510 return self.vc.subvolume_getpath(vol_name=cmd['vol_name'],
494da23a
TL
511 sub_name=cmd['sub_name'],
512 group_name=cmd.get('group_name', None))
11fdf7f2 513
f91f0fd5 514 @mgr_cmd_wrap
1911f103
TL
515 def _cmd_fs_subvolume_info(self, inbuf, cmd):
516 return self.vc.subvolume_info(vol_name=cmd['vol_name'],
517 sub_name=cmd['sub_name'],
518 group_name=cmd.get('group_name', None))
519
f91f0fd5 520 @mgr_cmd_wrap
f6b5b4d7
TL
521 def _cmd_fs_subvolumegroup_pin(self, inbuf, cmd):
522 return self.vc.pin_subvolume_group(vol_name=cmd['vol_name'],
523 group_name=cmd['group_name'], pin_type=cmd['pin_type'],
524 pin_setting=cmd['pin_setting'])
525
f91f0fd5 526 @mgr_cmd_wrap
81eedcae 527 def _cmd_fs_subvolumegroup_snapshot_create(self, inbuf, cmd):
92f5a8d4 528 return self.vc.create_subvolume_group_snapshot(vol_name=cmd['vol_name'],
494da23a
TL
529 group_name=cmd['group_name'],
530 snap_name=cmd['snap_name'])
11fdf7f2 531
f91f0fd5 532 @mgr_cmd_wrap
81eedcae 533 def _cmd_fs_subvolumegroup_snapshot_rm(self, inbuf, cmd):
92f5a8d4 534 return self.vc.remove_subvolume_group_snapshot(vol_name=cmd['vol_name'],
494da23a
TL
535 group_name=cmd['group_name'],
536 snap_name=cmd['snap_name'],
537 force=cmd.get('force', False))
11fdf7f2 538
f91f0fd5 539 @mgr_cmd_wrap
eafe8130 540 def _cmd_fs_subvolumegroup_snapshot_ls(self, inbuf, cmd):
92f5a8d4 541 return self.vc.list_subvolume_group_snapshots(vol_name=cmd['vol_name'],
eafe8130
TL
542 group_name=cmd['group_name'])
543
f91f0fd5 544 @mgr_cmd_wrap
81eedcae 545 def _cmd_fs_subvolume_snapshot_create(self, inbuf, cmd):
92f5a8d4 546 return self.vc.create_subvolume_snapshot(vol_name=cmd['vol_name'],
494da23a
TL
547 sub_name=cmd['sub_name'],
548 snap_name=cmd['snap_name'],
549 group_name=cmd.get('group_name', None))
11fdf7f2 550
f91f0fd5 551 @mgr_cmd_wrap
81eedcae 552 def _cmd_fs_subvolume_snapshot_rm(self, inbuf, cmd):
92f5a8d4 553 return self.vc.remove_subvolume_snapshot(vol_name=cmd['vol_name'],
494da23a
TL
554 sub_name=cmd['sub_name'],
555 snap_name=cmd['snap_name'],
556 group_name=cmd.get('group_name', None),
557 force=cmd.get('force', False))
eafe8130 558
f91f0fd5 559 @mgr_cmd_wrap
e306af50
TL
560 def _cmd_fs_subvolume_snapshot_info(self, inbuf, cmd):
561 return self.vc.subvolume_snapshot_info(vol_name=cmd['vol_name'],
562 sub_name=cmd['sub_name'],
563 snap_name=cmd['snap_name'],
564 group_name=cmd.get('group_name', None))
565
f91f0fd5 566 @mgr_cmd_wrap
eafe8130 567 def _cmd_fs_subvolume_snapshot_ls(self, inbuf, cmd):
92f5a8d4 568 return self.vc.list_subvolume_snapshots(vol_name=cmd['vol_name'],
eafe8130
TL
569 sub_name=cmd['sub_name'],
570 group_name=cmd.get('group_name', None))
92f5a8d4 571
f91f0fd5 572 @mgr_cmd_wrap
92f5a8d4
TL
573 def _cmd_fs_subvolume_resize(self, inbuf, cmd):
574 return self.vc.resize_subvolume(vol_name=cmd['vol_name'], sub_name=cmd['sub_name'],
575 new_size=cmd['new_size'], group_name=cmd.get('group_name', None),
576 no_shrink=cmd.get('no_shrink', False))
577
f91f0fd5 578 @mgr_cmd_wrap
f6b5b4d7
TL
579 def _cmd_fs_subvolume_pin(self, inbuf, cmd):
580 return self.vc.subvolume_pin(vol_name=cmd['vol_name'],
581 sub_name=cmd['sub_name'], pin_type=cmd['pin_type'],
582 pin_setting=cmd['pin_setting'],
583 group_name=cmd.get('group_name', None))
584
f91f0fd5 585 @mgr_cmd_wrap
92f5a8d4
TL
586 def _cmd_fs_subvolume_snapshot_protect(self, inbuf, cmd):
587 return self.vc.protect_subvolume_snapshot(vol_name=cmd['vol_name'], sub_name=cmd['sub_name'],
588 snap_name=cmd['snap_name'], group_name=cmd.get('group_name', None))
589
f91f0fd5 590 @mgr_cmd_wrap
92f5a8d4
TL
591 def _cmd_fs_subvolume_snapshot_unprotect(self, inbuf, cmd):
592 return self.vc.unprotect_subvolume_snapshot(vol_name=cmd['vol_name'], sub_name=cmd['sub_name'],
593 snap_name=cmd['snap_name'], group_name=cmd.get('group_name', None))
594
f91f0fd5 595 @mgr_cmd_wrap
92f5a8d4
TL
596 def _cmd_fs_subvolume_snapshot_clone(self, inbuf, cmd):
597 return self.vc.clone_subvolume_snapshot(
598 vol_name=cmd['vol_name'], sub_name=cmd['sub_name'], snap_name=cmd['snap_name'],
599 group_name=cmd.get('group_name', None), pool_layout=cmd.get('pool_layout', None),
600 target_sub_name=cmd['target_sub_name'], target_group_name=cmd.get('target_group_name', None))
601
f91f0fd5 602 @mgr_cmd_wrap
92f5a8d4
TL
603 def _cmd_fs_clone_status(self, inbuf, cmd):
604 return self.vc.clone_status(
605 vol_name=cmd['vol_name'], clone_name=cmd['clone_name'], group_name=cmd.get('group_name', None))
9f95a23c 606
f91f0fd5 607 @mgr_cmd_wrap
9f95a23c
TL
608 def _cmd_fs_clone_cancel(self, inbuf, cmd):
609 return self.vc.clone_cancel(
610 vol_name=cmd['vol_name'], clone_name=cmd['clone_name'], group_name=cmd.get('group_name', None))