Prioritize hypervisor.uri configuration (#8254)

Co-authored-by: Henrique Sato <henrique.sato@scclouds.com.br>
This commit is contained in:
sato03 2023-12-06 16:43:04 -03:00 committed by GitHub
parent 14376ce298
commit fdfbb4fad1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -1004,10 +1004,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
rollingMaintenanceExecutor = BooleanUtils.isTrue(AgentPropertiesFileHandler.getPropertyValue(AgentProperties.ROLLING_MAINTENANCE_SERVICE_EXECUTOR_DISABLED)) ? new RollingMaintenanceAgentExecutor(hooksDir) : rollingMaintenanceExecutor = BooleanUtils.isTrue(AgentPropertiesFileHandler.getPropertyValue(AgentProperties.ROLLING_MAINTENANCE_SERVICE_EXECUTOR_DISABLED)) ? new RollingMaintenanceAgentExecutor(hooksDir) :
new RollingMaintenanceServiceExecutor(hooksDir); new RollingMaintenanceServiceExecutor(hooksDir);
hypervisorURI = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.HYPERVISOR_URI);
if (hypervisorURI == null) {
hypervisorURI = LibvirtConnection.getHypervisorURI(hypervisorType.toString()); hypervisorURI = LibvirtConnection.getHypervisorURI(hypervisorType.toString());
}
networkDirectSourceMode = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.NETWORK_DIRECT_SOURCE_MODE); networkDirectSourceMode = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.NETWORK_DIRECT_SOURCE_MODE);
networkDirectDevice = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.NETWORK_DIRECT_DEVICE); networkDirectDevice = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.NETWORK_DIRECT_DEVICE);

View File

@ -19,6 +19,8 @@ package com.cloud.hypervisor.kvm.resource;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.cloud.agent.properties.AgentProperties;
import com.cloud.agent.properties.AgentPropertiesFileHandler;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.libvirt.Connect; import org.libvirt.Connect;
import org.libvirt.LibvirtException; import org.libvirt.LibvirtException;
@ -88,10 +90,15 @@ public class LibvirtConnection {
} }
static String getHypervisorURI(String hypervisorType) { static String getHypervisorURI(String hypervisorType) {
String uri = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.HYPERVISOR_URI);
if (uri != null) {
return uri;
}
if ("LXC".equalsIgnoreCase(hypervisorType)) { if ("LXC".equalsIgnoreCase(hypervisorType)) {
return "lxc:///"; return "lxc:///";
} else { }
return "qemu:///system"; return "qemu:///system";
} }
}
} }