Search in sources :

Example 1 with AttachPrimaryDataStoreAnswer

use of com.cloud.storage.command.AttachPrimaryDataStoreAnswer in project cosmic by MissionCriticalCloud.

the class XenServerStorageProcessor method execute.

protected Answer execute(final AttachPrimaryDataStoreCmd cmd) {
    final String dataStoreUri = cmd.getDataStore();
    final Connection conn = hypervisorResource.getConnection();
    try {
        final DecodedDataObject obj = Decoder.decode(dataStoreUri);
        final DecodedDataStore store = obj.getStore();
        final SR sr = hypervisorResource.getStorageRepository(conn, store.getUuid());
        hypervisorResource.setupHeartbeatSr(conn, sr, false);
        final long capacity = sr.getPhysicalSize(conn);
        final long available = capacity - sr.getPhysicalUtilisation(conn);
        if (capacity == -1) {
            final String msg = "Pool capacity is -1! pool: ";
            s_logger.warn(msg);
            return new Answer(cmd, false, msg);
        }
        final AttachPrimaryDataStoreAnswer answer = new AttachPrimaryDataStoreAnswer(cmd);
        answer.setCapacity(capacity);
        answer.setUuid(sr.getUuid(conn));
        answer.setAvailable(available);
        return answer;
    } catch (final XenAPIException e) {
        final String msg = "AttachPrimaryDataStoreCmd add XenAPIException:" + e.toString();
        s_logger.warn(msg, e);
        return new Answer(cmd, false, msg);
    } catch (final Exception e) {
        final String msg = "AttachPrimaryDataStoreCmd failed:" + e.getMessage();
        s_logger.warn(msg, e);
        return new Answer(cmd, false, msg);
    }
}
Also used : CreateObjectAnswer(com.cloud.storage.command.CreateObjectAnswer) IntroduceObjectAnswer(com.cloud.storage.command.IntroduceObjectAnswer) Answer(com.cloud.agent.api.Answer) SnapshotAndCopyAnswer(com.cloud.storage.command.SnapshotAndCopyAnswer) AttachPrimaryDataStoreAnswer(com.cloud.storage.command.AttachPrimaryDataStoreAnswer) DettachAnswer(com.cloud.storage.command.DettachAnswer) CopyCmdAnswer(com.cloud.storage.command.CopyCmdAnswer) AttachAnswer(com.cloud.storage.command.AttachAnswer) AttachPrimaryDataStoreAnswer(com.cloud.storage.command.AttachPrimaryDataStoreAnswer) DecodedDataStore(com.cloud.utils.storage.encoding.DecodedDataStore) Connection(com.xensource.xenapi.Connection) XenAPIException(com.xensource.xenapi.Types.XenAPIException) DecodedDataObject(com.cloud.utils.storage.encoding.DecodedDataObject) XenAPIException(com.xensource.xenapi.Types.XenAPIException) InternalErrorException(com.cloud.exception.InternalErrorException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) SR(com.xensource.xenapi.SR)

Aggregations

Answer (com.cloud.agent.api.Answer)1 InternalErrorException (com.cloud.exception.InternalErrorException)1 AttachAnswer (com.cloud.storage.command.AttachAnswer)1 AttachPrimaryDataStoreAnswer (com.cloud.storage.command.AttachPrimaryDataStoreAnswer)1 CopyCmdAnswer (com.cloud.storage.command.CopyCmdAnswer)1 CreateObjectAnswer (com.cloud.storage.command.CreateObjectAnswer)1 DettachAnswer (com.cloud.storage.command.DettachAnswer)1 IntroduceObjectAnswer (com.cloud.storage.command.IntroduceObjectAnswer)1 SnapshotAndCopyAnswer (com.cloud.storage.command.SnapshotAndCopyAnswer)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 DecodedDataObject (com.cloud.utils.storage.encoding.DecodedDataObject)1 DecodedDataStore (com.cloud.utils.storage.encoding.DecodedDataStore)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