Search in sources :

Example 21 with CopyCommand

use of org.apache.cloudstack.storage.command.CopyCommand in project cloudstack by apache.

the class Ovm3StorageProcessorTest method copyCommandTemplateToTemplateTest.

/**
 * Copy template from secondary to primary template
 *
 * @throws ConfigurationException
 */
@Test
public void copyCommandTemplateToTemplateTest() throws ConfigurationException {
    con = prepare();
    con.setMethodResponse("storage_plugin_mount", results.simpleResponseWrapWrapper(storageplugin.getNfsFileSystemInfo()));
    /*
         * because the template requires a reference to the name for the uuid...
         * -sigh-
         */
    String templateid = ovmObject.newUuid();
    String targetid = ovmObject.newUuid();
    String templatedir = "template/tmpl/1/11" + templateid + ".raw";
    String storeUrl = "nfs://" + linux.getRemoteHost() + "/" + linux.getRemoteDir();
    TemplateObjectTO src = template(templateid, linux.getRepoId(), storeUrl, templatedir);
    TemplateObjectTO dest = template(targetid, linux.getRepoId(), linux.getRepoId(), linux.getTemplatesDir());
    CopyCommand copy = new CopyCommand(src, dest, 0, true);
    CopyCmdAnswer ra = (CopyCmdAnswer) hypervisor.executeRequest(copy);
    TemplateObjectTO vol = (TemplateObjectTO) ra.getNewData();
    results.basicStringTest(vol.getUuid(), targetid);
    results.basicStringTest(vol.getPath(), targetid);
    results.basicBooleanTest(ra.getResult());
}
Also used : CopyCommand(org.apache.cloudstack.storage.command.CopyCommand) TemplateObjectTO(org.apache.cloudstack.storage.to.TemplateObjectTO) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer) 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 CopyCommand

use of org.apache.cloudstack.storage.command.CopyCommand in project cloudstack by apache.

the class Ovm3StorageProcessorTest method copyCommandBogusTest.

/**
 * Copy template from secondary to primary template
 *
 * @throws ConfigurationException
 */
@Test
public void copyCommandBogusTest() throws ConfigurationException {
    con = prepare();
    VolumeObjectTO src = volume(ovmObject.newUuid(), ovmObject.newUuid(), ovmObject.newUuid(linux.getRemote()), linux.getRemote());
    VolumeObjectTO dest = volume(ovmObject.newUuid(), ovmObject.newUuid(), linux.getRepoId(), linux.getVirtualDisksDir());
    CopyCommand copy = new CopyCommand(src, dest, 0, false);
    Answer ra = hypervisor.executeRequest(copy);
    results.basicBooleanTest(ra.getResult(), false);
}
Also used : Answer(com.cloud.agent.api.Answer) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer) CopyCommand(org.apache.cloudstack.storage.command.CopyCommand) VolumeObjectTO(org.apache.cloudstack.storage.to.VolumeObjectTO) 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 23 with CopyCommand

use of org.apache.cloudstack.storage.command.CopyCommand in project cloudstack by apache.

the class AncientDataMotionStrategy method cloneVolume.

protected Answer cloneVolume(DataObject template, DataObject volume) {
    CopyCommand cmd = new CopyCommand(template.getTO(), addFullCloneAndDiskprovisiongStrictnessFlagOnVMwareDest(volume.getTO()), 0, VirtualMachineManager.ExecuteInSequence.value());
    try {
        EndPoint ep = selector.select(volume.getDataStore());
        Answer answer = null;
        if (ep == null) {
            String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
            s_logger.error(errMsg);
            answer = new Answer(cmd, false, errMsg);
        } else {
            answer = ep.sendMessage(cmd);
        }
        return answer;
    } catch (Exception e) {
        s_logger.debug("Failed to send to storage pool", e);
        throw new CloudRuntimeException("Failed to send to storage pool", e);
    }
}
Also used : Answer(com.cloud.agent.api.Answer) MigrateVolumeAnswer(com.cloud.agent.api.storage.MigrateVolumeAnswer) CopyCommand(org.apache.cloudstack.storage.command.CopyCommand) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(org.apache.cloudstack.storage.RemoteHostEndPoint) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 24 with CopyCommand

use of org.apache.cloudstack.storage.command.CopyCommand in project cloudstack by apache.

the class AncientDataMotionStrategy method createTemplateFromSnapshot.

@DB
protected Answer createTemplateFromSnapshot(DataObject srcData, DataObject destData) {
    String value = configDao.getValue(Config.CreatePrivateTemplateFromSnapshotWait.toString());
    int _createprivatetemplatefromsnapshotwait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CreatePrivateTemplateFromSnapshotWait.getDefaultValue()));
    boolean needCache = false;
    if (needCacheStorage(srcData, destData)) {
        needCache = true;
        SnapshotInfo snapshot = (SnapshotInfo) srcData;
        srcData = cacheSnapshotChain(snapshot, snapshot.getDataStore().getScope());
    }
    EndPoint ep = null;
    if (srcData.getDataStore().getRole() == DataStoreRole.Primary) {
        ep = selector.select(destData);
    } else {
        ep = selector.select(srcData, destData);
    }
    CopyCommand cmd = new CopyCommand(srcData.getTO(), addFullCloneAndDiskprovisiongStrictnessFlagOnVMwareDest(destData.getTO()), _createprivatetemplatefromsnapshotwait, VirtualMachineManager.ExecuteInSequence.value());
    Answer answer = null;
    if (ep == null) {
        String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
        s_logger.error(errMsg);
        answer = new Answer(cmd, false, errMsg);
    } else {
        answer = ep.sendMessage(cmd);
    }
    // clean up snapshot copied to staging
    if (needCache && srcData != null) {
        // reduce ref count, but keep it there on cache which is converted from previous secondary storage
        cacheMgr.releaseCacheObject(srcData);
    }
    return answer;
}
Also used : Answer(com.cloud.agent.api.Answer) MigrateVolumeAnswer(com.cloud.agent.api.storage.MigrateVolumeAnswer) SnapshotInfo(org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo) CopyCommand(org.apache.cloudstack.storage.command.CopyCommand) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(org.apache.cloudstack.storage.RemoteHostEndPoint) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(org.apache.cloudstack.storage.RemoteHostEndPoint) DB(com.cloud.utils.db.DB)

