|
45 | 45 | import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope; |
46 | 46 | import org.apache.cloudstack.framework.async.AsyncCompletionCallback; |
47 | 47 | import org.apache.cloudstack.framework.config.dao.ConfigurationDao; |
| 48 | +import org.apache.cloudstack.secstorage.heuristics.HeuristicType; |
48 | 49 | import org.apache.cloudstack.storage.RemoteHostEndPoint; |
49 | 50 | import org.apache.cloudstack.storage.command.CopyCommand; |
50 | 51 | import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao; |
51 | 52 | import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO; |
| 53 | +import org.apache.cloudstack.storage.heuristics.HeuristicRuleHelper; |
52 | 54 | import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity; |
53 | 55 | import org.apache.cloudstack.storage.to.PrimaryDataStoreTO; |
54 | 56 | import org.apache.logging.log4j.Logger; |
@@ -104,6 +106,9 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { |
104 | 106 | @Inject |
105 | 107 | SnapshotDao snapshotDao; |
106 | 108 |
|
| 109 | + @Inject |
| 110 | + HeuristicRuleHelper heuristicRuleHelper; |
| 111 | + |
107 | 112 | @Override |
108 | 113 | public StrategyPriority canHandle(DataObject srcData, DataObject destData) { |
109 | 114 | return StrategyPriority.DEFAULT; |
@@ -374,7 +379,13 @@ protected Answer copyVolumeBetweenPools(DataObject srcData, DataObject destData) |
374 | 379 | } |
375 | 380 | // need to find a nfs or cifs image store, assuming that can't copy volume |
376 | 381 | // directly to s3 |
377 | | - ImageStoreEntity imageStore = (ImageStoreEntity)dataStoreMgr.getImageStoreWithFreeCapacity(destScope.getScopeId()); |
| 382 | + Long zoneId = destScope.getScopeId(); |
| 383 | + ImageStoreEntity imageStore = (ImageStoreEntity) heuristicRuleHelper.getImageStoreIfThereIsHeuristicRule(zoneId, HeuristicType.VOLUME, destData); |
| 384 | + if (imageStore == null) { |
| 385 | + logger.debug("Secondary storage selector did not direct volume migration to a specific secondary storage; using secondary storage with the most free capacity."); |
| 386 | + imageStore = (ImageStoreEntity) dataStoreMgr.getImageStoreWithFreeCapacity(zoneId); |
| 387 | + } |
| 388 | + |
378 | 389 | if (imageStore == null || !imageStore.getProtocol().equalsIgnoreCase("nfs") && !imageStore.getProtocol().equalsIgnoreCase("cifs")) { |
379 | 390 | String errMsg = "can't find a nfs (or cifs) image store to satisfy the need for a staging store"; |
380 | 391 | Answer answer = new Answer(null, false, errMsg); |
|
0 commit comments