Search in sources :

Example 1 with DecodedDataObject

use of com.cloud.utils.storage.encoding.DecodedDataObject in project cloudstack by apache.

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(org.apache.cloudstack.storage.command.CreateObjectAnswer) Answer(com.cloud.agent.api.Answer) ResignatureAnswer(org.apache.cloudstack.storage.command.ResignatureAnswer) IntroduceObjectAnswer(org.apache.cloudstack.storage.command.IntroduceObjectAnswer) AttachPrimaryDataStoreAnswer(org.apache.cloudstack.storage.command.AttachPrimaryDataStoreAnswer) DettachAnswer(org.apache.cloudstack.storage.command.DettachAnswer) SnapshotAndCopyAnswer(org.apache.cloudstack.storage.command.SnapshotAndCopyAnswer) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer) AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) AttachPrimaryDataStoreAnswer(org.apache.cloudstack.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 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 AttachAnswer (org.apache.cloudstack.storage.command.AttachAnswer)1 AttachPrimaryDataStoreAnswer (org.apache.cloudstack.storage.command.AttachPrimaryDataStoreAnswer)1 CopyCmdAnswer (org.apache.cloudstack.storage.command.CopyCmdAnswer)1 CreateObjectAnswer (org.apache.cloudstack.storage.command.CreateObjectAnswer)1 DettachAnswer (org.apache.cloudstack.storage.command.DettachAnswer)1 IntroduceObjectAnswer (org.apache.cloudstack.storage.command.IntroduceObjectAnswer)1 ResignatureAnswer (org.apache.cloudstack.storage.command.ResignatureAnswer)1 SnapshotAndCopyAnswer (org.apache.cloudstack.storage.command.SnapshotAndCopyAnswer)1 XmlRpcException (org.apache.xmlrpc.XmlRpcException)1