use of com.cloud.legacymodel.vm.VmStatsEntry in project cosmic by MissionCriticalCloud.
the class CitrixGetVmStatsCommandWrapper method execute.
@Override
public Answer execute(final GetVmStatsCommand command, final CitrixResourceBase citrixResourceBase) {
final Connection conn = citrixResourceBase.getConnection();
final List<String> vmNames = command.getVmNames();
final HashMap<String, VmStatsEntry> vmStatsNameMap = new HashMap<>();
if (vmNames.size() == 0) {
return new GetVmStatsAnswer(command, vmStatsNameMap);
}
try {
// Determine the UUIDs of the requested VMs
final List<String> vmUUIDs = new ArrayList<>();
for (final String vmName : vmNames) {
final VM vm = citrixResourceBase.getVM(conn, vmName);
vmUUIDs.add(vm.getUuid(conn));
}
final HashMap<String, VmStatsEntry> vmStatsUUIDMap = citrixResourceBase.getVmStats(conn, command, vmUUIDs, command.getHostGuid());
if (vmStatsUUIDMap == null) {
return new GetVmStatsAnswer(command, vmStatsNameMap);
}
for (final Map.Entry<String, VmStatsEntry> entry : vmStatsUUIDMap.entrySet()) {
vmStatsNameMap.put(vmNames.get(vmUUIDs.indexOf(entry.getKey())), entry.getValue());
}
return new GetVmStatsAnswer(command, vmStatsNameMap);
} catch (final XenAPIException e) {
final String msg = "Unable to get VM stats" + e.toString();
s_logger.warn(msg, e);
return new GetVmStatsAnswer(command, vmStatsNameMap);
} catch (final XmlRpcException e) {
final String msg = "Unable to get VM stats" + e.getMessage();
s_logger.warn(msg, e);
return new GetVmStatsAnswer(command, vmStatsNameMap);
}
}
Aggregations