From b2d76bad2e9455384c4ac34cee6763014e255eb6 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Tue, 10 May 2022 20:45:24 +0200 Subject: [PATCH] agent: enable ssl only for kvm agent (not in system vms) --- agent/src/main/java/com/cloud/agent/AgentShell.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/agent/src/main/java/com/cloud/agent/AgentShell.java b/agent/src/main/java/com/cloud/agent/AgentShell.java index b693ce1b2b3..9009cbd2cb5 100644 --- a/agent/src/main/java/com/cloud/agent/AgentShell.java +++ b/agent/src/main/java/com/cloud/agent/AgentShell.java @@ -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 properties = Collections.list((Enumeration)_properties.propertyNames()); @@ -399,12 +401,17 @@ public class AgentShell implements IAgentShell, Daemon { _backoff.configure("ConstantTimeBackoff", new HashMap()); } - 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);