def handle_get_mirror_info(self, image_spec: ImageSpec, image: rbd.Image, comp: rados.Completion, info: Dict[str, Union[str, int]]) -> None: pool_id, namespace, image_id = image_spec self.log.debug( "CreateSnapshotRequests.handle_get_mirror_info {}/{}/{}: r={} info={}" .format(pool_id, namespace, image_id, comp.get_return_value(), info)) if comp.get_return_value() < 0: if comp.get_return_value() != -errno.ENOENT: self.log.error( "error when getting mirror info for {}/{}/{}: {}".format( pool_id, namespace, image_id, comp.get_return_value())) self.close_image(image_spec, image) return if not info['primary']: self.log.debug( "CreateSnapshotRequests.handle_get_mirror_info: {}/{}/{}: {}". format(pool_id, namespace, image_id, "is not primary")) self.close_image(image_spec, image) return self.create_snapshot(image_spec, image)
def handle_get_mirror_mode(self, image_spec: ImageSpec, image: rbd.Image, comp: rados.Completion, mode: int) -> None: pool_id, namespace, image_id = image_spec self.log.debug( "CreateSnapshotRequests.handle_get_mirror_mode {}/{}/{}: r={} mode={}" .format(pool_id, namespace, image_id, comp.get_return_value(), mode)) if comp.get_return_value() < 0: if comp.get_return_value() != -errno.ENOENT: self.log.error( "error when getting mirror mode for {}/{}/{}: {}".format( pool_id, namespace, image_id, comp.get_return_value())) self.close_image(image_spec, image) return if mode != rbd.RBD_MIRROR_IMAGE_MODE_SNAPSHOT: self.log.debug( "CreateSnapshotRequests.handle_get_mirror_mode: {}/{}/{}: {}". format(pool_id, namespace, image_id, "snapshot mirroring is not enabled")) self.close_image(image_spec, image) return self.get_mirror_info(image_spec, image)
def handle_close_image(self, image_spec: ImageSpec, comp: rados.Completion) -> None: pool_id, namespace, image_id = image_spec self.log.debug( "CreateSnapshotRequests.handle_close_image {}/{}/{}: r={}".format( pool_id, namespace, image_id, comp.get_return_value())) if comp.get_return_value() < 0: self.log.error("error when closing {}/{}/{}: {}".format( pool_id, namespace, image_id, comp.get_return_value())) self.finish(image_spec)
def handle_open_image(self, image_spec: ImageSpec, comp: rados.Completion, image: rbd.Image) -> None: pool_id, namespace, image_id = image_spec self.log.debug( "CreateSnapshotRequests.handle_open_image {}/{}/{}: r={}".format( pool_id, namespace, image_id, comp.get_return_value())) if comp.get_return_value() < 0: if comp.get_return_value() != -errno.ENOENT: self.log.error("error when opening {}/{}/{}: {}".format( pool_id, namespace, image_id, comp.get_return_value())) self.finish(image_spec) return self.get_mirror_mode(image_spec, image)
def handle_create_snapshot(self, image_spec: ImageSpec, image: rbd.Image, comp: rados.Completion, snap_id: int) -> None: pool_id, namespace, image_id = image_spec self.log.debug( "CreateSnapshotRequests.handle_create_snapshot for {}/{}/{}: r={}, snap_id={}" .format(pool_id, namespace, image_id, comp.get_return_value(), snap_id)) if comp.get_return_value() < 0 and \ comp.get_return_value() != -errno.ENOENT: self.log.error( "error when creating snapshot for {}/{}/{}: {}".format( pool_id, namespace, image_id, comp.get_return_value())) self.close_image(image_spec, image)