Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1403#discussion_r59075640 --- Diff: engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java --- @@ -80,32 +92,48 @@ @Inject private AgentManager _agentMgr; @Inject private ConfigurationDao _configDao; + @Inject private DataStoreManager _dataStoreMgr; @Inject private DiskOfferingDao _diskOfferingDao; @Inject private HostDao _hostDao; + @Inject private HostDetailsDao _hostDetailsDao; @Inject private ManagementService _mgr; @Inject private PrimaryDataStoreDao _storagePoolDao; @Inject private SnapshotDao _snapshotDao; @Inject private SnapshotDetailsDao _snapshotDetailsDao; @Inject private VolumeDao _volumeDao; @Inject private VolumeDataFactory _volumeDataFactory; + @Inject private VolumeDetailsDao _volumeDetailsDao; @Inject private VolumeService _volumeService; @Override public StrategyPriority canHandle(DataObject srcData, DataObject destData) { if (srcData instanceof SnapshotInfo) { - if (canHandle(srcData.getDataStore()) || canHandle(destData.getDataStore())) { + if (canHandle(srcData) || canHandle(destData)) { return StrategyPriority.HIGHEST; } } + if (srcData instanceof TemplateInfo && destData instanceof VolumeInfo && + (srcData.getDataStore().getId() == destData.getDataStore().getId()) && + (canHandle(srcData) || canHandle(destData))) { + // Both source and dest are on the same storage, so just clone them. + return StrategyPriority.HIGHEST; + } + return StrategyPriority.CANT_HANDLE; } - private boolean canHandle(DataStore dataStore) { + private boolean canHandle(DataObject dataObject) { --- End diff -- @mike-tutkowski while it's unlikely, we should defined against if for nothing more than providing a better error than an NPE. Seems like a good place to use ``Preconditions.checkArgument`` with a meaningful error message. It also better pinpoints the origin of the failure.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---