diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 613a882c206..eac3b755070 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -86,7 +86,8 @@ public enum Config { CreatePrivateTemplateFromSnapshotWait("Storage", UserVmManager.class, Integer.class, "create.private.template.from.snapshot.wait", "10800", "In second, timeout for CreatePrivateTemplateFromSnapshotCommand", null), BackupSnapshotWait( "Storage", StorageManager.class, Integer.class, "backup.snapshot.wait", "21600", "In second, timeout for BackupSnapshotCommand", null), - + HAStorageMigration("Storage", ManagementServer.class, Boolean.class, "enable.ha.storage.migration", "true", "Enable/disable storage migration across primary storage during HA", null), + // Network NetworkLBHaproxyStatsVisbility("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.visibility", "global", "Load Balancer(haproxy) stats visibilty, the value can be one of the following six parameters : global,guest-network,link-local,disabled,all,default", null), NetworkLBHaproxyStatsUri("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.uri","/admin?stats","Load Balancer(haproxy) uri.",null), diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java index 232b640afd6..f3e1d9fe649 100644 --- a/server/src/com/cloud/storage/VolumeManagerImpl.java +++ b/server/src/com/cloud/storage/VolumeManagerImpl.java @@ -331,6 +331,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { private final int _customDiskOfferingMaxSize = 1024; private long _maxVolumeSizeInGb; private boolean _recreateSystemVmEnabled; + private boolean _storageHAMigrationEnabled; public VolumeManagerImpl() { _volStateMachine = Volume.State.getStateMachine(); @@ -2461,15 +2462,20 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { } throw new CloudRuntimeException("Local volume " + vol + " cannot be recreated on storagepool " + assignedPool + " assigned by deploymentPlanner"); } else { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Shared volume " - + vol - + " will be migrated on storage pool " - + assignedPool - + " assigned by deploymentPlanner"); + //Check if storage migration is enabled in config + if (_storageHAMigrationEnabled) { + if (s_logger.isDebugEnabled()) { + s_logger.debug("Shared volume " + + vol + + " will be migrated on storage pool " + + assignedPool + + " assigned by deploymentPlanner"); + } + VolumeTask task = new VolumeTask(VolumeTaskType.MIGRATE, vol, assignedPool); + tasks.add(task); + } else { + throw new CloudRuntimeException("Cannot migrate volumes. Volume Migration is disabled"); } - VolumeTask task = new VolumeTask(VolumeTaskType.MIGRATE, vol, assignedPool); - tasks.add(task); } } else { StoragePoolVO pool = _storagePoolDao @@ -2682,9 +2688,13 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { String value = _configDao.getValue(Config.RecreateSystemVmEnabled.key()); _recreateSystemVmEnabled = Boolean.parseBoolean(value); + + String storageMigrationEnabled = _configDao.getValue(Config.HAStorageMigration.key()); + _storageHAMigrationEnabled = (storageMigrationEnabled == null) ? true : Boolean.parseBoolean(storageMigrationEnabled); + _copyvolumewait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CopyVolumeWait.getDefaultValue())); - + return true; } diff --git a/setup/db/db/schema-420to421.sql b/setup/db/db/schema-420to421.sql index 1e6341e0d16..fc43fe50661 100644 --- a/setup/db/db/schema-420to421.sql +++ b/setup/db/db/schema-420to421.sql @@ -22,3 +22,5 @@ INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 's3.multipart.enabled', 'true', 'enable s3 multipart upload'); +INSERT IGNORE INTO `cloud`.`configuration` VALUES ("Storage", 'DEFAULT', 'management-server', "enable.ha.storage.migration", "true", "Enable/disable storage migration across primary storage during HA"); +