func GetVMImage( t *testing.T, client management.Client, filter func(vmimage.VMImage) bool) vmimage.VMImage { t.Log("Selecting VM image") allimages, err := vmimage.NewClient(client).ListVirtualMachineImages() if err != nil { t.Fatal(err) } filtered := []vmimage.VMImage{} for _, im := range allimages.VMImages { if filter(im) { filtered = append(filtered, im) } } if len(filtered) == 0 { t.Fatal("Filter too restrictive, no images left?") } image := filtered[0] for _, im := range filtered { if im.PublishedDate > image.PublishedDate { image = im } } t.Logf("Selecting image '%s'", image.Name) return image }
func TestVMImageList(t *testing.T) { client := testutils.GetTestClient(t) vmic := vmimage.NewClient(client) il, _ := vmic.ListVirtualMachineImages() for _, im := range il.VMImages { t.Logf("%s -%s", im.Name, im.Description) } }