Search in sources :

Example 1 with AttachPrimaryDataStoreAnswer

use of com.cloud.legacymodel.communication.answer.AttachPrimaryDataStoreAnswer in project cosmic by MissionCriticalCloud.

the class XenServerStorageProcessor method execute.

protected Answer execute(final AttachPrimaryDataStoreCommand 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 = "AttachPrimaryDataStoreCommand add XenAPIException:" + e.toString();
        s_logger.warn(msg, e);
        return new Answer(cmd, false, msg);
    } catch (final Exception e) {
        final String msg = "AttachPrimaryDataStoreCommand failed:" + e.getMessage();
        s_logger.warn(msg, e);
        return new Answer(cmd, false, msg);
    }
}
Also used : CreateObjectAnswer(com.cloud.legacymodel.communication.answer.CreateObjectAnswer) AttachPrimaryDataStoreAnswer(com.cloud.legacymodel.communication.answer.AttachPrimaryDataStoreAnswer) Answer(com.cloud.legacymodel.communication.answer.Answer) CopyCmdAnswer(com.cloud.legacymodel.communication.answer.CopyCmdAnswer) IntroduceObjectAnswer(com.cloud.legacymodel.communication.answer.IntroduceObjectAnswer) DettachAnswer(com.cloud.legacymodel.communication.answer.DettachAnswer) SnapshotAndCopyAnswer(com.cloud.legacymodel.communication.answer.SnapshotAndCopyAnswer) AttachAnswer(com.cloud.legacymodel.communication.answer.AttachAnswer) AttachPrimaryDataStoreAnswer(com.cloud.legacymodel.communication.answer.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.legacymodel.exceptions.InternalErrorException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException) SR(com.xensource.xenapi.SR)

Aggregations

Answer (com.cloud.legacymodel.communication.answer.Answer)1 AttachAnswer (com.cloud.legacymodel.communication.answer.AttachAnswer)1 AttachPrimaryDataStoreAnswer (com.cloud.legacymodel.communication.answer.AttachPrimaryDataStoreAnswer)1 CopyCmdAnswer (com.cloud.legacymodel.communication.answer.CopyCmdAnswer)1 CreateObjectAnswer (com.cloud.legacymodel.communication.answer.CreateObjectAnswer)1 DettachAnswer (com.cloud.legacymodel.communication.answer.DettachAnswer)1 IntroduceObjectAnswer (com.cloud.legacymodel.communication.answer.IntroduceObjectAnswer)1 SnapshotAndCopyAnswer (com.cloud.legacymodel.communication.answer.SnapshotAndCopyAnswer)1 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)1 InternalErrorException (com.cloud.legacymodel.exceptions.InternalErrorException)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