Search in sources :

Example 21 with SnapshotObjectTO

use of org.apache.cloudstack.storage.to.SnapshotObjectTO in project cloudstack by apache.

the class Ovm3StorageProcessorTest method deleteCommandTest.

/**
     * Delete an object
     *
     * @throws ConfigurationException
     */
@Test
public void deleteCommandTest() throws ConfigurationException {
    con = prepare();
    VolumeObjectTO vol = volume(ovmObject.newUuid(), ovmObject.newUuid(), linux.getRepoId(), linux.getVirtualDisksDir());
    DeleteCommand delete = new DeleteCommand(vol);
    Answer ra = hypervisor.executeRequest(delete);
    results.basicBooleanTest(ra.getResult());
    TemplateObjectTO template = template(ovmObject.newUuid(), ovmObject.newUuid(), ovmObject.newUuid(linux.getRemote()), linux.getRemote());
    delete = new DeleteCommand(template);
    ra = hypervisor.executeRequest(delete);
    results.basicBooleanTest(ra.getResult(), false);
    SnapshotObjectTO snap = snapshot(ovmObject.newUuid(), ovmObject.newUuid(), ovmObject.newUuid(linux.getRemote()), linux.getRemote());
    delete = new DeleteCommand(snap);
    ra = hypervisor.executeRequest(delete);
    results.basicBooleanTest(ra.getResult(), false);
}
Also used : DeleteCommand(org.apache.cloudstack.storage.command.DeleteCommand) SnapshotObjectTO(org.apache.cloudstack.storage.to.SnapshotObjectTO) Answer(com.cloud.agent.api.Answer) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer) VolumeObjectTO(org.apache.cloudstack.storage.to.VolumeObjectTO) TemplateObjectTO(org.apache.cloudstack.storage.to.TemplateObjectTO) ConnectionTest(com.cloud.hypervisor.ovm3.objects.ConnectionTest) LinuxTest(com.cloud.hypervisor.ovm3.objects.LinuxTest) Test(org.junit.Test) XenTest(com.cloud.hypervisor.ovm3.objects.XenTest) StoragePluginTest(com.cloud.hypervisor.ovm3.objects.StoragePluginTest) Ovm3SupportTest(com.cloud.hypervisor.ovm3.support.Ovm3SupportTest) XmlTestResultTest(com.cloud.hypervisor.ovm3.objects.XmlTestResultTest) Ovm3ConfigurationTest(com.cloud.hypervisor.ovm3.resources.helpers.Ovm3ConfigurationTest)

Example 22 with SnapshotObjectTO

use of org.apache.cloudstack.storage.to.SnapshotObjectTO in project cloudstack by apache.

the class Ovm3StorageProcessorTest method snapshot.

private SnapshotObjectTO snapshot(final String uuid, final String dsuuid, final String storeUrl, final String path) {
    SnapshotObjectTO volume = new SnapshotObjectTO();
    NfsTO nfsDataStore = new NfsTO();
    nfsDataStore.setUuid(dsuuid);
    nfsDataStore.setUrl(storeUrl);
    volume.setDataStore(nfsDataStore);
    volume.setPath(path);
    // volume.setUuid(uuid);
    return volume;
}
Also used : SnapshotObjectTO(org.apache.cloudstack.storage.to.SnapshotObjectTO) NfsTO(com.cloud.agent.api.to.NfsTO)

Example 23 with SnapshotObjectTO

use of org.apache.cloudstack.storage.to.SnapshotObjectTO in project cloudstack by apache.

the class SimulatorStorageProcessor method createSnapshot.

@Override
public Answer createSnapshot(CreateObjectCommand cmd) {
    String snapshotName = UUID.randomUUID().toString();
    SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
    newSnapshot.setPath(snapshotName);
    return new CreateObjectAnswer(newSnapshot);
}
Also used : SnapshotObjectTO(org.apache.cloudstack.storage.to.SnapshotObjectTO) CreateObjectAnswer(org.apache.cloudstack.storage.command.CreateObjectAnswer)

Example 24 with SnapshotObjectTO

use of org.apache.cloudstack.storage.to.SnapshotObjectTO in project cloudstack by apache.

the class SimulatorStorageProcessor method backupSnapshot.

@Override
public Answer backupSnapshot(CopyCommand cmd) {
    DataTO srcData = cmd.getSrcTO();
    DataTO destData = cmd.getDestTO();
    SnapshotObjectTO snapshot = (SnapshotObjectTO) srcData;
    DataStoreTO imageStore = destData.getDataStore();
    if (!(imageStore instanceof NfsTO)) {
        return new CopyCmdAnswer("unsupported protocol");
    }
    int index = snapshot.getPath().lastIndexOf("/");
    String snapshotName = snapshot.getPath().substring(index + 1);
    String snapshotRelPath = "snapshots";
    SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
    newSnapshot.setPath(snapshotRelPath + File.separator + snapshotName);
    return new CopyCmdAnswer(newSnapshot);
}
Also used : SnapshotObjectTO(org.apache.cloudstack.storage.to.SnapshotObjectTO) DataStoreTO(com.cloud.agent.api.to.DataStoreTO) DataTO(com.cloud.agent.api.to.DataTO) NfsTO(com.cloud.agent.api.to.NfsTO) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer)

