CEPH_RBD_API int rbd_snap_list(rbd_image_t image, rbd_snap_info_t *snaps,
int *max_snaps);
CEPH_RBD_API void rbd_snap_list_end(rbd_snap_info_t *snaps);
+CEPH_RBD_API int rbd_snap_exists(rbd_image_t image, const char *snapname, bool *exists);
CEPH_RBD_API int rbd_snap_create(rbd_image_t image, const char *snapname);
CEPH_RBD_API int rbd_snap_remove(rbd_image_t image, const char *snapname);
CEPH_RBD_API int rbd_snap_remove2(rbd_image_t image, const char *snap_name,
return r;
}
+extern "C" int rbd_snap_exists(rbd_image_t image, const char *snapname, bool *exists)
+{
+ librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
+ tracepoint(librbd, snap_exists_enter, ictx, ictx->name.c_str(),
+ ictx->snap_name.c_str(), ictx->read_only, snapname);
+ int r = librbd::api::Snapshot<>::exists(ictx, cls::rbd::UserSnapshotNamespace(), snapname, exists);
+ tracepoint(librbd, snap_exists_exit, r, *exists);
+ return r;
+}
+
extern "C" int rbd_snap_get_timestamp(rbd_image_t image, uint64_t snap_id, struct timespec *timestamp)
{
librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
int rbd_snap_unprotect(rbd_image_t image, const char *snap_name)
int rbd_snap_is_protected(rbd_image_t image, const char *snap_name,
int *is_protected)
+ int rbd_snap_exists(rbd_image_t image, const char *snapname, bint *exists)
int rbd_snap_get_limit(rbd_image_t image, uint64_t *limit)
int rbd_snap_set_limit(rbd_image_t image, uint64_t limit)
int rbd_snap_get_timestamp(rbd_image_t image, uint64_t snap_id, timespec *timestamp)
raise make_ex(ret, 'error checking if snapshot %s@%s is protected' % (self.name, name))
return is_protected == 1
+ def snap_exists(self, name):
+ """
+ Find out whether a snapshot is exists.
+
+ :param name: the snapshot to check
+ :type name: str
+ :returns: bool - whether the snapshot is exists
+ """
+ name = cstr(name, 'name')
+ cdef:
+ char *_name = name
+ bint _exists = False
+ with nogil:
+ ret = rbd_snap_exists(self.image, _name, &_exists)
+ if ret != 0:
+ raise make_ex(ret, 'error getting snapshot exists for %s' % self.name)
+ return bool(_exists != 0)
+
def get_snap_limit(self):
"""
Get the snapshot limit for an image.