Search in sources :

Example 51 with DataStoreTO

use of com.cloud.agent.api.to.DataStoreTO in project cloudstack by apache.

the class StorageSubsystemCommandHandlerBase method execute.

protected Answer execute(CopyCommand cmd) {
    DataTO srcData = cmd.getSrcTO();
    DataTO destData = cmd.getDestTO();
    DataStoreTO srcDataStore = srcData.getDataStore();
    DataStoreTO destDataStore = destData.getDataStore();
    if (srcData.getObjectType() == DataObjectType.TEMPLATE && (srcData.getDataStore().getRole() == DataStoreRole.Image || srcData.getDataStore().getRole() == DataStoreRole.ImageCache) && destData.getDataStore().getRole() == DataStoreRole.Primary) {
        //copy template to primary storage
        return processor.copyTemplateToPrimaryStorage(cmd);
    } else if (srcData.getObjectType() == DataObjectType.TEMPLATE && srcDataStore.getRole() == DataStoreRole.Primary && destDataStore.getRole() == DataStoreRole.Primary) {
        //clone template to a volume
        return processor.cloneVolumeFromBaseTemplate(cmd);
    } else if (srcData.getObjectType() == DataObjectType.VOLUME && (srcData.getDataStore().getRole() == DataStoreRole.ImageCache || srcDataStore.getRole() == DataStoreRole.Image)) {
        //copy volume from image cache to primary
        return processor.copyVolumeFromImageCacheToPrimary(cmd);
    } else if (srcData.getObjectType() == DataObjectType.VOLUME && srcData.getDataStore().getRole() == DataStoreRole.Primary) {
        if (destData.getObjectType() == DataObjectType.VOLUME) {
            return processor.copyVolumeFromPrimaryToSecondary(cmd);
        } else if (destData.getObjectType() == DataObjectType.TEMPLATE) {
            return processor.createTemplateFromVolume(cmd);
        }
    } else if (srcData.getObjectType() == DataObjectType.SNAPSHOT && destData.getObjectType() == DataObjectType.SNAPSHOT && srcData.getDataStore().getRole() == DataStoreRole.Primary) {
        return processor.backupSnapshot(cmd);
    } else if (srcData.getObjectType() == DataObjectType.SNAPSHOT && destData.getObjectType() == DataObjectType.VOLUME) {
        return processor.createVolumeFromSnapshot(cmd);
    } else if (srcData.getObjectType() == DataObjectType.SNAPSHOT && destData.getObjectType() == DataObjectType.TEMPLATE) {
        return processor.createTemplateFromSnapshot(cmd);
    }
    return new Answer(cmd, false, "not implemented yet");
}
Also used : CreateObjectAnswer(org.apache.cloudstack.storage.command.CreateObjectAnswer) Answer(com.cloud.agent.api.Answer) DataStoreTO(com.cloud.agent.api.to.DataStoreTO) DataTO(com.cloud.agent.api.to.DataTO)

Example 52 with DataStoreTO

use of com.cloud.agent.api.to.DataStoreTO in project cloudstack by apache.

the class ImageStoreImpl method getTO.

@Override
public DataStoreTO getTO() {
    DataStoreTO to = getDriver().getStoreTO(this);
    if (to == null) {
        ImageStoreTO primaryTO = new ImageStoreTO();
        primaryTO.setProviderName(getProviderName());
        primaryTO.setRole(getRole());
        primaryTO.setType(getProtocol());
        primaryTO.setUri(getUri());
        return primaryTO;
    }
    return to;
}
Also used : DataStoreTO(com.cloud.agent.api.to.DataStoreTO) ImageStoreTO(org.apache.cloudstack.storage.to.ImageStoreTO)

Example 53 with DataStoreTO

use of com.cloud.agent.api.to.DataStoreTO in project cloudstack by apache.

the class StorageSystemDataMotionStrategy method needCacheStorage.

protected boolean needCacheStorage(DataObject srcData, DataObject destData) {
    DataTO srcTO = srcData.getTO();
    DataStoreTO srcStoreTO = srcTO.getDataStore();
    DataTO destTO = destData.getTO();
    DataStoreTO destStoreTO = destTO.getDataStore();
    // hypervisor will copy directly
    if (srcStoreTO instanceof PrimaryDataStoreTO && destStoreTO instanceof PrimaryDataStoreTO) {
        return false;
    }
    if (srcStoreTO instanceof NfsTO || srcStoreTO.getRole() == DataStoreRole.ImageCache) {
        return false;
    }
    if (destStoreTO instanceof NfsTO || destStoreTO.getRole() == DataStoreRole.ImageCache) {
        return false;
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("needCacheStorage true, dest at " + destTO.getPath() + " dest role " + destStoreTO.getRole().toString() + srcTO.getPath() + " src role " + srcStoreTO.getRole().toString());
    }
    return true;
}
Also used : PrimaryDataStoreTO(org.apache.cloudstack.storage.to.PrimaryDataStoreTO) DataStoreTO(com.cloud.agent.api.to.DataStoreTO) DataTO(com.cloud.agent.api.to.DataTO) PrimaryDataStoreTO(org.apache.cloudstack.storage.to.PrimaryDataStoreTO) NfsTO(com.cloud.agent.api.to.NfsTO)

