CLOUDSTACK-3239: Delete Traffic Monitor directly without going through maintenance state
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9adec154 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9adec154 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9adec154 Branch: refs/heads/master-6-17-stable Commit: 9adec1548f2bd571463a239ec9e156bbef970563 Parents: 166622f Author: Kishan Kavala <[email protected]> Authored: Thu Jun 27 17:34:10 2013 +0530 Committer: Kishan Kavala <[email protected]> Committed: Fri Jun 28 11:04:58 2013 +0530 ---------------------------------------------------------------------- .../cloud/network/NetworkUsageManagerImpl.java | 29 ++++++++++---------- 1 file changed, 15 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9adec154/server/src/com/cloud/network/NetworkUsageManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/NetworkUsageManagerImpl.java b/server/src/com/cloud/network/NetworkUsageManagerImpl.java index 80f898b..dde77c4 100755 --- a/server/src/com/cloud/network/NetworkUsageManagerImpl.java +++ b/server/src/com/cloud/network/NetworkUsageManagerImpl.java @@ -188,20 +188,14 @@ public class NetworkUsageManagerImpl extends ManagerBase implements NetworkUsage @Override public boolean deleteTrafficMonitor(DeleteTrafficMonitorCmd cmd) { long hostId = cmd.getId(); - User caller = _accountMgr.getActiveUser(UserContext.current().getCallerUserId()); HostVO trafficMonitor = _hostDao.findById(hostId); if (trafficMonitor == null) { throw new InvalidParameterValueException("Could not find an traffic monitor with ID: " + hostId); } - try { - if (_resourceMgr.maintain(hostId) && _resourceMgr.deleteHost(hostId, false, false)) { - return true; - } else { - return false; - } - } catch (AgentUnavailableException e) { - s_logger.debug(e); + if (_resourceMgr.deleteHost(hostId, false, false)) { + return true; + } else { return false; } } @@ -528,13 +522,20 @@ public class NetworkUsageManagerImpl extends ManagerBase implements NetworkUsage return host; } - @Override + @Override public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException { - if(host.getType() != Host.Type.TrafficMonitor){ - return null; - } + if(host.getType() != Host.Type.TrafficMonitor){ + return null; + } + + long hostId = host.getId(); + _agentMgr.disconnectWithoutInvestigation(hostId, Status.Event.Remove); + _detailsDao.deleteDetails(hostId); + host.setGuid(null); + _hostDao.update(hostId, host); + _hostDao.remove(hostId); + return new DeleteHostAnswer(false); - return new DeleteHostAnswer(true); } }
