Skip to content
Open
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 @@ -45,10 +45,12 @@
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.secstorage.heuristics.HeuristicType;
import org.apache.cloudstack.storage.RemoteHostEndPoint;
import org.apache.cloudstack.storage.command.CopyCommand;
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
import org.apache.cloudstack.storage.heuristics.HeuristicRuleHelper;
import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -104,6 +106,9 @@
@Inject
SnapshotDao snapshotDao;

@Inject
HeuristicRuleHelper heuristicRuleHelper;

@Override
public StrategyPriority canHandle(DataObject srcData, DataObject destData) {
return StrategyPriority.DEFAULT;
Expand Down Expand Up @@ -374,7 +379,13 @@
}
// need to find a nfs or cifs image store, assuming that can't copy volume
// directly to s3
ImageStoreEntity imageStore = (ImageStoreEntity)dataStoreMgr.getImageStoreWithFreeCapacity(destScope.getScopeId());
Long zoneId = destScope.getScopeId();
ImageStoreEntity imageStore = (ImageStoreEntity) heuristicRuleHelper.getImageStoreIfThereIsHeuristicRule(zoneId, HeuristicType.VOLUME, destData);

Check warning on line 383 in engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java

View check run for this annotation

Codecov / codecov/patch

engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java#L382-L383

Added lines #L382 - L383 were not covered by tests
if (imageStore == null) {
logger.debug("Secondary storage selector did not direct volume migration to a specific secondary storage; using secondary storage with the most free capacity.");
imageStore = (ImageStoreEntity) dataStoreMgr.getImageStoreWithFreeCapacity(zoneId);

Check warning on line 386 in engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java

View check run for this annotation

Codecov / codecov/patch

engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java#L385-L386

Added lines #L385 - L386 were not covered by tests
}

if (imageStore == null || !imageStore.getProtocol().equalsIgnoreCase("nfs") && !imageStore.getProtocol().equalsIgnoreCase("cifs")) {
String errMsg = "can't find a nfs (or cifs) image store to satisfy the need for a staging store";
Answer answer = new Answer(null, false, errMsg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ protected void buildPresetVariables(JsInterpreter jsInterpreter, HeuristicType h
accountId = ((SnapshotInfo) obj).getAccountId();
break;
case VOLUME:
presetVariables.setVolume(setVolumePresetVariable((VolumeVO) obj));
accountId = ((VolumeVO) obj).getAccountId();
presetVariables.setVolume(setVolumePresetVariable((com.cloud.storage.Volume) obj));
accountId = ((com.cloud.storage.Volume) obj).getAccountId();
break;
}
presetVariables.setAccount(setAccountPresetVariable(accountId));
Expand Down Expand Up @@ -191,14 +191,14 @@ protected Template setTemplatePresetVariable(VMTemplateVO templateVO) {
return template;
}

protected Volume setVolumePresetVariable(VolumeVO volumeVO) {
Volume volume = new Volume();
protected Volume setVolumePresetVariable(com.cloud.storage.Volume volumeVO) {
Volume volumePresetVariable = new Volume();

volume.setName(volumeVO.getName());
volume.setFormat(volumeVO.getFormat());
volume.setSize(volumeVO.getSize());
volumePresetVariable.setName(volumeVO.getName());
volumePresetVariable.setFormat(volumeVO.getFormat());
volumePresetVariable.setSize(volumeVO.getSize());

return volume;
return volumePresetVariable;
}

protected Snapshot setSnapshotPresetVariable(SnapshotInfo snapshotInfo) {
Expand Down
Loading