Example 25 with SnapshotObjectTO

use of org.apache.cloudstack.storage.to.SnapshotObjectTO in project cloudstack by apache.

the class NfsSecondaryStorageResource method copyFromNfsToS3.

protected Answer copyFromNfsToS3(CopyCommand cmd) {
    final DataTO srcData = cmd.getSrcTO();
    final DataTO destData = cmd.getDestTO();
    DataStoreTO srcDataStore = srcData.getDataStore();
    NfsTO srcStore = (NfsTO) srcDataStore;
    DataStoreTO destDataStore = destData.getDataStore();
    final S3TO s3 = (S3TO) destDataStore;
    try {
        final String templatePath = determineStorageTemplatePath(srcStore.getUrl(), srcData.getPath(), _nfsVersion);
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Found " + srcData.getObjectType() + " from directory " + templatePath + " to upload to S3.");
        }
        final String bucket = s3.getBucketName();
        File srcFile = findFile(templatePath);
        if (srcFile == null) {
            return new CopyCmdAnswer("Can't find src file:" + templatePath);
        }
        ImageFormat format = getTemplateFormat(srcFile.getName());
        String key = destData.getPath() + S3Utils.SEPARATOR + srcFile.getName();
        putFile(s3, srcFile, bucket, key).waitForCompletion();
        DataTO retObj = null;
        if (destData.getObjectType() == DataObjectType.TEMPLATE) {
            TemplateObjectTO newTemplate = new TemplateObjectTO();
            newTemplate.setPath(key);
            newTemplate.setSize(getVirtualSize(srcFile, format));
            newTemplate.setPhysicalSize(srcFile.length());
            newTemplate.setFormat(format);
            retObj = newTemplate;
        } else if (destData.getObjectType() == DataObjectType.VOLUME) {
            VolumeObjectTO newVol = new VolumeObjectTO();
            newVol.setPath(key);
            newVol.setSize(srcFile.length());
            retObj = newVol;
        } else if (destData.getObjectType() == DataObjectType.SNAPSHOT) {
            SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
            newSnapshot.setPath(key);
            retObj = newSnapshot;
        }
        return new CopyCmdAnswer(retObj);
    } catch (Exception e) {
        s_logger.error("failed to upload" + srcData.getPath(), e);
        return new CopyCmdAnswer("failed to upload" + srcData.getPath() + e.toString());
    }
}
Also used : SnapshotObjectTO(org.apache.cloudstack.storage.to.SnapshotObjectTO) DataStoreTO(com.cloud.agent.api.to.DataStoreTO) DataTO(com.cloud.agent.api.to.DataTO) VolumeObjectTO(org.apache.cloudstack.storage.to.VolumeObjectTO) TemplateObjectTO(org.apache.cloudstack.storage.to.TemplateObjectTO) NfsTO(com.cloud.agent.api.to.NfsTO) S3TO(com.cloud.agent.api.to.S3TO) File(java.io.File) S3Utils.putFile(com.cloud.utils.storage.S3.S3Utils.putFile) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) InternalErrorException(com.cloud.exception.InternalErrorException) ConfigurationException(javax.naming.ConfigurationException) ImageFormat(com.cloud.storage.Storage.ImageFormat)

Aggregations

SnapshotObjectTO (org.apache.cloudstack.storage.to.SnapshotObjectTO)44 CopyCmdAnswer (org.apache.cloudstack.storage.command.CopyCmdAnswer)33 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)23 DataTO (com.cloud.agent.api.to.DataTO)22 NfsTO (com.cloud.agent.api.to.NfsTO)21 DataStoreTO (com.cloud.agent.api.to.DataStoreTO)20 PrimaryDataStoreTO (org.apache.cloudstack.storage.to.PrimaryDataStoreTO)19 VolumeObjectTO (org.apache.cloudstack.storage.to.VolumeObjectTO)16 InternalErrorException (com.cloud.exception.InternalErrorException)14 CreateObjectAnswer (org.apache.cloudstack.storage.command.CreateObjectAnswer)14 Answer (com.cloud.agent.api.Answer)12 TemplateObjectTO (org.apache.cloudstack.storage.to.TemplateObjectTO)11 Connection (com.xensource.xenapi.Connection)9 XenAPIException (com.xensource.xenapi.Types.XenAPIException)9 VDI (com.xensource.xenapi.VDI)9 XmlRpcException (org.apache.xmlrpc.XmlRpcException)9 SR (com.xensource.xenapi.SR)8 URI (java.net.URI)7 ConfigurationException (javax.naming.ConfigurationException)7 S3TO (com.cloud.agent.api.to.S3TO)6