Example 54 with DataStoreTO

use of com.cloud.agent.api.to.DataStoreTO in project cloudstack by apache.

the class GsonHelper method setDefaultGsonConfig.

static Gson setDefaultGsonConfig(GsonBuilder builder) {
    builder.setVersion(1.5);
    InterfaceTypeAdaptor<DataStoreTO> dsAdaptor = new InterfaceTypeAdaptor<DataStoreTO>();
    builder.registerTypeAdapter(DataStoreTO.class, dsAdaptor);
    InterfaceTypeAdaptor<DataTO> dtAdaptor = new InterfaceTypeAdaptor<DataTO>();
    builder.registerTypeAdapter(DataTO.class, dtAdaptor);
    ArrayTypeAdaptor<Command> cmdAdaptor = new ArrayTypeAdaptor<Command>();
    builder.registerTypeAdapter(Command[].class, cmdAdaptor);
    ArrayTypeAdaptor<Answer> ansAdaptor = new ArrayTypeAdaptor<Answer>();
    builder.registerTypeAdapter(Answer[].class, ansAdaptor);
    builder.registerTypeAdapter(new TypeToken<List<PortConfig>>() {
    }.getType(), new PortConfigListTypeAdaptor());
    builder.registerTypeAdapter(new TypeToken<Pair<Long, Long>>() {
    }.getType(), new NwGroupsCommandTypeAdaptor());
    Gson gson = builder.create();
    dsAdaptor.initGson(gson);
    dtAdaptor.initGson(gson);
    cmdAdaptor.initGson(gson);
    ansAdaptor.initGson(gson);
    return gson;
}
Also used : DataStoreTO(com.cloud.agent.api.to.DataStoreTO) InterfaceTypeAdaptor(com.cloud.agent.transport.InterfaceTypeAdaptor) Gson(com.google.gson.Gson) NwGroupsCommandTypeAdaptor(com.cloud.agent.transport.Request.NwGroupsCommandTypeAdaptor) Answer(com.cloud.agent.api.Answer) DataTO(com.cloud.agent.api.to.DataTO) PortConfigListTypeAdaptor(com.cloud.agent.transport.Request.PortConfigListTypeAdaptor) Command(com.cloud.agent.api.Command) TypeToken(com.google.gson.reflect.TypeToken) ArrayTypeAdaptor(com.cloud.agent.transport.ArrayTypeAdaptor) PortConfig(com.cloud.agent.api.SecStorageFirewallCfgCommand.PortConfig)

Example 55 with DataStoreTO

use of com.cloud.agent.api.to.DataStoreTO in project cloudstack by apache.

the class AncientDataMotionStrategy method needCacheStorage.

protected boolean needCacheStorage(DataObject srcData, DataObject destData) {
    DataTO srcTO = srcData.getTO();
    DataStoreTO srcStoreTO = srcTO.getDataStore();
    if (srcStoreTO instanceof NfsTO || srcStoreTO.getRole() == DataStoreRole.ImageCache) {
        return false;
    }
    DataTO destTO = destData.getTO();
    DataStoreTO destStoreTO = destTO.getDataStore();
    if (destStoreTO instanceof NfsTO || destStoreTO.getRole() == DataStoreRole.ImageCache) {
        return false;
    }
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("needCacheStorage true, dest at " + destTO.getPath() + " dest role " + destStoreTO.getRole().toString() + srcTO.getPath() + " src role " + srcStoreTO.getRole().toString());
    }
    return true;
}
Also used : PrimaryDataStoreTO(org.apache.cloudstack.storage.to.PrimaryDataStoreTO) DataStoreTO(com.cloud.agent.api.to.DataStoreTO) DataTO(com.cloud.agent.api.to.DataTO) NfsTO(com.cloud.agent.api.to.NfsTO)

Aggregations

DataStoreTO (com.cloud.agent.api.to.DataStoreTO)91 NfsTO (com.cloud.agent.api.to.NfsTO)66 CopyCmdAnswer (org.apache.cloudstack.storage.command.CopyCmdAnswer)54 PrimaryDataStoreTO (org.apache.cloudstack.storage.to.PrimaryDataStoreTO)50 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)47 DataTO (com.cloud.agent.api.to.DataTO)46 VolumeObjectTO (org.apache.cloudstack.storage.to.VolumeObjectTO)36 InternalErrorException (com.cloud.exception.InternalErrorException)30 TemplateObjectTO (org.apache.cloudstack.storage.to.TemplateObjectTO)28 Answer (com.cloud.agent.api.Answer)26 SnapshotObjectTO (org.apache.cloudstack.storage.to.SnapshotObjectTO)20 UnsupportedEncodingException (java.io.UnsupportedEncodingException)19 IOException (java.io.IOException)17 S3TO (com.cloud.agent.api.to.S3TO)16 ConfigurationException (javax.naming.ConfigurationException)16 XmlRpcException (org.apache.xmlrpc.XmlRpcException)16 XenAPIException (com.xensource.xenapi.Types.XenAPIException)15 RemoteException (java.rmi.RemoteException)15 SwiftTO (com.cloud.agent.api.to.SwiftTO)14 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)14