blob: 2223c58e5c00088f770b8dcfe24e92a248bf080b (
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
|
import os
import errno
import cephfs
from ..exception import VolumeException
def mksnap(fs, snappath):
"""
Create a snapshot, or do nothing if it already exists.
"""
try:
# snap create does not accept mode -- use default
fs.mkdir(snappath, 0o755)
except cephfs.ObjectExists:
return
except cephfs.Error as e:
raise VolumeException(-e.args[0], e.args[1])
def rmsnap(fs, snappath):
"""
Remove a snapshot
"""
try:
fs.stat(snappath)
fs.rmdir(snappath)
except cephfs.ObjectNotFound:
raise VolumeException(-errno.ENOENT, "snapshot '{0}' does not exist".format(os.path.basename(snappath)))
except cephfs.Error as e:
raise VolumeException(-e.args[0], e.args[1])
|