mirror of https://github.com/apache/cloudstack.git
Merge 7071461e90 into bce3e54a7e
This commit is contained in:
commit
fd077f1cee
|
|
@ -45,10 +45,12 @@ import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
|
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
|
||||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
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.RemoteHostEndPoint;
|
||||||
import org.apache.cloudstack.storage.command.CopyCommand;
|
import org.apache.cloudstack.storage.command.CopyCommand;
|
||||||
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
|
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
|
||||||
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
|
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.image.datastore.ImageStoreEntity;
|
||||||
import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
|
import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
@ -104,6 +106,9 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
|
||||||
@Inject
|
@Inject
|
||||||
SnapshotDao snapshotDao;
|
SnapshotDao snapshotDao;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
HeuristicRuleHelper heuristicRuleHelper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StrategyPriority canHandle(DataObject srcData, DataObject destData) {
|
public StrategyPriority canHandle(DataObject srcData, DataObject destData) {
|
||||||
return StrategyPriority.DEFAULT;
|
return StrategyPriority.DEFAULT;
|
||||||
|
|
@ -374,7 +379,13 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
|
||||||
}
|
}
|
||||||
// need to find a nfs or cifs image store, assuming that can't copy volume
|
// need to find a nfs or cifs image store, assuming that can't copy volume
|
||||||
// directly to s3
|
// directly to s3
|
||||||
ImageStoreEntity imageStore = (ImageStoreEntity)dataStoreMgr.getImageStoreWithFreeCapacity(destScope.getScopeId());
|
Long zoneId = destScope.getScopeId();
|
||||||
|
ImageStoreEntity imageStore = (ImageStoreEntity) heuristicRuleHelper.getImageStoreIfThereIsHeuristicRule(zoneId, HeuristicType.VOLUME, destData);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
if (imageStore == null || !imageStore.getProtocol().equalsIgnoreCase("nfs") && !imageStore.getProtocol().equalsIgnoreCase("cifs")) {
|
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";
|
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);
|
Answer answer = new Answer(null, false, errMsg);
|
||||||
|
|
|
||||||
|
|
@ -117,8 +117,8 @@ public class HeuristicRuleHelper {
|
||||||
accountId = ((SnapshotInfo) obj).getAccountId();
|
accountId = ((SnapshotInfo) obj).getAccountId();
|
||||||
break;
|
break;
|
||||||
case VOLUME:
|
case VOLUME:
|
||||||
presetVariables.setVolume(setVolumePresetVariable((VolumeVO) obj));
|
presetVariables.setVolume(setVolumePresetVariable((com.cloud.storage.Volume) obj));
|
||||||
accountId = ((VolumeVO) obj).getAccountId();
|
accountId = ((com.cloud.storage.Volume) obj).getAccountId();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
presetVariables.setAccount(setAccountPresetVariable(accountId));
|
presetVariables.setAccount(setAccountPresetVariable(accountId));
|
||||||
|
|
@ -191,14 +191,14 @@ public class HeuristicRuleHelper {
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Volume setVolumePresetVariable(VolumeVO volumeVO) {
|
protected Volume setVolumePresetVariable(com.cloud.storage.Volume volumeVO) {
|
||||||
Volume volume = new Volume();
|
Volume volumePresetVariable = new Volume();
|
||||||
|
|
||||||
volume.setName(volumeVO.getName());
|
volumePresetVariable.setName(volumeVO.getName());
|
||||||
volume.setFormat(volumeVO.getFormat());
|
volumePresetVariable.setFormat(volumeVO.getFormat());
|
||||||
volume.setSize(volumeVO.getSize());
|
volumePresetVariable.setSize(volumeVO.getSize());
|
||||||
|
|
||||||
return volume;
|
return volumePresetVariable;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Snapshot setSnapshotPresetVariable(SnapshotInfo snapshotInfo) {
|
protected Snapshot setSnapshotPresetVariable(SnapshotInfo snapshotInfo) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue