use of com.cloud.legacymodel.communication.answer.GetStorageStatsAnswer in project cosmic by MissionCriticalCloud.
the class NfsSecondaryStorageResource method execute.
protected GetStorageStatsAnswer execute(final GetStorageStatsCommand cmd) {
final DataStoreTO store = cmd.getStore();
final String rootDir = getRootDir(((NfsTO) store).getUrl());
final long usedSize = getUsedSize(rootDir);
final long totalSize = getTotalSize(rootDir);
if ((usedSize == 0 && totalSize == 0) || usedSize < 0 || totalSize < 0) {
return new GetStorageStatsAnswer(cmd, "Unable to get storage stats");
} else {
return new GetStorageStatsAnswer(cmd, totalSize, usedSize);
}
}
use of com.cloud.legacymodel.communication.answer.GetStorageStatsAnswer in project cosmic by MissionCriticalCloud.
the class LibvirtGetStorageStatsCommandWrapper method execute.
@Override
public Answer execute(final GetStorageStatsCommand command, final LibvirtComputingResource libvirtComputingResource) {
try {
final KvmStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr();
final KvmStoragePool sp = storagePoolMgr.getStoragePool(command.getPooltype(), command.getStorageId(), true);
return new GetStorageStatsAnswer(command, sp.getCapacity(), sp.getUsed());
} catch (final CloudRuntimeException e) {
return new GetStorageStatsAnswer(command, e.toString());
}
}
use of com.cloud.legacymodel.communication.answer.GetStorageStatsAnswer in project cosmic by MissionCriticalCloud.
the class CitrixGetStorageStatsCommandWrapper method execute.
@Override
public Answer execute(final GetStorageStatsCommand command, final CitrixResourceBase citrixResourceBase) {
final Connection conn = citrixResourceBase.getConnection();
try {
final Set<SR> srs = SR.getByNameLabel(conn, command.getStorageId());
if (srs.size() != 1) {
final String msg = "There are " + srs.size() + " storageid: " + command.getStorageId();
s_logger.warn(msg);
return new GetStorageStatsAnswer(command, msg);
}
final SR sr = srs.iterator().next();
sr.scan(conn);
final long capacity = sr.getPhysicalSize(conn);
final long used = sr.getPhysicalUtilisation(conn);
return new GetStorageStatsAnswer(command, capacity, used);
} catch (final XenAPIException e) {
final String msg = "GetStorageStats Exception:" + e.toString() + "host:" + citrixResourceBase.getHost().getUuid() + "storageid: " + command.getStorageId();
s_logger.warn(msg);
return new GetStorageStatsAnswer(command, msg);
} catch (final XmlRpcException e) {
final String msg = "GetStorageStats Exception:" + e.getMessage() + "host:" + citrixResourceBase.getHost().getUuid() + "storageid: " + command.getStorageId();
s_logger.warn(msg);
return new GetStorageStatsAnswer(command, msg);
} catch (final Exception e) {
final String msg = "GetStorageStats Exception:" + e.getMessage() + "host:" + citrixResourceBase.getHost().getUuid() + "storageid: " + command.getStorageId();
s_logger.warn(msg);
return new GetStorageStatsAnswer(command, msg);
}
}
Aggregations