summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/volumes/fs/operations/template.py
blob: eb55bd7432519cc3f9d5e5bc3f87773bcd968ff8 (plain)
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
import errno

from enum import Enum, unique

from ..exception import VolumeException

class GroupTemplate(object):
    def list_subvolumes(self):
        raise VolumeException(-errno.ENOTSUP, "operation not supported.")

    def create_snapshot(self, snapname):
        """
        create a subvolume group snapshot.

        :param: group snapshot name
        :return: None
        """
        raise VolumeException(-errno.ENOTSUP, "operation not supported.")

    def remove_snapshot(self, snapname):
        """
        remove a subvolume group snapshot.

        :param: group snapshot name
        :return: None
        """
        raise VolumeException(-errno.ENOTSUP, "operation not supported.")

    def list_snapshots(self):
        """
        list all subvolume group snapshots.

        :param: None
        :return: None
        """
        raise VolumeException(-errno.ENOTSUP, "operation not supported.")

@unique
class SubvolumeOpType(Enum):
    CREATE                = 'create'
    REMOVE                = 'rm'
    REMOVE_FORCE          = 'rm-force'
    PIN                   = 'pin'
    LIST                  = 'ls'
    GETPATH               = 'getpath'
    INFO                  = 'info'
    RESIZE                = 'resize'
    SNAP_CREATE           = 'snap-create'
    SNAP_REMOVE           = 'snap-rm'
    SNAP_LIST             = 'snap-ls'
    SNAP_INFO             = 'snap-info'
    SNAP_PROTECT          = 'snap-protect'
    SNAP_UNPROTECT        = 'snap-unprotect'
    CLONE_SOURCE          = 'clone-source'
    CLONE_CREATE          = 'clone-create'
    CLONE_STATUS          = 'clone-status'
    CLONE_CANCEL          = 'clone-cancel'
    CLONE_INTERNAL        = 'clone_internal'
    ALLOW_ACCESS          = 'allow-access'
    DENY_ACCESS           = 'deny-access'
    AUTH_LIST             = 'auth-list'
    EVICT                 = 'evict'
    USER_METADATA_SET     = 'user-metadata-set'
    USER_METADATA_GET     = 'user-metadata-get'
    USER_METADATA_LIST    = 'user-metadata-ls'
    USER_METADATA_REMOVE  = 'user-metadata-rm'
    SNAP_METADATA_SET     = 'snap-metadata-set'
    SNAP_METADATA_GET     = 'snap-metadata-get'
    SNAP_METADATA_LIST    = 'snap-metadata-ls'
    SNAP_METADATA_REMOVE  = 'snap-metadata-rm'

class SubvolumeTemplate(object):
    VERSION = None # type: int

    @staticmethod
    def version():
        return SubvolumeTemplate.VERSION

    def open(self, op_type):
        raise VolumeException(-errno.ENOTSUP, "operation not supported.")

    def status(self):
        raise VolumeException(-errno.ENOTSUP, "operation not supported.")

    def create(self, size, isolate_nspace, pool, mode, uid, gid):
        """
        set up metadata, pools and auth for a subvolume.

        This function is idempotent.  It is safe to call this again
        for an already-created subvolume, even if it is in use.

        :param size: In bytes, or None for no size limit
        :param isolate_nspace: If true, use separate RADOS namespace for this subvolume
        :param pool: the RADOS pool where the data objects of the subvolumes will be stored
        :param mode: the user permissions
        :param uid: the user identifier
        :param gid: the group identifier
        :return: None
        """
        raise VolumeException(-errno.ENOTSUP, "operation not supported.")

    def create_clone(self, pool, source_volname, source_subvolume, snapname):
        """
        prepare a subvolume to be cloned.

        :param pool: the RADOS pool where the data objects of the cloned subvolume will be stored
        :param source_volname: source volume of snapshot
        :param source_subvolume: source subvolume of snapshot
        :param snapname: snapshot name to be cloned from
        :return: None
        """
        raise VolumeException(-errno.ENOTSUP, "operation not supported.")

    def remove(self):
        """
        make a subvolume inaccessible to guests.

        This function is idempotent.  It is safe to call this again

        :param: None
        :return: None
        """
        raise VolumeException(-errno.ENOTSUP, "operation not supported.")

    def resize(self, newsize, nshrink):
        """
        resize a subvolume

        :param newsize: new size In bytes (or inf/infinite)
        :return: new quota size and used bytes as a tuple
        """
        raise VolumeException(-errno.ENOTSUP, "operation not supported.")

    def pin(self, pin_type, pin_setting):
        """
        pin a subvolume

        :param pin_type: type of pin
        :param pin_setting: setting for pin
        :return: None
        """
        raise VolumeException(-errno.ENOTSUP, "operation not supported.")

    def create_snapshot(self, snapname):
        """
        snapshot a subvolume.

        :param: subvolume snapshot name
        :return: None
        """
        raise VolumeException(-errno.ENOTSUP, "operation not supported.")

    def remove_snapshot(self, snapname):
        """
        remove a subvolume snapshot.

        :param: subvolume snapshot name
        :return: None
        """
        raise VolumeException(-errno.ENOTSUP, "operation not supported.")

    def list_snapshots(self):
        """
        list all subvolume snapshots.

        :param: None
        :return: None
        """
        raise VolumeException(-errno.ENOTSUP, "operation not supported.")

    def attach_snapshot(self, snapname, tgt_subvolume):
        """
        attach a snapshot to a target cloned subvolume. the target subvolume
        should be an empty subvolume (type "clone") in "pending" state.

        :param: snapname: snapshot to attach to a clone
        :param: tgt_subvolume: target clone subvolume
        :return: None
        """
        raise VolumeException(-errno.ENOTSUP, "operation not supported.")

    def detach_snapshot(self, snapname, tgt_subvolume):
        """
        detach a snapshot from a target cloned subvolume. the target subvolume
        should either be in "failed" or "completed" state.

        :param: snapname: snapshot to detach from a clone
        :param: tgt_subvolume: target clone subvolume
        :return: None
        """
        raise VolumeException(-errno.ENOTSUP, "operation not supported.")