mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Change vmsnapshot.max config to be dynamic (#9883)
Co-authored-by: Lucas Martins <lucas.martins@scclouds.com.br>
This commit is contained in:
parent
2c412f8947
commit
5886780240
@ -31,7 +31,7 @@ public interface VMSnapshotManager extends VMSnapshotService, Manager {
|
||||
static final ConfigKey<Integer> VMSnapshotExpireInterval = new ConfigKey<Integer>("Advanced", Integer.class, "vmsnapshot.expire.interval", "-1",
|
||||
"VM Snapshot expire interval in hours", true, ConfigKey.Scope.Account);
|
||||
|
||||
public static final int VMSNAPSHOTMAX = 10;
|
||||
ConfigKey<Integer> VMSnapshotMax = new ConfigKey<Integer>("Advanced", Integer.class, "vmsnapshot.max", "10", "Maximum vm snapshots for a single vm", true, ConfigKey.Scope.Global);
|
||||
|
||||
/**
|
||||
* Delete all VM snapshots belonging to one VM
|
||||
|
||||
@ -1740,7 +1740,6 @@ DefaultMaxAccountProjects(
|
||||
null),
|
||||
|
||||
// VMSnapshots
|
||||
VMSnapshotMax("Advanced", VMSnapshotManager.class, Integer.class, "vmsnapshot.max", "10", "Maximum vm snapshots for a vm", null),
|
||||
VMSnapshotCreateWait("Advanced", VMSnapshotManager.class, Integer.class, "vmsnapshot.create.wait", "1800", "In second, timeout for create vm snapshot", null),
|
||||
|
||||
CloudDnsName("Advanced", ManagementServer.class, String.class, "cloud.dns.name", null, "DNS name of the cloud for the GSLB service", null),
|
||||
|
||||
@ -174,7 +174,6 @@ public class VMSnapshotManagerImpl extends MutualExclusiveIdsManagerBase impleme
|
||||
|
||||
VmWorkJobHandlerProxy _jobHandlerProxy = new VmWorkJobHandlerProxy(this);
|
||||
|
||||
int _vmSnapshotMax;
|
||||
int _wait;
|
||||
|
||||
static final ConfigKey<Long> VmJobCheckInterval = new ConfigKey<Long>("Advanced",
|
||||
@ -188,8 +187,6 @@ public class VMSnapshotManagerImpl extends MutualExclusiveIdsManagerBase impleme
|
||||
throw new ConfigurationException("Unable to get the configuration dao.");
|
||||
}
|
||||
|
||||
_vmSnapshotMax = NumbersUtil.parseInt(_configDao.getValue("vmsnapshot.max"), VMSNAPSHOTMAX);
|
||||
|
||||
String value = _configDao.getValue("vmsnapshot.create.wait");
|
||||
_wait = NumbersUtil.parseInt(value, 1800);
|
||||
|
||||
@ -398,8 +395,10 @@ public class VMSnapshotManagerImpl extends MutualExclusiveIdsManagerBase impleme
|
||||
_accountMgr.checkAccess(caller, null, true, userVmVo);
|
||||
|
||||
// check max snapshot limit for per VM
|
||||
if (_vmSnapshotDao.findByVm(vmId).size() >= _vmSnapshotMax) {
|
||||
throw new CloudRuntimeException("Creating vm snapshot failed due to a VM can just have : " + _vmSnapshotMax + " VM snapshots. Please delete old ones");
|
||||
int vmSnapshotMax = VMSnapshotManager.VMSnapshotMax.value();
|
||||
|
||||
if (_vmSnapshotDao.findByVm(vmId).size() >= vmSnapshotMax) {
|
||||
throw new CloudRuntimeException("Creating vm snapshot failed due to a VM can just have : " + vmSnapshotMax + " VM snapshots. Please delete old ones");
|
||||
}
|
||||
|
||||
// check if there are active volume snapshots tasks
|
||||
@ -1391,6 +1390,6 @@ public class VMSnapshotManagerImpl extends MutualExclusiveIdsManagerBase impleme
|
||||
|
||||
@Override
|
||||
public ConfigKey<?>[] getConfigKeys() {
|
||||
return new ConfigKey<?>[] {VMSnapshotExpireInterval};
|
||||
return new ConfigKey<?>[] {VMSnapshotExpireInterval, VMSnapshotMax};
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +136,6 @@ public class VMSnapshotManagerTest {
|
||||
VMSnapshotDetailsDao _vmSnapshotDetailsDao;
|
||||
@Mock
|
||||
UserVmManager _userVmManager;
|
||||
int _vmSnapshotMax = 10;
|
||||
|
||||
private static final long TEST_VM_ID = 3L;
|
||||
private static final long SERVICE_OFFERING_ID = 1L;
|
||||
@ -194,8 +193,6 @@ public class VMSnapshotManagerTest {
|
||||
|
||||
doNothing().when(_accountMgr).checkAccess(any(Account.class), any(AccessType.class), any(Boolean.class), any(ControlledEntity.class));
|
||||
|
||||
_vmSnapshotMgr._vmSnapshotMax = _vmSnapshotMax;
|
||||
|
||||
_vmSnapshotMgr._serviceOfferingDao = _serviceOfferingDao;
|
||||
_vmSnapshotMgr._userVmDetailsDao = _userVmDetailsDao;
|
||||
_vmSnapshotMgr._vmSnapshotDetailsDao = _vmSnapshotDetailsDao;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user