This is an automated email from the ASF dual-hosted git repository.
harikrishna pushed a commit to branch 4.22
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.22 by this push:
new 128dbe2c0be Refactor configuration SystemVMDefaultHypervisor (#8934)
128dbe2c0be is described below
commit 128dbe2c0be87c9a2986030aa40264444738cd76
Author: GaOrtiga <[email protected]>
AuthorDate: Tue Jan 27 02:06:59 2026 -0300
Refactor configuration SystemVMDefaultHypervisor (#8934)
* refactor configuration SystemVMDefaultHypervisor
* change variable name
---------
Co-authored-by: Gabriel <[email protected]>
---
.../main/java/com/cloud/resource/ResourceManager.java | 5 +++++
.../src/main/java/com/cloud/configuration/Config.java | 7 -------
.../java/com/cloud/resource/ResourceManagerImpl.java | 18 +++++++-----------
3 files changed, 12 insertions(+), 18 deletions(-)
diff --git
a/engine/components-api/src/main/java/com/cloud/resource/ResourceManager.java
b/engine/components-api/src/main/java/com/cloud/resource/ResourceManager.java
index 8550dfdd906..120b716518e 100755
---
a/engine/components-api/src/main/java/com/cloud/resource/ResourceManager.java
+++
b/engine/components-api/src/main/java/com/cloud/resource/ResourceManager.java
@@ -79,6 +79,11 @@ public interface ResourceManager extends ResourceService,
Configurable {
ConfigKey.Kind.Select,
"," + CPU.CPUArch.getTypesAsCSV());
+ ConfigKey<String> SystemVMDefaultHypervisor = new
ConfigKey<String>(String.class,
+ "system.vm.default.hypervisor", "Advanced", "Any", "Hypervisor
type used to create System VMs. Valid values are: XenServer, KVM, VMware,
Hyperv, VirtualBox, " +
+ "Parralels, BareMetal, Ovm, LXC, Any", true,
ConfigKey.Scope.Global, null, null, null, null, null, ConfigKey.Kind.Select,
"XenServer, KVM, VMware, Hyperv, " +
+ "VirtualBox, Parralels, BareMetal, Ovm, LXC, Any");
+
/**
* Register a listener for different types of resource life cycle events.
* There can only be one type of listener per type of host.
diff --git a/server/src/main/java/com/cloud/configuration/Config.java
b/server/src/main/java/com/cloud/configuration/Config.java
index abae4d3996c..a82ccb33a4a 100644
--- a/server/src/main/java/com/cloud/configuration/Config.java
+++ b/server/src/main/java/com/cloud/configuration/Config.java
@@ -542,13 +542,6 @@ public enum Config {
"true",
"Indicates whether or not to automatically reserver system VM
standby capacity.",
null),
- SystemVMDefaultHypervisor("Advanced",
- ManagementServer.class,
- String.class,
- "system.vm.default.hypervisor",
- null,
- "Hypervisor type used to create system vm, valid values are:
XenServer, KVM, VMware, Hyperv, VirtualBox, Parralels, BareMetal, Ovm, LXC,
Any",
- null),
SystemVMRandomPassword(
"Advanced",
ManagementServer.class,
diff --git a/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
b/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
index 110353c4b48..3545bf5dddf 100755
--- a/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
@@ -352,7 +352,6 @@ public class ResourceManagerImpl extends ManagerBase
implements ResourceManager,
private final HashMap<String, ResourceStateAdapter> _resourceStateAdapters
= new HashMap<>();
private final HashMap<Integer, List<ResourceListener>> _lifeCycleListeners
= new HashMap<>();
- private HypervisorType _defaultSystemVMHypervisor;
private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 30;
// seconds
@@ -2935,7 +2934,6 @@ public class ResourceManagerImpl extends ManagerBase
implements ResourceManager,
@Override
public boolean configure(final String name, final Map<String, Object>
params) throws ConfigurationException {
- _defaultSystemVMHypervisor =
HypervisorType.getType(_configDao.getValue(Config.SystemVMDefaultHypervisor.toString()));
_gson = GsonHelper.getGson();
_hypervisorsInDC = _hostDao.createSearchBuilder(String.class);
@@ -2981,10 +2979,7 @@ public class ResourceManagerImpl extends ManagerBase
implements ResourceManager,
@Override
public HypervisorType getDefaultHypervisor(final long zoneId) {
- HypervisorType defaultHyper = HypervisorType.None;
- if (_defaultSystemVMHypervisor != HypervisorType.None) {
- defaultHyper = _defaultSystemVMHypervisor;
- }
+ HypervisorType systemVMDefaultHypervisor =
HypervisorType.getType(ResourceManager.SystemVMDefaultHypervisor.value());
final DataCenterVO dc = _dcDao.findById(zoneId);
if (dc == null) {
@@ -2993,27 +2988,27 @@ public class ResourceManagerImpl extends ManagerBase
implements ResourceManager,
_dcDao.loadDetails(dc);
final String defaultHypervisorInZone =
dc.getDetail("defaultSystemVMHypervisorType");
if (defaultHypervisorInZone != null) {
- defaultHyper = HypervisorType.getType(defaultHypervisorInZone);
+ systemVMDefaultHypervisor =
HypervisorType.getType(defaultHypervisorInZone);
}
final List<VMTemplateVO> systemTemplates =
_templateDao.listAllSystemVMTemplates();
boolean isValid = false;
for (final VMTemplateVO template : systemTemplates) {
- if (template.getHypervisorType() == defaultHyper) {
+ if (template.getHypervisorType() == systemVMDefaultHypervisor) {
isValid = true;
break;
}
}
if (isValid) {
- final List<ClusterVO> clusters =
_clusterDao.listByDcHyType(zoneId, defaultHyper.toString());
+ final List<ClusterVO> clusters =
_clusterDao.listByDcHyType(zoneId, systemVMDefaultHypervisor.toString());
if (clusters.isEmpty()) {
isValid = false;
}
}
if (isValid) {
- return defaultHyper;
+ return systemVMDefaultHypervisor;
} else {
return HypervisorType.None;
}
@@ -4578,7 +4573,8 @@ public class ResourceManagerImpl extends ManagerBase
implements ResourceManager,
return new ConfigKey<?>[] {
KvmSshToAgentEnabled,
HOST_MAINTENANCE_LOCAL_STRATEGY,
- SystemVmPreferredArchitecture
+ SystemVmPreferredArchitecture,
+ SystemVMDefaultHypervisor
};
}
}