VM with multiple StorageProfiles

296 Views Asked by At

I'm using the .NET version of the vCloud SDK from VMware. I have a VM with two storages, one of type "x" and the other of type "y".

However, when calling vm.Resource.StorageProfile.name I only get the name of the first disk (x)

vCloudClient client = new vCloudClient(url,   com.vmware.vcloud.sdk.constants.Version.V1_5);
client.Login(userName,pass);
Organization organisation = Organization.GetOrganizationByReference(client, client.GetOrgRefsByName()[orgName]);
Vdc vdc = Vdc.GetVdcByReference(client,organisation.GetVdcRefByName(vdcName));
ReferenceType vappref = vdc.GetVappRefByName("myVappName");
Vapp vapp = Vapp.GetVappByReference(client,vappref);
List<VM> vms = vapp.GetChildrenVms();
foreach(VM vm in vms)
{
   //VM I'm having trouble with
   string storageprofile = vm.Resource.StorageProfile.name //returns value: x
}

Is there any other way to get both the "x" and "y" storages?

2

There are 2 best solutions below

3
On BEST ANSWER

Hey try parsing via the vdc storage profile instead

heres the link type for it:

"https://vcloud-example/api/query?type=orgVdcStorageProfile"

If that is not what you need you need to search for the Storage Profile list itself, where it gives href or a link type for EACH storage policy with their name and href type link for that specific storage policy

most probably vm.GetDisks gives you the storage policy "link" (im not sure, but i think it should, I dont use C#, but python and powershell)

1
On

vm.GetDisks should return all disks.