func listImages(ioctx *rados.IOContext, prefix string) { imageNames, err := rbd.GetImageNames(ioctx) if err != nil { fmt.Println("error when getImagesNames", err) os.Exit(1) } fmt.Println(prefix, ":", imageNames) }
func TestGetImageNames(t *testing.T) { conn, _ := rados.NewConn() conn.ReadDefaultConfigFile() conn.Connect() poolname := GetUUID() err := conn.MakePool(poolname) assert.NoError(t, err) ioctx, err := conn.OpenIOContext(poolname) assert.NoError(t, err) createdList := []string{} for i := 0; i < 10; i++ { name := GetUUID() _, err := rbd.Create(ioctx, name, 1<<22, 22) assert.NoError(t, err) createdList = append(createdList, name) } imageNames, err := rbd.GetImageNames(ioctx) assert.NoError(t, err) sort.Strings(createdList) sort.Strings(imageNames) assert.Equal(t, createdList, imageNames) for _, name := range createdList { img := rbd.GetImage(ioctx, name) err := img.Remove() assert.NoError(t, err) } ioctx.Destroy() conn.DeletePool(poolname) conn.Shutdown() }