HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails = new HashMap<String, HashMap<String, VgpuTypesInfo>>();
Host host = Host.getByUuid(conn, _host.uuid);
Set<PGPU> pgpus = host.getPGPUs(conn);
Iterator<PGPU> iter = pgpus.iterator();
while (iter.hasNext()) {
PGPU pgpu = iter.next();
GPUGroup gpuGroup = pgpu.getGPUGroup(conn);
Set<VGPUType> enabledVGPUTypes = gpuGroup.getEnabledVGPUTypes(conn);
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) {
Iterator<VGPUType> it = enabledVGPUTypes.iterator();
while (it.hasNext()) {
VGPUType type = it.next();
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);