From e66f4e96bb79337454ef617d03d41e0cdc7cd237 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Wed, 10 Apr 2024 16:20:38 -0300 Subject: [PATCH 1/2] refactor configuration SystemVMDefaultHypervisor --- .../main/java/com/cloud/resource/ResourceManager.java | 5 +++++ .../src/main/java/com/cloud/configuration/Config.java | 7 ------- .../java/com/cloud/resource/ResourceManagerImpl.java | 10 +++------- 3 files changed, 8 insertions(+), 14 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 83f9768a62ac..488b8926bc24 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 @@ -75,6 +75,11 @@ public interface ResourceManager extends ResourceService, Configurable { ConfigKey.Kind.Select, "," + CPU.CPUArch.getTypesAsCSV()); + ConfigKey SystemVMDefaultHypervisor = new ConfigKey(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 a6efaffcb56d..f561badac05b 100644 --- a/server/src/main/java/com/cloud/configuration/Config.java +++ b/server/src/main/java/com/cloud/configuration/Config.java @@ -642,13 +642,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 5c8b09e28ab5..815bc610237e 100755 --- a/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java @@ -320,7 +320,6 @@ public void setDiscoverers(final List discoverers) { private final HashMap _resourceStateAdapters = new HashMap<>(); private final HashMap> _lifeCycleListeners = new HashMap<>(); - private HypervisorType _defaultSystemVMHypervisor; private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 30; // seconds @@ -2784,7 +2783,6 @@ public DataCenter getZone(Long zoneId) { @Override public boolean configure(final String name, final Map params) throws ConfigurationException { - _defaultSystemVMHypervisor = HypervisorType.getType(_configDao.getValue(Config.SystemVMDefaultHypervisor.toString())); _gson = GsonHelper.getGson(); _hypervisorsInDC = _hostDao.createSearchBuilder(String.class); @@ -2830,10 +2828,7 @@ public List getSupportedHypervisorTypes(final long zoneId, final @Override public HypervisorType getDefaultHypervisor(final long zoneId) { - HypervisorType defaultHyper = HypervisorType.None; - if (_defaultSystemVMHypervisor != HypervisorType.None) { - defaultHyper = _defaultSystemVMHypervisor; - } + HypervisorType defaultHyper = HypervisorType.getType(ResourceManager.SystemVMDefaultHypervisor.value()); final DataCenterVO dc = _dcDao.findById(zoneId); if (dc == null) { @@ -4313,7 +4308,8 @@ public ConfigKey[] getConfigKeys() { return new ConfigKey[] { KvmSshToAgentEnabled, HOST_MAINTENANCE_LOCAL_STRATEGY, - SystemVmPreferredArchitecture + SystemVmPreferredArchitecture, + SystemVMDefaultHypervisor }; } } From 29843c8deab583134dfb3b2f7ac1fd6a24f278c0 Mon Sep 17 00:00:00 2001 From: gabriel Date: Mon, 12 Jan 2026 13:17:08 -0300 Subject: [PATCH 2/2] change variable name --- .../java/com/cloud/resource/ResourceManagerImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java b/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java index 815bc610237e..ebac77d42cfb 100755 --- a/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java @@ -2828,7 +2828,7 @@ public List getSupportedHypervisorTypes(final long zoneId, final @Override public HypervisorType getDefaultHypervisor(final long zoneId) { - HypervisorType defaultHyper = HypervisorType.getType(ResourceManager.SystemVMDefaultHypervisor.value()); + HypervisorType systemVMDefaultHypervisor = HypervisorType.getType(ResourceManager.SystemVMDefaultHypervisor.value()); final DataCenterVO dc = _dcDao.findById(zoneId); if (dc == null) { @@ -2837,27 +2837,27 @@ public HypervisorType getDefaultHypervisor(final long zoneId) { _dcDao.loadDetails(dc); final String defaultHypervisorInZone = dc.getDetail("defaultSystemVMHypervisorType"); if (defaultHypervisorInZone != null) { - defaultHyper = HypervisorType.getType(defaultHypervisorInZone); + systemVMDefaultHypervisor = HypervisorType.getType(defaultHypervisorInZone); } final List 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 clusters = _clusterDao.listByDcHyType(zoneId, defaultHyper.toString()); + final List clusters = _clusterDao.listByDcHyType(zoneId, systemVMDefaultHypervisor.toString()); if (clusters.isEmpty()) { isValid = false; } } if (isValid) { - return defaultHyper; + return systemVMDefaultHypervisor; } else { return HypervisorType.None; }