diff --git a/docs/api-status.json b/docs/api-status.json index a5baa7b..a6128cd 100644 --- a/docs/api-status.json +++ b/docs/api-status.json @@ -1407,6 +1407,10 @@ "name": "Image.GetId", "comment": "GetId returns the internal image ID string.\n\nImplements:\n int rbd_get_id(rbd_image_t image, char *id, size_t id_len);\n" }, + { + "name": "Image.GetName", + "comment": "GetName returns the image name." + }, { "name": "Image.SetSnapshot", "comment": "SetSnapshot updates the rbd image (not the Snapshot) such that the snapshot\nis the source of readable data.\n\nImplements:\n int rbd_snap_set(rbd_image_t image, const char *snapname);\n" diff --git a/rbd/rbd.go b/rbd/rbd.go index 7d5b1ce..e7cd6c7 100644 --- a/rbd/rbd.go +++ b/rbd/rbd.go @@ -951,6 +951,11 @@ func (image *Image) GetId() (string, error) { } +// GetName returns the image name. +func (image *Image) GetName() string { + return image.name +} + // SetSnapshot updates the rbd image (not the Snapshot) such that the snapshot // is the source of readable data. // diff --git a/rbd/rbd_test.go b/rbd/rbd_test.go index 6621637..7ab2e38 100644 --- a/rbd/rbd_test.go +++ b/rbd/rbd_test.go @@ -1641,6 +1641,14 @@ func TestGetId(t *testing.T) { conn.Shutdown() } +func TestGetName(t *testing.T) { + image := Image{ + name: "testImg", + } + imgName := image.GetName() + assert.Equal(t, image.name, imgName) +} + func TestOpenImageById(t *testing.T) { conn := radosConnect(t)