Example 25 with CopyCommand

use of org.apache.cloudstack.storage.command.CopyCommand in project cloudstack by apache.

the class AncientDataMotionStrategy method copySnapshot.

protected Answer copySnapshot(DataObject srcData, DataObject destData) {
    String value = configDao.getValue(Config.BackupSnapshotWait.toString());
    int _backupsnapshotwait = NumbersUtil.parseInt(value, Integer.parseInt(Config.BackupSnapshotWait.getDefaultValue()));
    DataObject cacheData = null;
    SnapshotInfo snapshotInfo = (SnapshotInfo) srcData;
    Boolean snapshotFullBackup = snapshotInfo.getFullBackup();
    Boolean fullSnapshot = true;
    if (snapshotFullBackup != null) {
        fullSnapshot = snapshotFullBackup;
    }
    Map<String, String> options = new HashMap<String, String>();
    options.put("fullSnapshot", fullSnapshot.toString());
    Answer answer = null;
    try {
        if (needCacheStorage(srcData, destData)) {
            Scope selectedScope = pickCacheScopeForCopy(srcData, destData);
            cacheData = cacheMgr.getCacheObject(srcData, selectedScope);
            CopyCommand cmd = new CopyCommand(srcData.getTO(), addFullCloneAndDiskprovisiongStrictnessFlagOnVMwareDest(destData.getTO()), _backupsnapshotwait, VirtualMachineManager.ExecuteInSequence.value());
            cmd.setCacheTO(cacheData.getTO());
            cmd.setOptions(options);
            EndPoint ep = selector.select(srcData, destData);
            if (ep == null) {
                String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
                s_logger.error(errMsg);
                answer = new Answer(cmd, false, errMsg);
            } else {
                answer = ep.sendMessage(cmd);
            }
        } else {
            addFullCloneAndDiskprovisiongStrictnessFlagOnVMwareDest(destData.getTO());
            CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _backupsnapshotwait, VirtualMachineManager.ExecuteInSequence.value());
            cmd.setOptions(options);
            EndPoint ep = selector.select(srcData, destData, StorageAction.BACKUPSNAPSHOT);
            if (ep == null) {
                String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
                s_logger.error(errMsg);
                answer = new Answer(cmd, false, errMsg);
            } else {
                answer = ep.sendMessage(cmd);
            }
        }
        // clean up cache entry
        if (cacheData != null) {
            cacheMgr.deleteCacheObject(cacheData);
        }
        return answer;
    } catch (Exception e) {
        s_logger.debug("copy snasphot failed: ", e);
        if (cacheData != null) {
            cacheMgr.deleteCacheObject(cacheData);
        }
        throw new CloudRuntimeException(e.toString());
    }
}
Also used : HashMap(java.util.HashMap) CopyCommand(org.apache.cloudstack.storage.command.CopyCommand) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(org.apache.cloudstack.storage.RemoteHostEndPoint) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(org.apache.cloudstack.storage.RemoteHostEndPoint) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Answer(com.cloud.agent.api.Answer) MigrateVolumeAnswer(com.cloud.agent.api.storage.MigrateVolumeAnswer) SnapshotInfo(org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo) DataObject(org.apache.cloudstack.engine.subsystem.api.storage.DataObject) ZoneScope(org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope) Scope(org.apache.cloudstack.engine.subsystem.api.storage.Scope) HostScope(org.apache.cloudstack.engine.subsystem.api.storage.HostScope) ClusterScope(org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Aggregations

CopyCommand (org.apache.cloudstack.storage.command.CopyCommand)29 EndPoint (org.apache.cloudstack.engine.subsystem.api.storage.EndPoint)17 Answer (com.cloud.agent.api.Answer)16 CopyCmdAnswer (org.apache.cloudstack.storage.command.CopyCmdAnswer)14 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)13 DataObject (org.apache.cloudstack.engine.subsystem.api.storage.DataObject)9 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)8 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)8 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)8 RemoteHostEndPoint (org.apache.cloudstack.storage.RemoteHostEndPoint)8 CopyCommandResult (org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult)7 ZoneScope (org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope)7 MigrateVolumeAnswer (com.cloud.agent.api.storage.MigrateVolumeAnswer)6 DataStoreTO (com.cloud.agent.api.to.DataStoreTO)6 DataTO (com.cloud.agent.api.to.DataTO)6 NfsTO (com.cloud.agent.api.to.NfsTO)6 HostVO (com.cloud.host.HostVO)6 TemplateObjectTO (org.apache.cloudstack.storage.to.TemplateObjectTO)6 ClusterScope (org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope)5 HostScope (org.apache.cloudstack.engine.subsystem.api.storage.HostScope)5