@@ -138,7 +138,7 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy {
138138 private static final String OPERATION_NOT_SUPPORTED = "This operation is not supported." ;
139139
140140 @ Inject
141- protected AgentManager _agentMgr ;
141+ protected AgentManager agentManager ;
142142 @ Inject private ConfigurationDao _configDao ;
143143 @ Inject private DataStoreManager dataStoreMgr ;
144144 @ Inject
@@ -953,7 +953,7 @@ else if (HypervisorType.VMware.equals(snapshotInfo.getHypervisorType()) || Hyper
953953
954954 copyCommand .setOptions (srcDetails );
955955
956- copyCmdAnswer = (CopyCmdAnswer )_agentMgr .send (hostVO .getId (), copyCommand );
956+ copyCmdAnswer = (CopyCmdAnswer )agentManager .send (hostVO .getId (), copyCommand );
957957
958958 if (!copyCmdAnswer .getResult ()) {
959959 errMsg = copyCmdAnswer .getDetails ();
@@ -1120,7 +1120,7 @@ private void handleCreateNonManagedVolumeFromManagedSnapshot(SnapshotInfo snapsh
11201120
11211121 copyCommand .setOptions (srcDetails );
11221122
1123- copyCmdAnswer = (CopyCmdAnswer )_agentMgr .send (hostVO .getId (), copyCommand );
1123+ copyCmdAnswer = (CopyCmdAnswer )agentManager .send (hostVO .getId (), copyCommand );
11241124
11251125 if (!copyCmdAnswer .getResult ()) {
11261126 errMsg = copyCmdAnswer .getDetails ();
@@ -1609,7 +1609,7 @@ private CopyCmdAnswer copyImageToVolume(DataObject srcDataObject, VolumeInfo des
16091609
16101610 copyCommand .setOptions2 (destDetails );
16111611
1612- copyCmdAnswer = (CopyCmdAnswer )_agentMgr .send (hostVO .getId (), copyCommand );
1612+ copyCmdAnswer = (CopyCmdAnswer )agentManager .send (hostVO .getId (), copyCommand );
16131613 }
16141614 catch (CloudRuntimeException | AgentUnavailableException | OperationTimedoutException ex ) {
16151615 String msg = "Failed to copy image : " ;
@@ -1724,6 +1724,8 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
17241724 continue ;
17251725 }
17261726
1727+ migrateTemplateToTargetFilesystemStorageIfNeeded (srcVolumeInfo , destDataStore , destStoragePool , destHost );
1728+
17271729 VolumeVO destVolume = duplicateVolumeOnAnotherStorage (srcVolume , destStoragePool );
17281730 VolumeInfo destVolumeInfo = _volumeDataFactory .getVolume (destVolume .getId (), destDataStore );
17291731
@@ -1763,7 +1765,7 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
17631765 PrepareForMigrationCommand pfmc = new PrepareForMigrationCommand (vmTO );
17641766
17651767 try {
1766- Answer pfma = _agentMgr .send (destHost .getId (), pfmc );
1768+ Answer pfma = agentManager .send (destHost .getId (), pfmc );
17671769
17681770 if (pfma == null || !pfma .getResult ()) {
17691771 String details = pfma != null ? pfma .getDetails () : "null answer returned" ;
@@ -1791,7 +1793,7 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
17911793
17921794 migrateCommand .setAutoConvergence (kvmAutoConvergence );
17931795
1794- MigrateAnswer migrateAnswer = (MigrateAnswer )_agentMgr .send (srcHost .getId (), migrateCommand );
1796+ MigrateAnswer migrateAnswer = (MigrateAnswer )agentManager .send (srcHost .getId (), migrateCommand );
17951797
17961798 boolean success = migrateAnswer != null && migrateAnswer .getResult ();
17971799
@@ -1859,14 +1861,21 @@ protected void setVolumePath(VolumeVO volume) {
18591861 volume .setPath (volume .get_iScsiName ());
18601862 }
18611863
1864+ /**
1865+ * For this strategy it is not necessary to check and migrate the template; however, classes that extend this one may need to check if the template is on the target storage pool (and if not then migrate) before migrating the VM.
1866+ */
1867+ protected void migrateTemplateToTargetFilesystemStorageIfNeeded (VolumeInfo srcVolumeInfo , DataStore destDataStore , StoragePool destStoragePool , Host destHost ) {
1868+ // This method is used by classes that extend this one
1869+ }
1870+
18621871 private void handlePostMigration (boolean success , Map <VolumeInfo , VolumeInfo > srcVolumeInfoToDestVolumeInfo , VirtualMachineTO vmTO , Host destHost ) {
18631872 if (!success ) {
18641873 try {
18651874 PrepareForMigrationCommand pfmc = new PrepareForMigrationCommand (vmTO );
18661875
18671876 pfmc .setRollback (true );
18681877
1869- Answer pfma = _agentMgr .send (destHost .getId (), pfmc );
1878+ Answer pfma = agentManager .send (destHost .getId (), pfmc );
18701879
18711880 if (pfma == null || !pfma .getResult ()) {
18721881 String details = pfma != null ? pfma .getDetails () : "null answer returned" ;
@@ -2007,7 +2016,7 @@ private ModifyTargetsCommand getModifyTargetsCommand(long storagePoolId, String
20072016 }
20082017
20092018 private List <String > sendModifyTargetsCommand (ModifyTargetsCommand cmd , long hostId ) {
2010- ModifyTargetsAnswer modifyTargetsAnswer = (ModifyTargetsAnswer )_agentMgr .easySend (hostId , cmd );
2019+ ModifyTargetsAnswer modifyTargetsAnswer = (ModifyTargetsAnswer )agentManager .easySend (hostId , cmd );
20112020
20122021 if (modifyTargetsAnswer == null ) {
20132022 throw new CloudRuntimeException ("Unable to get an answer to the modify targets command" );
@@ -2125,7 +2134,7 @@ private void handleCreateTemplateFromManagedVolume(VolumeInfo volumeInfo, Templa
21252134
21262135 copyCommand .setOptions (srcDetails );
21272136
2128- copyCmdAnswer = (CopyCmdAnswer )_agentMgr .send (hostVO .getId (), copyCommand );
2137+ copyCmdAnswer = (CopyCmdAnswer )agentManager .send (hostVO .getId (), copyCommand );
21292138
21302139 if (!copyCmdAnswer .getResult ()) {
21312140 errMsg = copyCmdAnswer .getDetails ();
@@ -2389,7 +2398,7 @@ private CopyCmdAnswer performResignature(DataObject dataObj, HostVO hostVO, Map<
23892398 try {
23902399 _volumeService .grantAccess (dataObj , hostVO , dataStore );
23912400
2392- answer = (ResignatureAnswer )_agentMgr .send (hostVO .getId (), command );
2401+ answer = (ResignatureAnswer )agentManager .send (hostVO .getId (), command );
23932402 }
23942403 catch (CloudRuntimeException | AgentUnavailableException | OperationTimedoutException ex ) {
23952404 keepGrantedAccess = false ;
@@ -2466,7 +2475,7 @@ private String migrateVolumeForKVM(VolumeInfo srcVolumeInfo, VolumeInfo destVolu
24662475
24672476 _volumeService .grantAccess (destVolumeInfo , hostVO , destVolumeInfo .getDataStore ());
24682477
2469- MigrateVolumeAnswer migrateVolumeAnswer = (MigrateVolumeAnswer )_agentMgr .send (hostVO .getId (), migrateVolumeCommand );
2478+ MigrateVolumeAnswer migrateVolumeAnswer = (MigrateVolumeAnswer )agentManager .send (hostVO .getId (), migrateVolumeCommand );
24702479
24712480 if (migrateVolumeAnswer == null || !migrateVolumeAnswer .getResult ()) {
24722481 if (migrateVolumeAnswer != null && !StringUtils .isEmpty (migrateVolumeAnswer .getDetails ())) {
@@ -2534,7 +2543,7 @@ private String copyManagedVolumeToSecondaryStorage(VolumeInfo srcVolumeInfo, Vol
25342543 _volumeService .grantAccess (srcVolumeInfo , hostVO , srcVolumeInfo .getDataStore ());
25352544 }
25362545
2537- CopyVolumeAnswer copyVolumeAnswer = (CopyVolumeAnswer )_agentMgr .send (hostVO .getId (), copyVolumeCommand );
2546+ CopyVolumeAnswer copyVolumeAnswer = (CopyVolumeAnswer )agentManager .send (hostVO .getId (), copyVolumeCommand );
25382547
25392548 if (copyVolumeAnswer == null || !copyVolumeAnswer .getResult ()) {
25402549 if (copyVolumeAnswer != null && !StringUtils .isEmpty (copyVolumeAnswer .getDetails ())) {
@@ -2623,7 +2632,7 @@ private CopyCmdAnswer performCopyOfVdi(VolumeInfo volumeInfo, SnapshotInfo snaps
26232632
26242633 copyCommand .setOptions2 (destDetails );
26252634
2626- copyCmdAnswer = (CopyCmdAnswer )_agentMgr .send (hostVO .getId (), copyCommand );
2635+ copyCmdAnswer = (CopyCmdAnswer )agentManager .send (hostVO .getId (), copyCommand );
26272636 }
26282637 catch (CloudRuntimeException | AgentUnavailableException | OperationTimedoutException ex ) {
26292638 String msg = "Failed to perform VDI copy : " ;
0 commit comments