@@ -1078,7 +1078,7 @@ private static class VolumeTask {
10781078 }
10791079 }
10801080
1081- private List <VolumeTask > getTasks (List <VolumeVO > vols , Map <Volume , StoragePool > destVols ) throws StorageUnavailableException {
1081+ private List <VolumeTask > getTasks (List <VolumeVO > vols , Map <Volume , StoragePool > destVols , VirtualMachineProfile vm ) throws StorageUnavailableException {
10821082 boolean recreate = RecreatableSystemVmEnabled .value ();
10831083 List <VolumeTask > tasks = new ArrayList <VolumeTask >();
10841084 for (VolumeVO vol : vols ) {
@@ -1118,7 +1118,14 @@ private List<VolumeTask> getTasks(List<VolumeVO> vols, Map<Volume, StoragePool>
11181118 throw new CloudRuntimeException ("Local volume " + vol + " cannot be recreated on storagepool " + assignedPool + " assigned by deploymentPlanner" );
11191119 } else {
11201120 //Check if storage migration is enabled in config
1121- if (StorageHAMigrationEnabled .value ()) {
1121+ Boolean isHAOperation = (Boolean )vm .getParameter (VirtualMachineProfile .Param .HaOperation );
1122+ Boolean storageMigrationEnabled = true ;
1123+ if (isHAOperation != null && isHAOperation ) {
1124+ storageMigrationEnabled = StorageHAMigrationEnabled .value ();
1125+ } else {
1126+ storageMigrationEnabled = StorageMigrationEnabled .value ();
1127+ }
1128+ if (storageMigrationEnabled ){
11221129 if (s_logger .isDebugEnabled ()) {
11231130 s_logger .debug ("Shared volume " + vol + " will be migrated on storage pool " + assignedPool + " assigned by deploymentPlanner" );
11241131 }
@@ -1276,7 +1283,7 @@ public void prepare(VirtualMachineProfile vm, DeployDestination dest) throws Sto
12761283 s_logger .debug ("Checking if we need to prepare " + vols .size () + " volumes for " + vm );
12771284 }
12781285
1279- List <VolumeTask > tasks = getTasks (vols , dest .getStorageForDisks ());
1286+ List <VolumeTask > tasks = getTasks (vols , dest .getStorageForDisks (), vm );
12801287 Volume vol = null ;
12811288 StoragePool pool = null ;
12821289 for (VolumeTask task : tasks ) {
@@ -1327,6 +1334,9 @@ public boolean canVmRestartOnAnotherServer(long vmId) {
13271334 public static final ConfigKey <Boolean > StorageHAMigrationEnabled = new ConfigKey <Boolean >(Boolean .class , "enable.ha.storage.migration" , "Storage" , "true" ,
13281335 "Enable/disable storage migration across primary storage during HA" , true );
13291336
1337+ public static final ConfigKey <Boolean > StorageMigrationEnabled = new ConfigKey <Boolean >(Boolean .class , "enable.storage.migration" , "Storage" , "true" ,
1338+ "Enable/disable storage migration across primary storage" , true );
1339+
13301340 @ Override
13311341 public ConfigKey <?>[] getConfigKeys () {
13321342 return new ConfigKey <?>[] {RecreatableSystemVmEnabled , MaxVolumeSize , StorageHAMigrationEnabled , CustomDiskOfferingMaxSize , CustomDiskOfferingMinSize };
0 commit comments