Ejemplo n.º 1
0
// RemoveSnapshot deletes a named snapshot for the image provided.
func (img *Image) RemoveSnapshot(snapshotName string) error {
	snapshotStr := C.CString(snapshotName)
	defer func() {
		C.free(unsafe.Pointer(snapshotStr))
	}()

	action := func(image *C.rbd_image_t) error {
		if i, err := C.rbd_snap_remove(*image, snapshotStr); err != nil || i < 0 {
			if i < 0 {
				err = strerror(i)
			}

			return fmt.Errorf("Error creating snapshot: %v", err)
		}

		return nil
	}

	if err := img.pool.wrapOpen(img.imageName, action); err != nil {
		return err
	}

	return nil
}
Ejemplo n.º 2
0
// int rbd_snap_remove(rbd_image_t image, const char *snapname);
func (snapshot *Snapshot) Remove() error {
	var c_snapname *C.char = C.CString(snapshot.name)
	defer C.free(unsafe.Pointer(c_snapname))

	return GetError(C.rbd_snap_remove(snapshot.image.image, c_snapname))
}