]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/volumes/module.py
752dde33e3e6badbbffee67c03edd1ece9912f8d
[ceph.git] / ceph / src / pybind / mgr / volumes / module.py
1 import errno
2 import logging
3 import traceback
4 import threading
5
6 from mgr_module import MgrModule, Option
7 import orchestrator
8
9 from .fs.volume import VolumeClient
10
11 log = logging.getLogger(__name__)
12
13 goodchars = '[A-Za-z0-9-_.]'
14
15
16 class VolumesInfoWrapper():
17 def __init__(self, f, context):
18 self.f = f
19 self.context = context
20
21 def __enter__(self):
22 log.info("Starting {}".format(self.context))
23
24 def __exit__(self, exc_type, exc_value, tb):
25 if exc_type is not None:
26 log.error("Failed {}:\n{}".format(self.context, "".join(traceback.format_exception(exc_type, exc_value, tb))))
27 else:
28 log.info("Finishing {}".format(self.context))
29
30
31 def mgr_cmd_wrap(f):
32 def wrap(self, inbuf, cmd):
33 astr = []
34 for k in cmd:
35 astr.append("{}:{}".format(k, cmd[k]))
36 context = "{}({}) < \"{}\"".format(f.__name__, ", ".join(astr), inbuf)
37 with VolumesInfoWrapper(f, context):
38 return f(self, inbuf, cmd)
39 return wrap
40
41
42 class Module(orchestrator.OrchestratorClientMixin, MgrModule):
43 COMMANDS = [
44 {
45 'cmd': 'fs volume ls',
46 'desc': "List volumes",
47 'perm': 'r'
48 },
49 {
50 'cmd': 'fs volume create '
51 f'name=name,type=CephString,goodchars={goodchars} '
52 'name=placement,type=CephString,req=false ',
53 'desc': "Create a CephFS volume",
54 'perm': 'rw'
55 },
56 {
57 'cmd': 'fs volume rm '
58 'name=vol_name,type=CephString '
59 'name=yes-i-really-mean-it,type=CephString,req=false ',
60 'desc': "Delete a FS volume by passing --yes-i-really-mean-it flag",
61 'perm': 'rw'
62 },
63 {
64 'cmd': 'fs volume rename '
65 f'name=vol_name,type=CephString,goodchars={goodchars} '
66 f'name=new_vol_name,type=CephString,goodchars={goodchars} '
67 'name=yes_i_really_mean_it,type=CephBool,req=false ',
68 'desc': "Rename a CephFS volume by passing --yes-i-really-mean-it flag",
69 'perm': 'rw'
70 },
71 {
72 'cmd': 'fs volume info '
73 'name=vol_name,type=CephString ',
74 'desc': "Get the information of a CephFS volume",
75 'perm': 'r'
76 },
77 {
78 'cmd': 'fs subvolumegroup ls '
79 'name=vol_name,type=CephString ',
80 'desc': "List subvolumegroups",
81 'perm': 'r'
82 },
83 {
84 'cmd': 'fs subvolumegroup create '
85 'name=vol_name,type=CephString '
86 f'name=group_name,type=CephString,goodchars={goodchars} '
87 'name=size,type=CephInt,req=false '
88 'name=pool_layout,type=CephString,req=false '
89 'name=uid,type=CephInt,req=false '
90 'name=gid,type=CephInt,req=false '
91 'name=mode,type=CephString,req=false ',
92 'desc': "Create a CephFS subvolume group in a volume, and optionally, "
93 "with a specific data pool layout, and a specific numeric mode",
94 'perm': 'rw'
95 },
96 {
97 'cmd': 'fs subvolumegroup rm '
98 'name=vol_name,type=CephString '
99 'name=group_name,type=CephString '
100 'name=force,type=CephBool,req=false ',
101 'desc': "Delete a CephFS subvolume group in a volume",
102 'perm': 'rw'
103 },
104 {
105 'cmd': 'fs subvolumegroup info '
106 'name=vol_name,type=CephString '
107 'name=group_name,type=CephString ',
108 'desc': "Get the metadata of a CephFS subvolume group in a volume, ",
109 'perm': 'r'
110 },
111 {
112 'cmd': 'fs subvolumegroup resize '
113 'name=vol_name,type=CephString '
114 'name=group_name,type=CephString '
115 'name=new_size,type=CephString,req=true '
116 'name=no_shrink,type=CephBool,req=false ',
117 'desc': "Resize a CephFS subvolume group",
118 'perm': 'rw'
119 },
120 {
121 'cmd': 'fs subvolumegroup exist '
122 'name=vol_name,type=CephString ',
123 'desc': "Check a volume for the existence of subvolumegroup",
124 'perm': 'r'
125 },
126 {
127 'cmd': 'fs subvolume ls '
128 'name=vol_name,type=CephString '
129 'name=group_name,type=CephString,req=false ',
130 'desc': "List subvolumes",
131 'perm': 'r'
132 },
133 {
134 'cmd': 'fs subvolume create '
135 'name=vol_name,type=CephString '
136 f'name=sub_name,type=CephString,goodchars={goodchars} '
137 'name=size,type=CephInt,req=false '
138 'name=group_name,type=CephString,req=false '
139 'name=pool_layout,type=CephString,req=false '
140 'name=uid,type=CephInt,req=false '
141 'name=gid,type=CephInt,req=false '
142 'name=mode,type=CephString,req=false '
143 'name=namespace_isolated,type=CephBool,req=false ',
144 'desc': "Create a CephFS subvolume in a volume, and optionally, "
145 "with a specific size (in bytes), a specific data pool layout, "
146 "a specific mode, in a specific subvolume group and in separate "
147 "RADOS namespace",
148 'perm': 'rw'
149 },
150 {
151 'cmd': 'fs subvolume rm '
152 'name=vol_name,type=CephString '
153 'name=sub_name,type=CephString '
154 'name=group_name,type=CephString,req=false '
155 'name=force,type=CephBool,req=false '
156 'name=retain_snapshots,type=CephBool,req=false ',
157 'desc': "Delete a CephFS subvolume in a volume, and optionally, "
158 "in a specific subvolume group, force deleting a cancelled or failed "
159 "clone, and retaining existing subvolume snapshots",
160 'perm': 'rw'
161 },
162 {
163 'cmd': 'fs subvolume authorize '
164 'name=vol_name,type=CephString '
165 'name=sub_name,type=CephString '
166 'name=auth_id,type=CephString '
167 'name=group_name,type=CephString,req=false '
168 'name=access_level,type=CephString,req=false '
169 'name=tenant_id,type=CephString,req=false '
170 'name=allow_existing_id,type=CephBool,req=false ',
171 'desc': "Allow a cephx auth ID access to a subvolume",
172 'perm': 'rw'
173 },
174 {
175 'cmd': 'fs subvolume deauthorize '
176 'name=vol_name,type=CephString '
177 'name=sub_name,type=CephString '
178 'name=auth_id,type=CephString '
179 'name=group_name,type=CephString,req=false ',
180 'desc': "Deny a cephx auth ID access to a subvolume",
181 'perm': 'rw'
182 },
183 {
184 'cmd': 'fs subvolume authorized_list '
185 'name=vol_name,type=CephString '
186 'name=sub_name,type=CephString '
187 'name=group_name,type=CephString,req=false ',
188 'desc': "List auth IDs that have access to a subvolume",
189 'perm': 'r'
190 },
191 {
192 'cmd': 'fs subvolume evict '
193 'name=vol_name,type=CephString '
194 'name=sub_name,type=CephString '
195 'name=auth_id,type=CephString '
196 'name=group_name,type=CephString,req=false ',
197 'desc': "Evict clients based on auth IDs and subvolume mounted",
198 'perm': 'rw'
199 },
200 {
201 'cmd': 'fs subvolumegroup getpath '
202 'name=vol_name,type=CephString '
203 'name=group_name,type=CephString ',
204 'desc': "Get the mountpath of a CephFS subvolume group in a volume",
205 'perm': 'r'
206 },
207 {
208 'cmd': 'fs subvolume getpath '
209 'name=vol_name,type=CephString '
210 'name=sub_name,type=CephString '
211 'name=group_name,type=CephString,req=false ',
212 'desc': "Get the mountpath of a CephFS subvolume in a volume, "
213 "and optionally, in a specific subvolume group",
214 'perm': 'rw'
215 },
216 {
217 'cmd': 'fs subvolume info '
218 'name=vol_name,type=CephString '
219 'name=sub_name,type=CephString '
220 'name=group_name,type=CephString,req=false ',
221 'desc': "Get the information of a CephFS subvolume in a volume, "
222 "and optionally, in a specific subvolume group",
223 'perm': 'r'
224 },
225 {
226 'cmd': 'fs subvolume exist '
227 'name=vol_name,type=CephString '
228 'name=group_name,type=CephString,req=false ',
229 'desc': "Check a volume for the existence of a subvolume, "
230 "optionally in a specified subvolume group",
231 'perm': 'r'
232 },
233 {
234 'cmd': 'fs subvolume metadata set '
235 'name=vol_name,type=CephString '
236 'name=sub_name,type=CephString '
237 'name=key_name,type=CephString '
238 'name=value,type=CephString '
239 'name=group_name,type=CephString,req=false ',
240 'desc': "Set custom metadata (key-value) for a CephFS subvolume in a volume, "
241 "and optionally, in a specific subvolume group",
242 'perm': 'rw'
243 },
244 {
245 'cmd': 'fs subvolume metadata get '
246 'name=vol_name,type=CephString '
247 'name=sub_name,type=CephString '
248 'name=key_name,type=CephString '
249 'name=group_name,type=CephString,req=false ',
250 'desc': "Get custom metadata associated with the key of a CephFS subvolume in a volume, "
251 "and optionally, in a specific subvolume group",
252 'perm': 'r'
253 },
254 {
255 'cmd': 'fs subvolume metadata ls '
256 'name=vol_name,type=CephString '
257 'name=sub_name,type=CephString '
258 'name=group_name,type=CephString,req=false ',
259 'desc': "List custom metadata (key-value pairs) of a CephFS subvolume in a volume, "
260 "and optionally, in a specific subvolume group",
261 'perm': 'r'
262 },
263 {
264 'cmd': 'fs subvolume metadata rm '
265 'name=vol_name,type=CephString '
266 'name=sub_name,type=CephString '
267 'name=key_name,type=CephString '
268 'name=group_name,type=CephString,req=false '
269 'name=force,type=CephBool,req=false ',
270 'desc': "Remove custom metadata (key-value) associated with the key of a CephFS subvolume in a volume, "
271 "and optionally, in a specific subvolume group",
272 'perm': 'rw'
273 },
274 {
275 'cmd': 'fs subvolumegroup pin'
276 ' name=vol_name,type=CephString'
277 ' name=group_name,type=CephString,req=true'
278 ' name=pin_type,type=CephChoices,strings=export|distributed|random'
279 ' name=pin_setting,type=CephString,req=true',
280 'desc': "Set MDS pinning policy for subvolumegroup",
281 'perm': 'rw'
282 },
283 {
284 'cmd': 'fs subvolumegroup snapshot ls '
285 'name=vol_name,type=CephString '
286 'name=group_name,type=CephString ',
287 'desc': "List subvolumegroup snapshots",
288 'perm': 'r'
289 },
290 {
291 'cmd': 'fs subvolumegroup snapshot create '
292 'name=vol_name,type=CephString '
293 'name=group_name,type=CephString '
294 'name=snap_name,type=CephString ',
295 'desc': "Create a snapshot of a CephFS subvolume group in a volume",
296 'perm': 'rw'
297 },
298 {
299 'cmd': 'fs subvolumegroup snapshot rm '
300 'name=vol_name,type=CephString '
301 'name=group_name,type=CephString '
302 'name=snap_name,type=CephString '
303 'name=force,type=CephBool,req=false ',
304 'desc': "Delete a snapshot of a CephFS subvolume group in a volume",
305 'perm': 'rw'
306 },
307 {
308 'cmd': 'fs subvolume snapshot ls '
309 'name=vol_name,type=CephString '
310 'name=sub_name,type=CephString '
311 'name=group_name,type=CephString,req=false ',
312 'desc': "List subvolume snapshots",
313 'perm': 'r'
314 },
315 {
316 'cmd': 'fs subvolume snapshot create '
317 'name=vol_name,type=CephString '
318 'name=sub_name,type=CephString '
319 'name=snap_name,type=CephString '
320 'name=group_name,type=CephString,req=false ',
321 'desc': "Create a snapshot of a CephFS subvolume in a volume, "
322 "and optionally, in a specific subvolume group",
323 'perm': 'rw'
324 },
325 {
326 'cmd': 'fs subvolume snapshot info '
327 'name=vol_name,type=CephString '
328 'name=sub_name,type=CephString '
329 'name=snap_name,type=CephString '
330 'name=group_name,type=CephString,req=false ',
331 'desc': "Get the information of a CephFS subvolume snapshot "
332 "and optionally, in a specific subvolume group",
333 'perm': 'r'
334 },
335 {
336 'cmd': 'fs subvolume snapshot metadata set '
337 'name=vol_name,type=CephString '
338 'name=sub_name,type=CephString '
339 'name=snap_name,type=CephString '
340 'name=key_name,type=CephString '
341 'name=value,type=CephString '
342 'name=group_name,type=CephString,req=false ',
343 'desc': "Set custom metadata (key-value) for a CephFS subvolume snapshot in a volume, "
344 "and optionally, in a specific subvolume group",
345 'perm': 'rw'
346 },
347 {
348 'cmd': 'fs subvolume snapshot metadata get '
349 'name=vol_name,type=CephString '
350 'name=sub_name,type=CephString '
351 'name=snap_name,type=CephString '
352 'name=key_name,type=CephString '
353 'name=group_name,type=CephString,req=false ',
354 'desc': "Get custom metadata associated with the key of a CephFS subvolume snapshot in a volume, "
355 "and optionally, in a specific subvolume group",
356 'perm': 'r'
357 },
358 {
359 'cmd': 'fs subvolume snapshot metadata ls '
360 'name=vol_name,type=CephString '
361 'name=sub_name,type=CephString '
362 'name=snap_name,type=CephString '
363 'name=group_name,type=CephString,req=false ',
364 'desc': "List custom metadata (key-value pairs) of a CephFS subvolume snapshot in a volume, "
365 "and optionally, in a specific subvolume group",
366 'perm': 'r'
367 },
368 {
369 'cmd': 'fs subvolume snapshot metadata rm '
370 'name=vol_name,type=CephString '
371 'name=sub_name,type=CephString '
372 'name=snap_name,type=CephString '
373 'name=key_name,type=CephString '
374 'name=group_name,type=CephString,req=false '
375 'name=force,type=CephBool,req=false ',
376 'desc': "Remove custom metadata (key-value) associated with the key of a CephFS subvolume snapshot in a volume, "
377 "and optionally, in a specific subvolume group",
378 'perm': 'rw'
379 },
380 {
381 'cmd': 'fs subvolume snapshot rm '
382 'name=vol_name,type=CephString '
383 'name=sub_name,type=CephString '
384 'name=snap_name,type=CephString '
385 'name=group_name,type=CephString,req=false '
386 'name=force,type=CephBool,req=false ',
387 'desc': "Delete a snapshot of a CephFS subvolume in a volume, "
388 "and optionally, in a specific subvolume group",
389 'perm': 'rw'
390 },
391 {
392 'cmd': 'fs subvolume resize '
393 'name=vol_name,type=CephString '
394 'name=sub_name,type=CephString '
395 'name=new_size,type=CephString,req=true '
396 'name=group_name,type=CephString,req=false '
397 'name=no_shrink,type=CephBool,req=false ',
398 'desc': "Resize a CephFS subvolume",
399 'perm': 'rw'
400 },
401 {
402 'cmd': 'fs subvolume pin'
403 ' name=vol_name,type=CephString'
404 ' name=sub_name,type=CephString'
405 ' name=pin_type,type=CephChoices,strings=export|distributed|random'
406 ' name=pin_setting,type=CephString,req=true'
407 ' name=group_name,type=CephString,req=false',
408 'desc': "Set MDS pinning policy for subvolume",
409 'perm': 'rw'
410 },
411 {
412 'cmd': 'fs subvolume snapshot protect '
413 'name=vol_name,type=CephString '
414 'name=sub_name,type=CephString '
415 'name=snap_name,type=CephString '
416 'name=group_name,type=CephString,req=false ',
417 'desc': "(deprecated) Protect snapshot of a CephFS subvolume in a volume, "
418 "and optionally, in a specific subvolume group",
419 'perm': 'rw'
420 },
421 {
422 'cmd': 'fs subvolume snapshot unprotect '
423 'name=vol_name,type=CephString '
424 'name=sub_name,type=CephString '
425 'name=snap_name,type=CephString '
426 'name=group_name,type=CephString,req=false ',
427 'desc': "(deprecated) Unprotect a snapshot of a CephFS subvolume in a volume, "
428 "and optionally, in a specific subvolume group",
429 'perm': 'rw'
430 },
431 {
432 'cmd': 'fs subvolume snapshot clone '
433 'name=vol_name,type=CephString '
434 'name=sub_name,type=CephString '
435 'name=snap_name,type=CephString '
436 'name=target_sub_name,type=CephString '
437 'name=pool_layout,type=CephString,req=false '
438 'name=group_name,type=CephString,req=false '
439 'name=target_group_name,type=CephString,req=false ',
440 'desc': "Clone a snapshot to target subvolume",
441 'perm': 'rw'
442 },
443 {
444 'cmd': 'fs clone status '
445 'name=vol_name,type=CephString '
446 'name=clone_name,type=CephString '
447 'name=group_name,type=CephString,req=false ',
448 'desc': "Get status on a cloned subvolume.",
449 'perm': 'r'
450 },
451 {
452 'cmd': 'fs clone cancel '
453 'name=vol_name,type=CephString '
454 'name=clone_name,type=CephString '
455 'name=group_name,type=CephString,req=false ',
456 'desc': "Cancel an pending or ongoing clone operation.",
457 'perm': 'r'
458 },
459 # volume ls [recursive]
460 # subvolume ls <volume>
461 # volume authorize/deauthorize
462 # subvolume authorize/deauthorize
463
464 # volume describe (free space, etc)
465 # volume auth list (vc.get_authorized_ids)
466
467 # snapshots?
468
469 # FIXME: we're doing CephFSVolumeClient.recover on every
470 # path where we instantiate and connect a client. Perhaps
471 # keep clients alive longer, or just pass a "don't recover"
472 # flag in if it's the >1st time we connected a particular
473 # volume in the lifetime of this module instance.
474 ]
475
476 MODULE_OPTIONS = [
477 Option(
478 'max_concurrent_clones',
479 type='int',
480 default=4,
481 desc='Number of asynchronous cloner threads'),
482 Option(
483 'snapshot_clone_delay',
484 type='int',
485 default=0,
486 desc='Delay clone begin operation by snapshot_clone_delay seconds')
487 ]
488
489 def __init__(self, *args, **kwargs):
490 self.inited = False
491 # for mypy
492 self.max_concurrent_clones = None
493 self.snapshot_clone_delay = None
494 self.lock = threading.Lock()
495 super(Module, self).__init__(*args, **kwargs)
496 # Initialize config option members
497 self.config_notify()
498 with self.lock:
499 self.vc = VolumeClient(self)
500 self.inited = True
501
502 def __del__(self):
503 self.vc.shutdown()
504
505 def shutdown(self):
506 self.vc.shutdown()
507
508 def config_notify(self):
509 """
510 This method is called whenever one of our config options is changed.
511 """
512 with self.lock:
513 for opt in self.MODULE_OPTIONS:
514 setattr(self,
515 opt['name'], # type: ignore
516 self.get_module_option(opt['name'])) # type: ignore
517 self.log.debug(' mgr option %s = %s',
518 opt['name'], getattr(self, opt['name'])) # type: ignore
519 if self.inited:
520 if opt['name'] == "max_concurrent_clones":
521 self.vc.cloner.reconfigure_max_concurrent_clones(self.max_concurrent_clones)
522 elif opt['name'] == "snapshot_clone_delay":
523 self.vc.cloner.reconfigure_snapshot_clone_delay(self.snapshot_clone_delay)
524
525 def handle_command(self, inbuf, cmd):
526 handler_name = "_cmd_" + cmd['prefix'].replace(" ", "_")
527 try:
528 handler = getattr(self, handler_name)
529 except AttributeError:
530 return -errno.EINVAL, "", "Unknown command"
531
532 return handler(inbuf, cmd)
533
534 @mgr_cmd_wrap
535 def _cmd_fs_volume_create(self, inbuf, cmd):
536 vol_id = cmd['name']
537 placement = cmd.get('placement', '')
538 return self.vc.create_fs_volume(vol_id, placement)
539
540 @mgr_cmd_wrap
541 def _cmd_fs_volume_rm(self, inbuf, cmd):
542 vol_name = cmd['vol_name']
543 confirm = cmd.get('yes-i-really-mean-it', None)
544 return self.vc.delete_fs_volume(vol_name, confirm)
545
546 @mgr_cmd_wrap
547 def _cmd_fs_volume_ls(self, inbuf, cmd):
548 return self.vc.list_fs_volumes()
549
550 @mgr_cmd_wrap
551 def _cmd_fs_volume_rename(self, inbuf, cmd):
552 return self.vc.rename_fs_volume(cmd['vol_name'],
553 cmd['new_vol_name'],
554 cmd.get('yes_i_really_mean_it', False))
555
556 @mgr_cmd_wrap
557 def _cmd_fs_volume_info(self, inbuf, cmd):
558 return self.vc.volume_info(vol_name=cmd['vol_name'])
559
560 @mgr_cmd_wrap
561 def _cmd_fs_subvolumegroup_create(self, inbuf, cmd):
562 """
563 :return: a 3-tuple of return code(int), empty string(str), error message (str)
564 """
565 return self.vc.create_subvolume_group(
566 vol_name=cmd['vol_name'], group_name=cmd['group_name'], size=cmd.get('size', None),
567 pool_layout=cmd.get('pool_layout', None), mode=cmd.get('mode', '755'),
568 uid=cmd.get('uid', None), gid=cmd.get('gid', None))
569
570 @mgr_cmd_wrap
571 def _cmd_fs_subvolumegroup_rm(self, inbuf, cmd):
572 """
573 :return: a 3-tuple of return code(int), empty string(str), error message (str)
574 """
575 return self.vc.remove_subvolume_group(vol_name=cmd['vol_name'],
576 group_name=cmd['group_name'],
577 force=cmd.get('force', False))
578
579 @mgr_cmd_wrap
580 def _cmd_fs_subvolumegroup_info(self, inbuf, cmd):
581 return self.vc.subvolumegroup_info(vol_name=cmd['vol_name'],
582 group_name=cmd['group_name'])
583
584 @mgr_cmd_wrap
585 def _cmd_fs_subvolumegroup_resize(self, inbuf, cmd):
586 return self.vc.resize_subvolume_group(vol_name=cmd['vol_name'],
587 group_name=cmd['group_name'],
588 new_size=cmd['new_size'],
589 no_shrink=cmd.get('no_shrink', False))
590 @mgr_cmd_wrap
591 def _cmd_fs_subvolumegroup_ls(self, inbuf, cmd):
592 return self.vc.list_subvolume_groups(vol_name=cmd['vol_name'])
593
594 @mgr_cmd_wrap
595 def _cmd_fs_subvolumegroup_exist(self, inbuf, cmd):
596 return self.vc.subvolume_group_exists(vol_name=cmd['vol_name'])
597
598 @mgr_cmd_wrap
599 def _cmd_fs_subvolume_create(self, inbuf, cmd):
600 """
601 :return: a 3-tuple of return code(int), empty string(str), error message (str)
602 """
603 return self.vc.create_subvolume(vol_name=cmd['vol_name'],
604 sub_name=cmd['sub_name'],
605 group_name=cmd.get('group_name', None),
606 size=cmd.get('size', None),
607 pool_layout=cmd.get('pool_layout', None),
608 uid=cmd.get('uid', None),
609 gid=cmd.get('gid', None),
610 mode=cmd.get('mode', '755'),
611 namespace_isolated=cmd.get('namespace_isolated', False))
612
613 @mgr_cmd_wrap
614 def _cmd_fs_subvolume_rm(self, inbuf, cmd):
615 """
616 :return: a 3-tuple of return code(int), empty string(str), error message (str)
617 """
618 return self.vc.remove_subvolume(vol_name=cmd['vol_name'],
619 sub_name=cmd['sub_name'],
620 group_name=cmd.get('group_name', None),
621 force=cmd.get('force', False),
622 retain_snapshots=cmd.get('retain_snapshots', False))
623
624 @mgr_cmd_wrap
625 def _cmd_fs_subvolume_authorize(self, inbuf, cmd):
626 """
627 :return: a 3-tuple of return code(int), secret key(str), error message (str)
628 """
629 return self.vc.authorize_subvolume(vol_name=cmd['vol_name'],
630 sub_name=cmd['sub_name'],
631 auth_id=cmd['auth_id'],
632 group_name=cmd.get('group_name', None),
633 access_level=cmd.get('access_level', 'rw'),
634 tenant_id=cmd.get('tenant_id', None),
635 allow_existing_id=cmd.get('allow_existing_id', False))
636
637 @mgr_cmd_wrap
638 def _cmd_fs_subvolume_deauthorize(self, inbuf, cmd):
639 """
640 :return: a 3-tuple of return code(int), empty string(str), error message (str)
641 """
642 return self.vc.deauthorize_subvolume(vol_name=cmd['vol_name'],
643 sub_name=cmd['sub_name'],
644 auth_id=cmd['auth_id'],
645 group_name=cmd.get('group_name', None))
646
647 @mgr_cmd_wrap
648 def _cmd_fs_subvolume_authorized_list(self, inbuf, cmd):
649 """
650 :return: a 3-tuple of return code(int), list of authids(json), error message (str)
651 """
652 return self.vc.authorized_list(vol_name=cmd['vol_name'],
653 sub_name=cmd['sub_name'],
654 group_name=cmd.get('group_name', None))
655
656 @mgr_cmd_wrap
657 def _cmd_fs_subvolume_evict(self, inbuf, cmd):
658 """
659 :return: a 3-tuple of return code(int), empyt string(str), error message (str)
660 """
661 return self.vc.evict(vol_name=cmd['vol_name'],
662 sub_name=cmd['sub_name'],
663 auth_id=cmd['auth_id'],
664 group_name=cmd.get('group_name', None))
665
666 @mgr_cmd_wrap
667 def _cmd_fs_subvolume_ls(self, inbuf, cmd):
668 return self.vc.list_subvolumes(vol_name=cmd['vol_name'],
669 group_name=cmd.get('group_name', None))
670
671 @mgr_cmd_wrap
672 def _cmd_fs_subvolumegroup_getpath(self, inbuf, cmd):
673 return self.vc.getpath_subvolume_group(
674 vol_name=cmd['vol_name'], group_name=cmd['group_name'])
675
676 @mgr_cmd_wrap
677 def _cmd_fs_subvolume_getpath(self, inbuf, cmd):
678 return self.vc.subvolume_getpath(vol_name=cmd['vol_name'],
679 sub_name=cmd['sub_name'],
680 group_name=cmd.get('group_name', None))
681
682 @mgr_cmd_wrap
683 def _cmd_fs_subvolume_info(self, inbuf, cmd):
684 return self.vc.subvolume_info(vol_name=cmd['vol_name'],
685 sub_name=cmd['sub_name'],
686 group_name=cmd.get('group_name', None))
687
688 @mgr_cmd_wrap
689 def _cmd_fs_subvolume_exist(self, inbuf, cmd):
690 return self.vc.subvolume_exists(vol_name=cmd['vol_name'],
691 group_name=cmd.get('group_name', None))
692
693 @mgr_cmd_wrap
694 def _cmd_fs_subvolume_metadata_set(self, inbuf, cmd):
695 return self.vc.set_user_metadata(vol_name=cmd['vol_name'],
696 sub_name=cmd['sub_name'],
697 key_name=cmd['key_name'],
698 value=cmd['value'],
699 group_name=cmd.get('group_name', None))
700
701 @mgr_cmd_wrap
702 def _cmd_fs_subvolume_metadata_get(self, inbuf, cmd):
703 return self.vc.get_user_metadata(vol_name=cmd['vol_name'],
704 sub_name=cmd['sub_name'],
705 key_name=cmd['key_name'],
706 group_name=cmd.get('group_name', None))
707
708 @mgr_cmd_wrap
709 def _cmd_fs_subvolume_metadata_ls(self, inbuf, cmd):
710 return self.vc.list_user_metadata(vol_name=cmd['vol_name'],
711 sub_name=cmd['sub_name'],
712 group_name=cmd.get('group_name', None))
713
714 @mgr_cmd_wrap
715 def _cmd_fs_subvolume_metadata_rm(self, inbuf, cmd):
716 return self.vc.remove_user_metadata(vol_name=cmd['vol_name'],
717 sub_name=cmd['sub_name'],
718 key_name=cmd['key_name'],
719 group_name=cmd.get('group_name', None),
720 force=cmd.get('force', False))
721
722 @mgr_cmd_wrap
723 def _cmd_fs_subvolumegroup_pin(self, inbuf, cmd):
724 return self.vc.pin_subvolume_group(vol_name=cmd['vol_name'],
725 group_name=cmd['group_name'], pin_type=cmd['pin_type'],
726 pin_setting=cmd['pin_setting'])
727
728 @mgr_cmd_wrap
729 def _cmd_fs_subvolumegroup_snapshot_create(self, inbuf, cmd):
730 return self.vc.create_subvolume_group_snapshot(vol_name=cmd['vol_name'],
731 group_name=cmd['group_name'],
732 snap_name=cmd['snap_name'])
733
734 @mgr_cmd_wrap
735 def _cmd_fs_subvolumegroup_snapshot_rm(self, inbuf, cmd):
736 return self.vc.remove_subvolume_group_snapshot(vol_name=cmd['vol_name'],
737 group_name=cmd['group_name'],
738 snap_name=cmd['snap_name'],
739 force=cmd.get('force', False))
740
741 @mgr_cmd_wrap
742 def _cmd_fs_subvolumegroup_snapshot_ls(self, inbuf, cmd):
743 return self.vc.list_subvolume_group_snapshots(vol_name=cmd['vol_name'],
744 group_name=cmd['group_name'])
745
746 @mgr_cmd_wrap
747 def _cmd_fs_subvolume_snapshot_create(self, inbuf, cmd):
748 return self.vc.create_subvolume_snapshot(vol_name=cmd['vol_name'],
749 sub_name=cmd['sub_name'],
750 snap_name=cmd['snap_name'],
751 group_name=cmd.get('group_name', None))
752
753 @mgr_cmd_wrap
754 def _cmd_fs_subvolume_snapshot_rm(self, inbuf, cmd):
755 return self.vc.remove_subvolume_snapshot(vol_name=cmd['vol_name'],
756 sub_name=cmd['sub_name'],
757 snap_name=cmd['snap_name'],
758 group_name=cmd.get('group_name', None),
759 force=cmd.get('force', False))
760
761 @mgr_cmd_wrap
762 def _cmd_fs_subvolume_snapshot_info(self, inbuf, cmd):
763 return self.vc.subvolume_snapshot_info(vol_name=cmd['vol_name'],
764 sub_name=cmd['sub_name'],
765 snap_name=cmd['snap_name'],
766 group_name=cmd.get('group_name', None))
767
768 @mgr_cmd_wrap
769 def _cmd_fs_subvolume_snapshot_metadata_set(self, inbuf, cmd):
770 return self.vc.set_subvolume_snapshot_metadata(vol_name=cmd['vol_name'],
771 sub_name=cmd['sub_name'],
772 snap_name=cmd['snap_name'],
773 key_name=cmd['key_name'],
774 value=cmd['value'],
775 group_name=cmd.get('group_name', None))
776
777 @mgr_cmd_wrap
778 def _cmd_fs_subvolume_snapshot_metadata_get(self, inbuf, cmd):
779 return self.vc.get_subvolume_snapshot_metadata(vol_name=cmd['vol_name'],
780 sub_name=cmd['sub_name'],
781 snap_name=cmd['snap_name'],
782 key_name=cmd['key_name'],
783 group_name=cmd.get('group_name', None))
784
785 @mgr_cmd_wrap
786 def _cmd_fs_subvolume_snapshot_metadata_ls(self, inbuf, cmd):
787 return self.vc.list_subvolume_snapshot_metadata(vol_name=cmd['vol_name'],
788 sub_name=cmd['sub_name'],
789 snap_name=cmd['snap_name'],
790 group_name=cmd.get('group_name', None))
791
792 @mgr_cmd_wrap
793 def _cmd_fs_subvolume_snapshot_metadata_rm(self, inbuf, cmd):
794 return self.vc.remove_subvolume_snapshot_metadata(vol_name=cmd['vol_name'],
795 sub_name=cmd['sub_name'],
796 snap_name=cmd['snap_name'],
797 key_name=cmd['key_name'],
798 group_name=cmd.get('group_name', None),
799 force=cmd.get('force', False))
800
801 @mgr_cmd_wrap
802 def _cmd_fs_subvolume_snapshot_ls(self, inbuf, cmd):
803 return self.vc.list_subvolume_snapshots(vol_name=cmd['vol_name'],
804 sub_name=cmd['sub_name'],
805 group_name=cmd.get('group_name', None))
806
807 @mgr_cmd_wrap
808 def _cmd_fs_subvolume_resize(self, inbuf, cmd):
809 return self.vc.resize_subvolume(vol_name=cmd['vol_name'], sub_name=cmd['sub_name'],
810 new_size=cmd['new_size'], group_name=cmd.get('group_name', None),
811 no_shrink=cmd.get('no_shrink', False))
812
813 @mgr_cmd_wrap
814 def _cmd_fs_subvolume_pin(self, inbuf, cmd):
815 return self.vc.subvolume_pin(vol_name=cmd['vol_name'],
816 sub_name=cmd['sub_name'], pin_type=cmd['pin_type'],
817 pin_setting=cmd['pin_setting'],
818 group_name=cmd.get('group_name', None))
819
820 @mgr_cmd_wrap
821 def _cmd_fs_subvolume_snapshot_protect(self, inbuf, cmd):
822 return self.vc.protect_subvolume_snapshot(vol_name=cmd['vol_name'], sub_name=cmd['sub_name'],
823 snap_name=cmd['snap_name'], group_name=cmd.get('group_name', None))
824
825 @mgr_cmd_wrap
826 def _cmd_fs_subvolume_snapshot_unprotect(self, inbuf, cmd):
827 return self.vc.unprotect_subvolume_snapshot(vol_name=cmd['vol_name'], sub_name=cmd['sub_name'],
828 snap_name=cmd['snap_name'], group_name=cmd.get('group_name', None))
829
830 @mgr_cmd_wrap
831 def _cmd_fs_subvolume_snapshot_clone(self, inbuf, cmd):
832 return self.vc.clone_subvolume_snapshot(
833 vol_name=cmd['vol_name'], sub_name=cmd['sub_name'], snap_name=cmd['snap_name'],
834 group_name=cmd.get('group_name', None), pool_layout=cmd.get('pool_layout', None),
835 target_sub_name=cmd['target_sub_name'], target_group_name=cmd.get('target_group_name', None))
836
837 @mgr_cmd_wrap
838 def _cmd_fs_clone_status(self, inbuf, cmd):
839 return self.vc.clone_status(
840 vol_name=cmd['vol_name'], clone_name=cmd['clone_name'], group_name=cmd.get('group_name', None))
841
842 @mgr_cmd_wrap
843 def _cmd_fs_clone_cancel(self, inbuf, cmd):
844 return self.vc.clone_cancel(
845 vol_name=cmd['vol_name'], clone_name=cmd['clone_name'], group_name=cmd.get('group_name', None))