mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 14:20:19 +00:00
rbd: Add getImageID to get id of an image
add a new function called getImageID to fetch the image id of an image which need to be stored and retrived for Delete operation. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
9b518726ab
commit
9edb3b8e72
@ -235,6 +235,25 @@ func (rv *rbdVolume) openIoctx() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getImageID queries rbd about the given image and stores its id, returns
|
||||||
|
// ErrImageNotFound if provided image is not found
|
||||||
|
func (rv *rbdVolume) getImageID() error {
|
||||||
|
if rv.ImageID != "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
image, err := rv.open()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer image.Close()
|
||||||
|
|
||||||
|
id, err := image.GetId()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rv.ImageID = id
|
||||||
|
return nil
|
||||||
|
}
|
||||||
// open the rbdVolume after it has been connected.
|
// open the rbdVolume after it has been connected.
|
||||||
// ErrPoolNotFound or ErrImageNotFound are returned in case the pool or image
|
// ErrPoolNotFound or ErrImageNotFound are returned in case the pool or image
|
||||||
// can not be found, other errors will contain more details about other issues
|
// can not be found, other errors will contain more details about other issues
|
||||||
|
Loading…
Reference in New Issue
Block a user