]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/volumes/fs/operations/template.py
3fca8dd87f9ec0dc27415d0c25daa632053f14e7
[ceph.git] / ceph / src / pybind / mgr / volumes / fs / operations / template.py
1 import errno
2
3 from enum import Enum, unique
4
5 from ..exception import VolumeException
6
7 class GroupTemplate(object):
8 def list_subvolumes(self):
9 raise VolumeException(-errno.ENOTSUP, "operation not supported.")
10
11 def create_snapshot(self, snapname):
12 """
13 create a subvolume group snapshot.
14
15 :param: group snapshot name
16 :return: None
17 """
18 raise VolumeException(-errno.ENOTSUP, "operation not supported.")
19
20 def remove_snapshot(self, snapname):
21 """
22 remove a subvolume group snapshot.
23
24 :param: group snapshot name
25 :return: None
26 """
27 raise VolumeException(-errno.ENOTSUP, "operation not supported.")
28
29 def list_snapshots(self):
30 """
31 list all subvolume group snapshots.
32
33 :param: None
34 :return: None
35 """
36 raise VolumeException(-errno.ENOTSUP, "operation not supported.")
37
38 @unique
39 class SubvolumeOpType(Enum):
40 CREATE = 'create'
41 REMOVE = 'rm'
42 REMOVE_FORCE = 'rm-force'
43 PIN = 'pin'
44 LIST = 'ls'
45 GETPATH = 'getpath'
46 INFO = 'info'
47 RESIZE = 'resize'
48 SNAP_CREATE = 'snap-create'
49 SNAP_REMOVE = 'snap-rm'
50 SNAP_LIST = 'snap-ls'
51 SNAP_INFO = 'snap-info'
52 SNAP_PROTECT = 'snap-protect'
53 SNAP_UNPROTECT = 'snap-unprotect'
54 CLONE_SOURCE = 'clone-source'
55 CLONE_CREATE = 'clone-create'
56 CLONE_STATUS = 'clone-status'
57 CLONE_CANCEL = 'clone-cancel'
58 CLONE_INTERNAL = 'clone_internal'
59
60 class SubvolumeTemplate(object):
61 VERSION = None # type: int
62
63 @staticmethod
64 def version():
65 return SubvolumeTemplate.VERSION
66
67 def open(self, op_type):
68 raise VolumeException(-errno.ENOTSUP, "operation not supported.")
69
70 def status(self):
71 raise VolumeException(-errno.ENOTSUP, "operation not supported.")
72
73 def create(self, size, isolate_nspace, pool, mode, uid, gid):
74 """
75 set up metadata, pools and auth for a subvolume.
76
77 This function is idempotent. It is safe to call this again
78 for an already-created subvolume, even if it is in use.
79
80 :param size: In bytes, or None for no size limit
81 :param isolate_nspace: If true, use separate RADOS namespace for this subvolume
82 :param pool: the RADOS pool where the data objects of the subvolumes will be stored
83 :param mode: the user permissions
84 :param uid: the user identifier
85 :param gid: the group identifier
86 :return: None
87 """
88 raise VolumeException(-errno.ENOTSUP, "operation not supported.")
89
90 def create_clone(self, pool, source_volname, source_subvolume, snapname):
91 """
92 prepare a subvolume to be cloned.
93
94 :param pool: the RADOS pool where the data objects of the cloned subvolume will be stored
95 :param source_volname: source volume of snapshot
96 :param source_subvolume: source subvolume of snapshot
97 :param snapname: snapshot name to be cloned from
98 :return: None
99 """
100 raise VolumeException(-errno.ENOTSUP, "operation not supported.")
101
102 def remove(self):
103 """
104 make a subvolume inaccessible to guests.
105
106 This function is idempotent. It is safe to call this again
107
108 :param: None
109 :return: None
110 """
111 raise VolumeException(-errno.ENOTSUP, "operation not supported.")
112
113 def resize(self, newsize, nshrink):
114 """
115 resize a subvolume
116
117 :param newsize: new size In bytes (or inf/infinite)
118 :return: new quota size and used bytes as a tuple
119 """
120 raise VolumeException(-errno.ENOTSUP, "operation not supported.")
121
122 def pin(self, pin_type, pin_setting):
123 """
124 pin a subvolume
125
126 :param pin_type: type of pin
127 :param pin_setting: setting for pin
128 :return: None
129 """
130 raise VolumeException(-errno.ENOTSUP, "operation not supported.")
131
132 def create_snapshot(self, snapname):
133 """
134 snapshot a subvolume.
135
136 :param: subvolume snapshot name
137 :return: None
138 """
139 raise VolumeException(-errno.ENOTSUP, "operation not supported.")
140
141 def remove_snapshot(self, snapname):
142 """
143 remove a subvolume snapshot.
144
145 :param: subvolume snapshot name
146 :return: None
147 """
148 raise VolumeException(-errno.ENOTSUP, "operation not supported.")
149
150 def list_snapshots(self):
151 """
152 list all subvolume snapshots.
153
154 :param: None
155 :return: None
156 """
157 raise VolumeException(-errno.ENOTSUP, "operation not supported.")
158
159 def attach_snapshot(self, snapname, tgt_subvolume):
160 """
161 attach a snapshot to a target cloned subvolume. the target subvolume
162 should be an empty subvolume (type "clone") in "pending" state.
163
164 :param: snapname: snapshot to attach to a clone
165 :param: tgt_subvolume: target clone subvolume
166 :return: None
167 """
168 raise VolumeException(-errno.ENOTSUP, "operation not supported.")
169
170 def detach_snapshot(self, snapname, tgt_subvolume):
171 """
172 detach a snapshot from a target cloned subvolume. the target subvolume
173 should either be in "failed" or "completed" state.
174
175 :param: snapname: snapshot to detach from a clone
176 :param: tgt_subvolume: target clone subvolume
177 :return: None
178 """
179 raise VolumeException(-errno.ENOTSUP, "operation not supported.")