Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.framework.async.AsyncRpcContext;
import org.apache.cloudstack.storage.command.CopyCmdAnswer;
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
Expand All @@ -47,6 +46,7 @@
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
import org.apache.log4j.Logger;

import com.cloud.agent.api.Answer;
import com.cloud.secstorage.CommandExecLogDao;
import com.cloud.storage.DataStoreRole;
import com.cloud.utils.Pair;
Expand Down Expand Up @@ -91,6 +91,7 @@ public AsyncCallFuture<DataObjectResult> migrateData(DataObject srcDataObject, D
if (srcDataObject instanceof SnapshotInfo && snapshotChain != null && snapshotChain.containsKey(srcDataObject)) {
List<String> parentSnapshotPaths = new ArrayList<>();
for (SnapshotInfo snapshotInfo : snapshotChain.get(srcDataObject).first()) {
destDataObject = null;
if (!parentSnapshotPaths.isEmpty() && parentSnapshotPaths.contains(snapshotInfo.getPath())) {
parentSnapshotPaths.add(snapshotInfo.getPath());
SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findByStoreSnapshot(DataStoreRole.Image, srcDatastore.getId(), snapshotInfo.getSnapshotId());
Expand Down Expand Up @@ -135,6 +136,7 @@ public AsyncCallFuture<DataObjectResult> migrateData(DataObject srcDataObject, D
} catch (Exception e) {
s_logger.debug("Failed to copy Data", e);
if (destDataObject != null) {
s_logger.info("Deleting data on destination store: " + destDataObject.getDataStore().getName());
destDataObject.getDataStore().delete(destDataObject);
}
if (!(srcDataObject instanceof VolumeInfo)) {
Expand Down Expand Up @@ -164,7 +166,7 @@ protected Void migrateDataCallBack(AsyncCallbackDispatcher<SecondaryStorageServi
CopyCommandResult result = callback.getResult();
AsyncCallFuture<DataObjectResult> future = context.future;
DataObjectResult res = new DataObjectResult(srcData);
CopyCmdAnswer answer = (CopyCmdAnswer) result.getAnswer();
Answer answer = result.getAnswer();
try {
if (!answer.getResult()) {
s_logger.warn("Migration failed for "+srcData.getUuid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

import javax.inject.Inject;

import com.cloud.agent.api.to.NfsTO;
import com.cloud.storage.DataStoreRole;
import com.cloud.storage.Upload;
import org.apache.cloudstack.storage.image.deployasis.DeployAsIsHelper;
import org.apache.log4j.Logger;
Expand Down Expand Up @@ -396,6 +398,15 @@ private Answer sendToLeastBusyEndpoint(List<EndPoint> eps, CopyCommand cmd) {

@Override
public boolean canCopy(DataObject srcData, DataObject destData) {
DataStore srcStore = srcData.getDataStore();
DataStore destStore = destData.getDataStore();
if ((srcData.getDataStore().getTO() instanceof NfsTO && destData.getDataStore().getTO() instanceof NfsTO) &&
(srcStore.getRole() == DataStoreRole.Image && destStore.getRole() == DataStoreRole.Image) &&
((srcData.getType() == DataObjectType.TEMPLATE && destData.getType() == DataObjectType.TEMPLATE) ||
(srcData.getType() == DataObjectType.SNAPSHOT && destData.getType() == DataObjectType.SNAPSHOT) ||
(srcData.getType() == DataObjectType.VOLUME && destData.getType() == DataObjectType.VOLUME))) {
return true;
}
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ public void processEvent(ObjectInDataStoreStateMachine.Event event) {
volEvent = Volume.Event.UploadRequested;
} else if (event == ObjectInDataStoreStateMachine.Event.MigrationRequested) {
volEvent = Volume.Event.CopyRequested;
} else if (event == ObjectInDataStoreStateMachine.Event.MigrateDataRequested) {
return;
}
} else {
if (event == ObjectInDataStoreStateMachine.Event.CreateRequested || event == ObjectInDataStoreStateMachine.Event.CreateOnlyRequested) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import java.nio.file.Path;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -1313,6 +1314,8 @@ protected Answer copyFromNfsToNfs(CopyCommand cmd) {
srcDir = new File(srcFile.getParent());
} else if (!srcFile.isDirectory()) {
srcDir = new File(srcFile.getParent());
} else if (srcFile.isDirectory() && Arrays.stream(srcData.getPath().split(File.separator)).count() == 4) {
destFile = new File(destFile.getPath(), srcFile.getName());
}
File destDir = null;
if (destFile.isFile()) {
Expand Down