From 2ffab4fe29982538a3ecb17096814fb9fe6cf17a Mon Sep 17 00:00:00 2001 From: anthony Date: Wed, 13 Oct 2010 18:13:20 -0700 Subject: [PATCH] only send command to host which is UP --- server/src/com/cloud/agent/manager/AgentManagerImpl.java | 4 ++++ .../agent/manager/allocator/impl/FirstFitAllocator.java | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java index c85e1015ad9..39580c745fe 100755 --- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java @@ -1160,6 +1160,10 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory { @Override public Answer easySend(final Long hostId, final Command cmd, int timeout) { try { + Host h = _hostDao.findById(hostId); + if( !h.getStatus().equals(Status.Up) ) { + return null; + } final Answer answer = send(hostId, cmd, timeout); if (answer == null) { s_logger.warn("send returns null answer"); diff --git a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java index b192344bc65..23c83572d67 100755 --- a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java +++ b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java @@ -35,6 +35,7 @@ import com.cloud.dc.HostPodVO; import com.cloud.host.DetailVO; import com.cloud.host.Host; import com.cloud.host.HostVO; +import com.cloud.host.Status; import com.cloud.host.Host.Type; import com.cloud.host.dao.DetailsDao; import com.cloud.host.dao.HostDao; @@ -97,7 +98,10 @@ public class FirstFitAllocator implements HostAllocator { List poolhosts = _storagePoolHostDao.listByPoolId(sp.getId()); List hosts = new ArrayList(); for( StoragePoolHostVO poolhost : poolhosts ){ - hosts.add(_hostDao.findById(poolhost.getHostId())); + HostVO h = _hostDao.findById(poolhost.getHostId()); + if( h != null && h.getType().equals(Type.Routing) && h.getStatus().equals(Status.Up)) { + hosts.add(h); + } } long podId = pod.getId();