From 15a316484ede7e272e17a8b0f9af61731b01afbe Mon Sep 17 00:00:00 2001 From: alena Date: Wed, 3 Nov 2010 11:32:45 -0700 Subject: [PATCH] Fixed deleteZone API - used to return empty response instead of success=true/false --- .../configuration/ConfigurationManager.java | 2 +- .../ConfigurationManagerImpl.java | 23 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/server/src/com/cloud/configuration/ConfigurationManager.java b/server/src/com/cloud/configuration/ConfigurationManager.java index c95e1d30f5d..ed4c5046a06 100644 --- a/server/src/com/cloud/configuration/ConfigurationManager.java +++ b/server/src/com/cloud/configuration/ConfigurationManager.java @@ -232,7 +232,7 @@ public interface ConfigurationManager extends Manager { * @param userId * @param zoneId */ - void deleteZone(DeleteZoneCmd cmd); + boolean deleteZone(DeleteZoneCmd cmd); /** * Associates an ip address list to an account. The list of ip addresses are all addresses associated with the given vlan id. diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index daa6fee8182..c52fc65caeb 100644 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -785,7 +785,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager { @Override @DB - public void deleteZone(DeleteZoneCmd cmd) { + public boolean deleteZone(DeleteZoneCmd cmd) { Long userId = UserContext.current().getUserId(); Long zoneId = cmd.getId(); @@ -803,12 +803,23 @@ public class ConfigurationManagerImpl implements ConfigurationManager { DataCenterVO zone = _zoneDao.findById(zoneId); - _zoneDao.expunge(zoneId); + boolean success = _zoneDao.expunge(zoneId); - // Delete vNet - _zoneDao.deleteVnet(zoneId); - - saveConfigurationEvent(userId, null, EventTypes.EVENT_ZONE_DELETE, "Successfully deleted zone with name: " + zone.getName() + ".", "dcId=" + zoneId); + try { + // Delete vNet + _zoneDao.deleteVnet(zoneId); + } catch (Exception ex) { + s_logger.error("Failed to delete zone " + zoneId); + throw new CloudRuntimeException("Failed to delete zone " + zoneId); + } + + if (success){ + saveConfigurationEvent(userId, null, EventTypes.EVENT_ZONE_DELETE, "Successfully deleted zone with name: " + zone.getName() + ".", "dcId=" + zoneId); + return true; + } else{ + return false; + } + } @Override