"RBD image has snapshots (%s)" % message, errno)
+class ImageMemberOfGroup(OSError):
+ def __init__(self, message, errno=None):
+ super(ImageMemberOfGroup, self).__init__(
+ "RBD image is member of group (%s)" % message, errno)
+
+
class FunctionNotSupported(OSError):
def __init__(self, message, errno=None):
super(FunctionNotSupported, self).__init__(
errno.EROFS : ReadOnlyImage,
errno.EBUSY : ImageBusy,
errno.ENOTEMPTY : ImageHasSnapshots,
+ errno.EMLINK : ImageMemberOfGroup,
errno.ENOSYS : FunctionNotSupported,
errno.EDOM : ArgumentOutOfRange,
errno.ESHUTDOWN : ConnectionShutdown,
errno.EROFS : ReadOnlyImage,
errno.EBUSY : ImageBusy,
errno.ENOTEMPTY : ImageHasSnapshots,
+ errno.EMLINK : ImageMemberOfGroup,
errno.ENOSYS : FunctionNotSupported,
errno.EDOM : ArgumentOutOfRange,
errno.ESHUTDOWN : ConnectionShutdown,
LIBRADOS_OP_FLAG_FADVISE_RANDOM)
from rbd import (RBD, Group, Image, ImageNotFound, InvalidArgument, ImageExists,
ImageBusy, ImageHasSnapshots, ReadOnlyImage, ObjectNotFound,
- FunctionNotSupported, ArgumentOutOfRange,
+ FunctionNotSupported, ArgumentOutOfRange, ImageMemberOfGroup,
ECANCELED, OperationCanceled,
DiskQuotaExceeded, ConnectionShutdown, PermissionError,
RBD_FEATURE_LAYERING, RBD_FEATURE_STRIPINGV2,
eq([], list(self.group.list_images()))
RBD().trash_restore(ioctx, image_id, image_name)
+ def test_group_image_list_remove(self):
+ # need a closed image to get ImageMemberOfGroup instead of ImageBusy
+ self.image_names.append(create_image())
+ eq([], list(self.group.list_images()))
+ self.group.add_image(ioctx, image_name)
+ eq([image_name], [img['name'] for img in self.group.list_images()])
+ assert_raises(ImageMemberOfGroup, RBD().remove, ioctx, image_name)
+ eq([image_name], [img['name'] for img in self.group.list_images()])
+
def test_group_get_id(self):
id = self.group.id()
assert isinstance(id, str)