use of com.xensource.xenapi.PGPU in project cloudstack by apache.
the class XenServer620SP1Resource method getGPUGroupDetails.
@Override
public HashMap<String, HashMap<String, VgpuTypesInfo>> getGPUGroupDetails(final Connection conn) throws XenAPIException, XmlRpcException {
final HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails = new HashMap<String, HashMap<String, VgpuTypesInfo>>();
final Host host = Host.getByUuid(conn, _host.getUuid());
final Set<PGPU> pgpus = host.getPGPUs(conn);
final Iterator<PGPU> iter = pgpus.iterator();
while (iter.hasNext()) {
final PGPU pgpu = iter.next();
final GPUGroup gpuGroup = pgpu.getGPUGroup(conn);
final Set<VGPUType> enabledVGPUTypes = gpuGroup.getEnabledVGPUTypes(conn);
final String groupName = gpuGroup.getNameLabel(conn);
HashMap<String, VgpuTypesInfo> gpuCapacity = new HashMap<String, VgpuTypesInfo>();
if (groupDetails.get(groupName) != null) {
gpuCapacity = groupDetails.get(groupName);
}
// Get remaining capacity of all the enabled VGPU in a PGPU
if (enabledVGPUTypes != null) {
final Iterator<VGPUType> it = enabledVGPUTypes.iterator();
while (it.hasNext()) {
final VGPUType type = it.next();
final Record record = type.getRecord(conn);
Long remainingCapacity = pgpu.getRemainingCapacity(conn, type);
Long maxCapacity = pgpu.getSupportedVGPUMaxCapacities(conn).get(type);
VgpuTypesInfo entry;
if ((entry = gpuCapacity.get(record.modelName)) != null) {
remainingCapacity += entry.getRemainingCapacity();
maxCapacity += entry.getMaxCapacity();
entry.setRemainingCapacity(remainingCapacity);
entry.setMaxVmCapacity(maxCapacity);
gpuCapacity.put(record.modelName, entry);
} else {
final VgpuTypesInfo vgpuTypeRecord = new VgpuTypesInfo(null, record.modelName, record.framebufferSize, record.maxHeads, record.maxResolutionX, record.maxResolutionY, maxCapacity, remainingCapacity, maxCapacity);
gpuCapacity.put(record.modelName, vgpuTypeRecord);
}
}
}
groupDetails.put(groupName, gpuCapacity);
}
return groupDetails;
}