mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-22 21:10:22 +00:00
d772fc098c
this commit make use of latest go-ceph version https://github.com/ceph/go-ceph/releases/tag/v0.18.0 Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
35 lines
754 B
Go
35 lines
754 B
Go
package rbd
|
|
|
|
// #cgo LDFLAGS: -lrbd
|
|
// #include <stdlib.h>
|
|
// #include <rbd/librbd.h>
|
|
import "C"
|
|
|
|
import (
|
|
"unsafe"
|
|
)
|
|
|
|
// Rename a snapshot.
|
|
//
|
|
// Implements:
|
|
// int rbd_snap_rename(rbd_image_t image, const char *snapname,
|
|
// const char* dstsnapsname);
|
|
func (snapshot *Snapshot) Rename(destName string) error {
|
|
if err := snapshot.validate(imageNeedsIOContext | imageIsOpen | imageNeedsName | snapshotNeedsName); err != nil {
|
|
return err
|
|
}
|
|
|
|
cSrcName := C.CString(snapshot.name)
|
|
cDestName := C.CString(destName)
|
|
defer C.free(unsafe.Pointer(cSrcName))
|
|
defer C.free(unsafe.Pointer(cDestName))
|
|
|
|
err := C.rbd_snap_rename(snapshot.image.image, cSrcName, cDestName)
|
|
if err != 0 {
|
|
return getError(err)
|
|
}
|
|
|
|
snapshot.name = destName
|
|
return nil
|
|
}
|