Search in sources :

Example 1 with PGPU

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;
}
Also used : HashMap(java.util.HashMap) VGPUType(com.xensource.xenapi.VGPUType) Host(com.xensource.xenapi.Host) PGPU(com.xensource.xenapi.PGPU) Record(com.xensource.xenapi.VGPUType.Record) VgpuTypesInfo(com.cloud.agent.api.VgpuTypesInfo) GPUGroup(com.xensource.xenapi.GPUGroup)

Aggregations

VgpuTypesInfo (com.cloud.agent.api.VgpuTypesInfo)1 GPUGroup (com.xensource.xenapi.GPUGroup)1 Host (com.xensource.xenapi.Host)1 PGPU (com.xensource.xenapi.PGPU)1 VGPUType (com.xensource.xenapi.VGPUType)1 Record (com.xensource.xenapi.VGPUType.Record)1 HashMap (java.util.HashMap)1