From 61dfb2d625ede1d5ce38450bd4ddbdb2a1129b91 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Thu, 5 Feb 2015 16:29:03 +0530 Subject: [PATCH] AgentAttache: allow checkonhost command in maintenance, cancel if only allowed Signed-off-by: Rohit Yadav --- .../com/cloud/agent/manager/AgentAttache.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java index 0f02792493f..0acac3c0479 100644 --- a/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java +++ b/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java @@ -38,6 +38,7 @@ import com.cloud.agent.Listener; import com.cloud.agent.api.Answer; import com.cloud.agent.api.CheckHealthCommand; import com.cloud.agent.api.CheckNetworkCommand; +import com.cloud.agent.api.CheckOnHostCommand; import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.CleanupNetworkRulesCmd; import com.cloud.agent.api.Command; @@ -111,7 +112,7 @@ public abstract class AgentAttache { public final static String[] s_commandsAllowedInMaintenanceMode = new String[] {MaintainCommand.class.toString(), MigrateCommand.class.toString(), StopCommand.class.toString(), CheckVirtualMachineCommand.class.toString(), PingTestCommand.class.toString(), CheckHealthCommand.class.toString(), ReadyCommand.class.toString(), ShutdownCommand.class.toString(), SetupCommand.class.toString(), - CleanupNetworkRulesCmd.class.toString(), CheckNetworkCommand.class.toString(), PvlanSetupCommand.class.toString()}; + CleanupNetworkRulesCmd.class.toString(), CheckNetworkCommand.class.toString(), PvlanSetupCommand.class.toString(), CheckOnHostCommand.class.toString()}; protected final static String[] s_commandsNotAllowedInConnectingMode = new String[] {StartCommand.class.toString(), CreateCommand.class.toString()}; static { Arrays.sort(s_commandsAllowedInMaintenanceMode); @@ -307,16 +308,18 @@ public abstract class AgentAttache { } protected void cancelAllCommands(final Status state, final boolean cancelActive) { - final Set> entries = _waitForList.entrySet(); - final Iterator> it = entries.iterator(); - while (it.hasNext()) { - final Map.Entry entry = it.next(); - it.remove(); - final Listener monitor = entry.getValue(); - if (s_logger.isDebugEnabled()) { - s_logger.debug(log(entry.getKey(), "Sending disconnect to " + monitor.getClass())); + if (cancelActive) { + final Set> entries = _waitForList.entrySet(); + final Iterator> it = entries.iterator(); + while (it.hasNext()) { + final Map.Entry entry = it.next(); + it.remove(); + final Listener monitor = entry.getValue(); + if (s_logger.isDebugEnabled()) { + s_logger.debug(log(entry.getKey(), "Sending disconnect to " + monitor.getClass())); + } + monitor.processDisconnect(_id, state); } - monitor.processDisconnect(_id, state); } }