Search in sources :

Example 1 with GetStorageStatsAnswer

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);
    }
}
Also used : DataStoreTO(com.cloud.legacymodel.to.DataStoreTO) GetStorageStatsAnswer(com.cloud.legacymodel.communication.answer.GetStorageStatsAnswer)

Example 2 with GetStorageStatsAnswer

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());
    }
}
Also used : GetStorageStatsAnswer(com.cloud.legacymodel.communication.answer.GetStorageStatsAnswer) KvmStoragePool(com.cloud.agent.resource.kvm.storage.KvmStoragePool) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException) KvmStoragePoolManager(com.cloud.agent.resource.kvm.storage.KvmStoragePoolManager)

Example 3 with GetStorageStatsAnswer

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);
    }
}
Also used : GetStorageStatsAnswer(com.cloud.legacymodel.communication.answer.GetStorageStatsAnswer) Connection(com.xensource.xenapi.Connection) XenAPIException(com.xensource.xenapi.Types.XenAPIException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) XenAPIException(com.xensource.xenapi.Types.XenAPIException) SR(com.xensource.xenapi.SR)

Aggregations

GetStorageStatsAnswer (com.cloud.legacymodel.communication.answer.GetStorageStatsAnswer)3 KvmStoragePool (com.cloud.agent.resource.kvm.storage.KvmStoragePool)1 KvmStoragePoolManager (com.cloud.agent.resource.kvm.storage.KvmStoragePoolManager)1 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)1 DataStoreTO (com.cloud.legacymodel.to.DataStoreTO)1 Connection (com.xensource.xenapi.Connection)1 SR (com.xensource.xenapi.SR)1 XenAPIException (com.xensource.xenapi.Types.XenAPIException)1 XmlRpcException (org.apache.xmlrpc.XmlRpcException)1