in cloud-vmware-server/src/main/java/jetbrains/buildServer/clouds/vmware/connector/VMWareApiConnectorImpl.java [390:429]
protected Collection<ResourcePoolBean> findAllResourcePools() throws VmwareCheckedCloudException {
final AtomicReference<VmwareCheckedCloudException> exceptionRef = new AtomicReference<>();
final Collection<ResourcePoolBean> result = findWithDatacenter(dc -> {
try {
final String datacenterId = dc.getMOR().getVal();
final ObjectContent[] ocs = getObjectContents(dc, new String[][]{{"ResourcePool", "name", "parent"},});
if (ocs == null){
return Stream.empty();
}
return Arrays.stream(ocs).map(oc -> {
final Map<String, Object> mappedProperties = Arrays.stream(oc.getPropSet()).collect(Collectors.toMap(
DynamicProperty::getName, DynamicProperty::getVal
));
final String simpleName = String.valueOf(mappedProperties.get("name"));
final ManagedObjectReference parent = (ManagedObjectReference)mappedProperties.get("parent");
LOG.debug("Found respool with name '" + simpleName + "'. Parent: " + (parent == null ? "null" : parent.toString()));
final ResourcePool pool = (ResourcePool)createExactManagedEntity(oc.getObj());
final String path = getFullPath(simpleName, oc.obj, parent, dc);
LOG.debug("Calculated path: " + path);
return new ResourcePoolBean(oc.obj,
simpleName,
path,
parent,
datacenterId
);
});
} catch (RemoteException e) {
LOG.warnAndDebugDetails("An error occurred while searching for all resource pools", e);
exceptionRef.set(new VmwareCheckedCloudException(e));
return Stream.empty();
}
});
if (exceptionRef.get() != null){
throw exceptionRef.get();
}
return result;
}