From 2bc938c3f8c6662c0f25a317b9134cab455152ba Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Tue, 26 Oct 2010 09:34:40 -0700 Subject: [PATCH] checkins for problems. --- .../exception/PermissionDeniedException.java | 3 ++- client/tomcatconf/commands.properties.in | 2 +- core/src/com/cloud/agent/Listener.java | 4 +++- .../cloud/agent/manager/AgentManagerImpl.java | 18 +++++++++++++----- .../com/cloud/agent/manager/AgentMonitor.java | 3 +-- .../agent/manager/SynchronousListener.java | 3 +-- .../async/executor/VMOperationListener.java | 12 ++++++++++-- .../executor/VolumeOperationListener.java | 11 +++++++++-- .../consoleproxy/ConsoleProxyListener.java | 3 +-- server/src/com/cloud/ha/VmSyncListener.java | 13 ++++++++----- .../kvm/discoverer/KvmServerDiscoverer.java | 4 +--- .../xen/discoverer/XcpServerDiscoverer.java | 5 ++--- .../cloud/network/SshKeysDistriMonitor.java | 8 ++++---- .../network/security/NetworkGroupListener.java | 4 +--- .../storage/LocalStoragePoolListener.java | 13 ++++++------- .../storage/download/DownloadListener.java | 9 ++++----- .../storage/listener/StoragePoolMonitor.java | 3 +-- .../storage/listener/StorageSyncListener.java | 3 +-- .../secondary/SecondaryStorageListener.java | 10 +++------- .../cloud/storage/upload/UploadListener.java | 11 ++++------- server/src/com/cloud/vm/UserVmManagerImpl.java | 13 ++++++------- .../src/com/cloud/utils/SerialVersionUID.java | 8 ++------ .../src/com/cloud/utils/db/GenericDaoBase.java | 2 +- 23 files changed, 85 insertions(+), 80 deletions(-) diff --git a/api/src/com/cloud/exception/PermissionDeniedException.java b/api/src/com/cloud/exception/PermissionDeniedException.java index 1141fa6d260..bb304011aad 100644 --- a/api/src/com/cloud/exception/PermissionDeniedException.java +++ b/api/src/com/cloud/exception/PermissionDeniedException.java @@ -17,6 +17,7 @@ */ package com.cloud.exception; +import com.cloud.utils.SerialVersionUID; import com.cloud.utils.exception.CloudRuntimeException; /** @@ -25,7 +26,7 @@ import com.cloud.utils.exception.CloudRuntimeException; */ public class PermissionDeniedException extends CloudRuntimeException { - private static final long serialVersionUID = -4631412831814398074L; + private static final long serialVersionUID = SerialVersionUID.PermissionDeniedException; public PermissionDeniedException(String message) { super(message); diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index f6f76565f72..e1989cbc6a3 100755 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -33,7 +33,7 @@ updateResourceLimit=com.cloud.api.commands.UpdateResourceLimitCmd;3 listResourceLimits=com.cloud.api.commands.ListResourceLimitsCmd;15 #### VM commands -deployVirtualMachine=com.cloud.api.commands.DeployVm2Cmd;11 +deployVirtualMachine=com.cloud.api.commands.DeployVMCmd;11 destroyVirtualMachine=com.cloud.api.commands.DestroyVMCmd;15 rebootVirtualMachine=com.cloud.api.commands.RebootVMCmd;15 startVirtualMachine=com.cloud.api.commands.StartVMCmd;15 diff --git a/core/src/com/cloud/agent/Listener.java b/core/src/com/cloud/agent/Listener.java index 19f0babd116..6b5619cdf56 100755 --- a/core/src/com/cloud/agent/Listener.java +++ b/core/src/com/cloud/agent/Listener.java @@ -22,6 +22,7 @@ import com.cloud.agent.api.AgentControlCommand; import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; import com.cloud.agent.api.StartupCommand; +import com.cloud.exception.ConnectionException; import com.cloud.host.HostVO; import com.cloud.host.Status; @@ -73,8 +74,9 @@ public interface Listener { * been registered for host events. * @param agentId id of the agent * @param cmd command sent by the agent to the server on startup. + * @throws ConnectionException if host has problems and needs to put into maintenance state. */ - boolean processConnect(HostVO host, StartupCommand cmd); + void processConnect(HostVO host, StartupCommand cmd) throws ConnectionException; /** * This method is called by AgentManager when an agent disconnects diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java index 78a5b76f407..741b7d13699 100755 --- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java @@ -96,6 +96,7 @@ import com.cloud.dc.dao.HostPodDao; import com.cloud.dc.dao.VlanDao; import com.cloud.event.dao.EventDao; import com.cloud.exception.AgentUnavailableException; +import com.cloud.exception.ConnectionException; import com.cloud.exception.DiscoveryException; import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.OperationTimedoutException; @@ -1050,11 +1051,18 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory { s_logger.debug("Sending Connect to listener: " + monitor.second().getClass().getSimpleName()); } for (int i = 0; i < cmd.length; i++) { - if (!monitor.second().processConnect(host, cmd[i])) { - s_logger.info("Monitor " + monitor.second().getClass().getSimpleName() + " says not to continue the connect process for " + hostId); - handleDisconnect(attache, Event.AgentDisconnected, false); - return attache; - } + try { + monitor.second().processConnect(host, cmd[i]); + } catch (ConnectionException e) { + if (e.isSetupError()) { + s_logger.warn("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + " due to " + e.getMessage()); + handleDisconnect(attache, Event.AgentDisconnected, false); + } else { + s_logger.info("Monitor " + monitor.second().getClass().getSimpleName() + " says not to continue the connect process for " + hostId + " due to " + e.getMessage()); + handleDisconnect(attache, Event.ShutdownRequested, false); + } + return null; + } } } diff --git a/server/src/com/cloud/agent/manager/AgentMonitor.java b/server/src/com/cloud/agent/manager/AgentMonitor.java index 237aa66c9ff..17ed235c56c 100755 --- a/server/src/com/cloud/agent/manager/AgentMonitor.java +++ b/server/src/com/cloud/agent/manager/AgentMonitor.java @@ -195,9 +195,8 @@ public class AgentMonitor extends Thread implements Listener { } @Override - public boolean processConnect(HostVO host, StartupCommand cmd) { + public void processConnect(HostVO host, StartupCommand cmd) { s_logger.debug("Registering agent monitor for " + host.getId()); - return true; } @Override diff --git a/server/src/com/cloud/agent/manager/SynchronousListener.java b/server/src/com/cloud/agent/manager/SynchronousListener.java index dd5d1d001fd..7f1293d0c20 100755 --- a/server/src/com/cloud/agent/manager/SynchronousListener.java +++ b/server/src/com/cloud/agent/manager/SynchronousListener.java @@ -80,8 +80,7 @@ public class SynchronousListener implements Listener { } @Override - public boolean processConnect(HostVO agent, StartupCommand cmd) { - return false; + public void processConnect(HostVO agent, StartupCommand cmd) { } @Override diff --git a/server/src/com/cloud/async/executor/VMOperationListener.java b/server/src/com/cloud/async/executor/VMOperationListener.java index c37ddec25bc..c15b901b030 100644 --- a/server/src/com/cloud/async/executor/VMOperationListener.java +++ b/server/src/com/cloud/async/executor/VMOperationListener.java @@ -50,6 +50,7 @@ public class VMOperationListener implements Listener { _cookie = cookie; } + @Override public boolean processAnswers(long agentId, long seq, Answer[] answers) { Answer answer = null; if(answers != null) @@ -61,33 +62,40 @@ public class VMOperationListener implements Listener { return true; } + @Override public boolean processCommands(long agentId, long seq, Command[] commands) { return true; } + @Override public AgentControlAnswer processControlCommand(long agentId, AgentControlCommand cmd) { return null; } - public boolean processConnect(HostVO agent, StartupCommand cmd) { - return true; + @Override + public void processConnect(HostVO agent, StartupCommand cmd) { +// return true; } + @Override public boolean processDisconnect(long agentId, Status state) { if(_vm.getHostId() == agentId) _executor.processDisconnect(this, agentId); return true; } + @Override public boolean isRecurring() { return false; } + @Override public int getTimeout() { // TODO : no time out support for now as underlying support does not work as expected return -1; } + @Override public boolean processTimeout(long agentId, long seq) { if(s_logger.isDebugEnabled()) s_logger.debug("Process time out for " + agentId + "-" + seq); diff --git a/server/src/com/cloud/async/executor/VolumeOperationListener.java b/server/src/com/cloud/async/executor/VolumeOperationListener.java index 39f5668396a..0ef17af29de 100644 --- a/server/src/com/cloud/async/executor/VolumeOperationListener.java +++ b/server/src/com/cloud/async/executor/VolumeOperationListener.java @@ -52,6 +52,7 @@ public class VolumeOperationListener implements Listener { _cookie = cookie; } + @Override public boolean processAnswers(long agentId, long seq, Answer[] answers) { Answer answer = null; if(answers != null) @@ -64,33 +65,39 @@ public class VolumeOperationListener implements Listener { return true; } + @Override public boolean processCommands(long agentId, long seq, Command[] commands) { return true; } + @Override public AgentControlAnswer processControlCommand(long agentId, AgentControlCommand cmd) { return null; } - public boolean processConnect(HostVO agent, StartupCommand cmd) { - return true; + @Override + public void processConnect(HostVO agent, StartupCommand cmd) { } + @Override public boolean processDisconnect(long agentId, Status state) { if(_vm.getHostId() == agentId) _executor.processDisconnect(this, agentId); return true; } + @Override public boolean isRecurring() { return false; } + @Override public int getTimeout() { // TODO : no time out support for now as underlying support does not work as expected return -1; } + @Override public boolean processTimeout(long agentId, long seq) { if(s_logger.isDebugEnabled()) s_logger.debug("Process time out for " + agentId + "-" + seq); diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyListener.java b/server/src/com/cloud/consoleproxy/ConsoleProxyListener.java index 67dca3aa760..ef653085f23 100644 --- a/server/src/com/cloud/consoleproxy/ConsoleProxyListener.java +++ b/server/src/com/cloud/consoleproxy/ConsoleProxyListener.java @@ -64,9 +64,8 @@ public class ConsoleProxyListener implements Listener { } @Override - public boolean processConnect(HostVO host, StartupCommand cmd) { + public void processConnect(HostVO host, StartupCommand cmd) { _proxyMgr.onAgentConnect(host, cmd); - return true; } @Override diff --git a/server/src/com/cloud/ha/VmSyncListener.java b/server/src/com/cloud/ha/VmSyncListener.java index eb179dce44b..26898aedd97 100644 --- a/server/src/com/cloud/ha/VmSyncListener.java +++ b/server/src/com/cloud/ha/VmSyncListener.java @@ -33,6 +33,8 @@ import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupRoutingCommand; import com.cloud.agent.manager.Commands; import com.cloud.exception.AgentUnavailableException; +import com.cloud.exception.ConnectionException; +import com.cloud.exception.OperationTimedoutException; import com.cloud.host.HostVO; import com.cloud.host.Status; import com.cloud.host.dao.HostDao; @@ -119,9 +121,9 @@ public class VmSyncListener implements Listener { } @Override - public boolean processConnect(HostVO agent, StartupCommand cmd) { + public void processConnect(HostVO agent, StartupCommand cmd) throws ConnectionException { if (!(cmd instanceof StartupRoutingCommand)) { - return true; + return; } long agentId = agent.getId(); @@ -135,12 +137,13 @@ public class VmSyncListener implements Listener { Commands cmds = new Commands(OnError.Continue); cmds.addCommands(commands); try { - _agentMgr.send(agentId, cmds, this); + Answer[] answers = _agentMgr.send(agentId, cmds); } catch (final AgentUnavailableException e) { s_logger.warn("Agent is unavailable now", e); + throw new ConnectionException(true, "Unable to sync", e); + } catch (final OperationTimedoutException e) { + throw new ConnectionException(true, "Unable to sync", e); } } - - return true; } } diff --git a/server/src/com/cloud/hypervisor/kvm/discoverer/KvmServerDiscoverer.java b/server/src/com/cloud/hypervisor/kvm/discoverer/KvmServerDiscoverer.java index cb3b993b921..8fb84b3d3e5 100644 --- a/server/src/com/cloud/hypervisor/kvm/discoverer/KvmServerDiscoverer.java +++ b/server/src/com/cloud/hypervisor/kvm/discoverer/KvmServerDiscoverer.java @@ -71,9 +71,7 @@ public class KvmServerDiscoverer extends DiscovererBase implements Discoverer, } @Override - public boolean processConnect(HostVO host, StartupCommand cmd) { - // TODO Auto-generated method stub - return false; + public void processConnect(HostVO host, StartupCommand cmd) { } @Override diff --git a/server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java b/server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java index 17002c5a132..bdca29c3468 100644 --- a/server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java +++ b/server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java @@ -45,6 +45,7 @@ import com.cloud.alert.AlertManager; import com.cloud.configuration.Config; import com.cloud.dc.ClusterVO; import com.cloud.dc.dao.ClusterDao; +import com.cloud.exception.ConnectionException; import com.cloud.exception.DiscoveryException; import com.cloud.host.HostInfo; import com.cloud.host.HostVO; @@ -521,12 +522,10 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L } @Override - public boolean processConnect(HostVO agent, StartupCommand cmd) { + public void processConnect(HostVO agent, StartupCommand cmd) throws ConnectionException { if (cmd instanceof StartupStorageCommand) { createPVTemplate(agent.getId(), (StartupStorageCommand)cmd); - return true; } - return true; } @Override diff --git a/server/src/com/cloud/network/SshKeysDistriMonitor.java b/server/src/com/cloud/network/SshKeysDistriMonitor.java index c56e3d06178..3ca6e01060a 100644 --- a/server/src/com/cloud/network/SshKeysDistriMonitor.java +++ b/server/src/com/cloud/network/SshKeysDistriMonitor.java @@ -31,6 +31,7 @@ import com.cloud.agent.api.Command; import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupRoutingCommand; import com.cloud.configuration.dao.ConfigurationDao; +import com.cloud.exception.ConnectionException; import com.cloud.host.HostVO; import com.cloud.host.Status; import com.cloud.host.dao.HostDao; @@ -71,10 +72,10 @@ public class SshKeysDistriMonitor implements Listener { } @Override - public boolean processConnect(HostVO host, StartupCommand cmd) { + public void processConnect(HostVO host, StartupCommand cmd) throws ConnectionException { if (cmd instanceof StartupRoutingCommand) { if (((StartupRoutingCommand) cmd).getHypervisorType() == HypervisorType.KVM || - ((StartupRoutingCommand) cmd).getHypervisorType() == HypervisorType.XenServer) { + ((StartupRoutingCommand) cmd).getHypervisorType() == HypervisorType.XenServer) { /*TODO: Get the private/public keys here*/ Map configs = _configDao.getConfiguration("management-server", new HashMap()); @@ -82,11 +83,10 @@ public class SshKeysDistriMonitor implements Listener { String prvKey = configs.get("ssh.privatekey"); if (!_routerMgr.sendSshKeysToHost(host.getId(), pubKey, prvKey)) { s_logger.debug("Failed to send keys to agent: " + host.getId()); - return false; + throw new ConnectionException(true, "Unable to send keys to the agent"); } } } - return true; } @Override diff --git a/server/src/com/cloud/network/security/NetworkGroupListener.java b/server/src/com/cloud/network/security/NetworkGroupListener.java index e93f4e9792c..885eef3b643 100644 --- a/server/src/com/cloud/network/security/NetworkGroupListener.java +++ b/server/src/com/cloud/network/security/NetworkGroupListener.java @@ -111,9 +111,7 @@ public class NetworkGroupListener implements Listener { @Override - public boolean processConnect(HostVO host, StartupCommand cmd) { - - return true; + public void processConnect(HostVO host, StartupCommand cmd) { } diff --git a/server/src/com/cloud/storage/LocalStoragePoolListener.java b/server/src/com/cloud/storage/LocalStoragePoolListener.java index fecf47435a6..da7e045e62c 100644 --- a/server/src/com/cloud/storage/LocalStoragePoolListener.java +++ b/server/src/com/cloud/storage/LocalStoragePoolListener.java @@ -27,9 +27,9 @@ import com.cloud.agent.api.Command; import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupStorageCommand; import com.cloud.agent.api.StoragePoolInfo; +import com.cloud.exception.ConnectionException; import com.cloud.host.HostVO; import com.cloud.host.Status; -import com.cloud.storage.Storage.StorageResourceType; import com.cloud.storage.dao.StoragePoolDao; import com.cloud.storage.dao.StoragePoolHostDao; import com.cloud.utils.component.Inject; @@ -65,20 +65,20 @@ public class LocalStoragePoolListener implements Listener { @Override @DB - public boolean processConnect(HostVO host, StartupCommand cmd) { + public void processConnect(HostVO host, StartupCommand cmd) throws ConnectionException { if (!(cmd instanceof StartupStorageCommand)) { - return true; + return; } StartupStorageCommand ssCmd = (StartupStorageCommand)cmd; if (ssCmd.getResourceType() != Storage.StorageResourceType.STORAGE_POOL) { - return true; + return; } StoragePoolInfo pInfo = ssCmd.getPoolInfo(); if (pInfo == null) { - return true; + return; } try { @@ -114,9 +114,8 @@ public class LocalStoragePoolListener implements Listener { } } catch (Exception e) { s_logger.warn("Unable to setup the local storage pool for " + host, e); - return false; + throw new ConnectionException(true, "Unable to setup the local storage pool for " + host, e); } - return true; } diff --git a/server/src/com/cloud/storage/download/DownloadListener.java b/server/src/com/cloud/storage/download/DownloadListener.java index e2b18905355..647afefb4b6 100644 --- a/server/src/com/cloud/storage/download/DownloadListener.java +++ b/server/src/com/cloud/storage/download/DownloadListener.java @@ -39,6 +39,7 @@ import com.cloud.agent.api.storage.DownloadProgressCommand; import com.cloud.agent.api.storage.DownloadProgressCommand.RequestType; import com.cloud.event.EventTypes; import com.cloud.event.EventVO; +import com.cloud.exception.ConnectionException; import com.cloud.host.HostVO; import com.cloud.storage.Storage; import com.cloud.storage.VMTemplateHostVO; @@ -274,13 +275,13 @@ public class DownloadListener implements Listener { } @Override - public boolean processConnect(HostVO agent, StartupCommand cmd) { + public void processConnect(HostVO agent, StartupCommand cmd) throws ConnectionException { if (!(cmd instanceof StartupStorageCommand)) { - return true; + return; } if (cmd.getGuid().startsWith("iso:")) { //FIXME: do not download template for ISO secondary - return true; + return; } long agentId = agent.getId(); @@ -294,8 +295,6 @@ public class DownloadListener implements Listener { //downloadMonitor.handlePoolTemplateSync(storage.getPoolInfo(), storage.getTemplateInfo()); //no need to do anything. The storagepoolmonitor will initiate template sync. } - - return true; } public void setCommand(DownloadCommand _cmd) { diff --git a/server/src/com/cloud/storage/listener/StoragePoolMonitor.java b/server/src/com/cloud/storage/listener/StoragePoolMonitor.java index a184b348a09..c9158cea010 100755 --- a/server/src/com/cloud/storage/listener/StoragePoolMonitor.java +++ b/server/src/com/cloud/storage/listener/StoragePoolMonitor.java @@ -66,7 +66,7 @@ public class StoragePoolMonitor implements Listener { } @Override - public boolean processConnect(HostVO host, StartupCommand cmd) { + public void processConnect(HostVO host, StartupCommand cmd) { if (cmd instanceof StartupRoutingCommand) { StartupRoutingCommand scCmd = (StartupRoutingCommand)cmd; if (scCmd.getHypervisorType() == HypervisorType.XenServer || scCmd.getHypervisorType() == HypervisorType.KVM || @@ -81,7 +81,6 @@ public class StoragePoolMonitor implements Listener { } } } - return true; } diff --git a/server/src/com/cloud/storage/listener/StorageSyncListener.java b/server/src/com/cloud/storage/listener/StorageSyncListener.java index 5d03ad35421..9cf1be2ad89 100755 --- a/server/src/com/cloud/storage/listener/StorageSyncListener.java +++ b/server/src/com/cloud/storage/listener/StorageSyncListener.java @@ -52,8 +52,7 @@ public class StorageSyncListener implements Listener { } @Override - public boolean processConnect(HostVO agent, StartupCommand cmd) { - return false; + public void processConnect(HostVO agent, StartupCommand cmd) { } @Override diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageListener.java b/server/src/com/cloud/storage/secondary/SecondaryStorageListener.java index f5aba0b66f6..7c61710d737 100644 --- a/server/src/com/cloud/storage/secondary/SecondaryStorageListener.java +++ b/server/src/com/cloud/storage/secondary/SecondaryStorageListener.java @@ -29,7 +29,6 @@ import com.cloud.agent.api.StartupStorageCommand; import com.cloud.host.HostVO; import com.cloud.host.Status; import com.cloud.storage.Storage; -import com.cloud.storage.Storage.StorageResourceType; public class SecondaryStorageListener implements Listener { private final static Logger s_logger = Logger.getLogger(SecondaryStorageListener.class); @@ -76,11 +75,10 @@ public class SecondaryStorageListener implements Listener { } @Override - public boolean processConnect(HostVO agent, StartupCommand cmd) { - if(s_logger.isInfoEnabled()) - s_logger.info("Received a host startup notification"); - + public void processConnect(HostVO agent, StartupCommand cmd) { if (cmd instanceof StartupStorageCommand) { + if(s_logger.isInfoEnabled()) + s_logger.info("Received a host startup notification"); StartupStorageCommand ss = (StartupStorageCommand)cmd; if (ss.getResourceType() == Storage.StorageResourceType.SECONDARY_STORAGE) { @@ -89,8 +87,6 @@ public class SecondaryStorageListener implements Listener { _ssVmMgr.generateSetupCommand(agent.getDataCenterId()); } } - - return true; } @Override diff --git a/server/src/com/cloud/storage/upload/UploadListener.java b/server/src/com/cloud/storage/upload/UploadListener.java index 4ed3cd6278d..4cb5ab51c31 100755 --- a/server/src/com/cloud/storage/upload/UploadListener.java +++ b/server/src/com/cloud/storage/upload/UploadListener.java @@ -24,15 +24,13 @@ import com.cloud.agent.api.storage.UploadProgressCommand.RequestType; import com.cloud.async.AsyncJobManager; import com.cloud.async.AsyncJobResult; import com.cloud.async.executor.ExtractJobResultObject; -import com.cloud.event.EventTypes; import com.cloud.event.EventVO; import com.cloud.host.HostVO; import com.cloud.storage.Storage; -import com.cloud.storage.UploadVO; -import com.cloud.storage.dao.UploadDao; import com.cloud.storage.Upload.Status; import com.cloud.storage.Upload.Type; -import com.cloud.storage.upload.UploadMonitorImpl; +import com.cloud.storage.UploadVO; +import com.cloud.storage.dao.UploadDao; import com.cloud.storage.upload.UploadState.UploadEvent; import com.cloud.utils.exception.CloudRuntimeException; @@ -210,9 +208,9 @@ public class UploadListener implements Listener { } @Override - public boolean processConnect(HostVO agent, StartupCommand cmd) { + public void processConnect(HostVO agent, StartupCommand cmd) { if (!(cmd instanceof StartupStorageCommand)) { - return true; + return; } long agentId = agent.getId(); @@ -223,7 +221,6 @@ public class UploadListener implements Listener { { uploadMonitor.handleUploadSync(agentId); } - return true; } @Override diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 81e0819da03..46e3f9063db 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -63,7 +63,6 @@ import com.cloud.agent.api.VmStatsEntry; import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer; import com.cloud.agent.manager.Commands; import com.cloud.alert.AlertManager; -import com.cloud.api.ApiDBUtils; import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.api.commands.AttachVolumeCmd; @@ -3804,18 +3803,18 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM public UserVm createVirtualMachine(DeployVm2Cmd cmd) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException { Account caller = UserContext.current().getAccount(); - Domain domain = _domainDao.findById(cmd.getDomainId()); + AccountVO owner = _accountDao.findById(cmd.getAccountId()); + if (owner == null || owner.getRemoved() != null) { + throw new InvalidParameterValueException("Unable to find account: " + cmd.getAccountId()); + } + + Domain domain = _domainDao.findById(owner.getDomainId()); if (domain == null || domain.getRemoved() != null) { throw new InvalidParameterValueException("Unable to find domain: " + cmd.getDomainId()); } _accountMgr.checkAccess(caller, domain); - AccountVO owner = _accountDao.findById(cmd.getAccountId()); - if (owner == null || owner.getRemoved() != null) { - throw new InvalidParameterValueException("Unable to find account: " + cmd.getAccountId()); - } - DataCenterVO dc = _dcDao.findById(cmd.getZoneId()); if (dc == null) { throw new InvalidParameterValueException("Unable to find zone: " + cmd.getZoneId()); diff --git a/utils/src/com/cloud/utils/SerialVersionUID.java b/utils/src/com/cloud/utils/SerialVersionUID.java index 15ad176a507..a2132767e06 100755 --- a/utils/src/com/cloud/utils/SerialVersionUID.java +++ b/utils/src/com/cloud/utils/SerialVersionUID.java @@ -32,12 +32,6 @@ public interface SerialVersionUID { public static final long CloudRuntimeException = Base | 0x2; public static final long CloudStartupServlet = Base | 0x3; public static final long CloudServiceImpl = Base | 0x4; - public static final long UserRemote = Base | 0x5; - public static final long ServiceOfferingRemote = Base | 0x6; - public static final long VMTemplateRemote = Base | 0x7; - public static final long VMInstanceRemote = Base | 0x8; - public static final long IPAddressRemote = Base | 0x9; - public static final long IPForwardingRemote = Base | 0xa; public static final long UnsupportedVersionException = Base | 0xb; public static final long DataCenterIpAddressPK = Base | 0xc; public static final long UnableToExecuteException = Base | 0xd; @@ -59,4 +53,6 @@ public interface SerialVersionUID { public static final long CloudAuthenticationException = Base | 0x1d; public static final long AsyncCommandQueued = Base | 0x1e; public static final long ResourceUnavailableException = Base | 0x1f; + public static final long ConnectionException = Base | 0x20; + public static final long PermissionDeniedException = Base | 0x21; } diff --git a/utils/src/com/cloud/utils/db/GenericDaoBase.java b/utils/src/com/cloud/utils/db/GenericDaoBase.java index 13baf4066c5..c7afc81eac6 100755 --- a/utils/src/com/cloud/utils/db/GenericDaoBase.java +++ b/utils/src/com/cloud/utils/db/GenericDaoBase.java @@ -803,7 +803,7 @@ public abstract class GenericDaoBase implements Gene protected T findById(ID id, boolean removed, Boolean lock) { StringBuilder sql = new StringBuilder(_selectByIdSql); - if (!removed) { + if (!removed && _removed != null) { sql.append(" AND ").append(_removed.first()); } if (lock != null) {