Using vSphere SDK for .NET. Sorry, couldn't find a .NET forum for the vSphere SDK but the Java forum should be close enough.
I am having problems retrieving a list of VMs from a Resource Pool. Specifically if there are more than 100 VMs (104 in my case) in the Folder or Resource Pool the returned UpdateSet will only ever have 100 items in it.
The offending code is as follows:
UpdateSet uSet = pc.WaitForUpdatesEx(string.Empty, new WaitOptions() { MaxWaitSeconds = 0 });
Console.Writeline(uSet.FilterSet[0].ObjectSet.Count); // will always contain no more than 100 items
There seems to be a hard cut off of 100 items.
WaitForUpdatesEx's WaitOptions contains a MaxObjectUpdates property, from the documentation
"The maximum number of ObjectUpdate entries that should be returned in a single result from WaitForUpdatesEx. See truncated
An unset value indicates that there is no maximum. In this case PropertyCollector policy may still limit the number of objects that appear in an UpdateSet."
But what is the "PropertyCollector Policy" that it is referring to? I've been trawling the web and can find absolutely no reference to this at all other than in the documentation.
I also tried just putting in a a MaxObjectUpdates = 150 just to see what would happen. Again only 100 items returned.
For reference here is a more complete section of code:
EntityViewBase folderMngObj = GetVsphereVmFolderManagedObjectRefId(vClient, vSpherefolderName);
if (folderMngObj != null)
{
ManagedObjectReference svcRef = new ManagedObjectReference() { Type = "ServiceInstance", Value = "ServiceInstance" };
ServiceInstance srvInst = new ServiceInstance(vClient, svcRef);
ServiceContent sContent = srvInst.RetrieveServiceContent();
ViewManager viewManager = new ViewManager(vClient, sContent.ViewManager);
PropertyCollector pc = new PropertyCollector(vClient, sContent.PropertyCollector);
ManagedObjectReference cvMngObjRef = viewManager.CreateContainerView(folderMngObj.MoRef, new string[] { "VirtualMachine" }, false);
ContainerView cv = new ContainerView(vClient, cvMngObjRef);
List<PropertySpec> propertySpecList = new List<PropertySpec>();
foreach (string propertyPath in vmPropertyPaths)
{
PropertySpec propSpec = new PropertySpec();
propSpec.PathSet = new string[] { propertyPath };
propSpec.Type = "VirtualMachine";
propertySpecList.Add(propSpec);
}
PropertySpec[] propertySpecs = propertySpecList.ToArray();
PropertyFilterSpec pfs = new PropertyFilterSpec();
pfs.ObjectSet = new ObjectSpec[] { CreateObjSpec(cv) };
pfs.PropSet = propertySpecs;
// Create a Property with partialUpdate is true
PropertyFilter pf = new PropertyFilter(vClient, pc.CreateFilter(pfs, true));
// Wait for initial udpate with empty version string
UpdateSet uSet = pc.WaitForUpdatesEx(string.Empty, new WaitOptions() { MaxWaitSeconds = 0 });
// Here uSet.FilterSet[0].ObjectSet will always contain no more than 100 items
viewTable = OutputDataset(uSet);
pf.DestroyPropertyFilter();
}
Any help would be appreciated.