agent: enable ssl only for kvm agent (not in system vms)

This commit is contained in:
Wei Zhou 2022-05-10 20:45:24 +02:00
parent c1691a9e2d
commit b2d76bad2e

View File

@ -76,6 +76,8 @@ public class AgentShell implements IAgentShell, Daemon {
private String connectedHost;
private Long preferredHostCheckInterval;
static final String LIBVIRT_COMPUTING_RESOURCE = "com.cloud.hypervisor.kvm.resource.LibvirtComputingResource";
public AgentShell() {
}
@ -375,7 +377,7 @@ public class AgentShell implements IAgentShell, Daemon {
loadProperties();
parseCommand(args);
enableSSL();
enableSSLForKvmAgent();
if (s_logger.isDebugEnabled()) {
List<String> properties = Collections.list((Enumeration<String>)_properties.propertyNames());
@ -399,12 +401,17 @@ public class AgentShell implements IAgentShell, Daemon {
_backoff.configure("ConstantTimeBackoff", new HashMap<String, Object>());
}
private void enableSSL() {
private void enableSSLForKvmAgent() {
final File agentFile = PropertiesUtil.findConfigFile("agent.properties");
if (agentFile == null) {
s_logger.info("Failed to find agent.properties file");
return;
}
final String resource = getProperty(null, "resource");
if (!LIBVIRT_COMPUTING_RESOURCE.equalsIgnoreCase(resource)) {
s_logger.info("This is not a cloudstack kvm agent, ignoring");
return;
}
String keystorePass = getProperty(null, "keystore.passphrase");
if (StringUtils.isBlank(keystorePass)) {
s_logger.info("Failed to find passphrase for keystore: " + KeyStoreUtils.KS_FILENAME);