diff --git a/server/src/com/cloud/api/commands/DeleteZoneCmd.java b/server/src/com/cloud/api/commands/DeleteZoneCmd.java index d28dee505fd..0130320c0e2 100644 --- a/server/src/com/cloud/api/commands/DeleteZoneCmd.java +++ b/server/src/com/cloud/api/commands/DeleteZoneCmd.java @@ -25,22 +25,19 @@ import java.util.Map; import org.apache.log4j.Logger; import com.cloud.api.BaseCmd; +import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; +import com.cloud.api.BaseCmd.Manager; import com.cloud.dc.DataCenterVO; import com.cloud.user.User; import com.cloud.utils.Pair; +@Implementation(method="deleteZone", manager=Manager.ConfigManager) public class DeleteZoneCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteZoneCmd.class.getName()); private static final String s_name = "deletezoneresponse"; - private static final List> s_properties = new ArrayList>(); - - static { - s_properties.add(new Pair(BaseCmd.Properties.ID, Boolean.TRUE)); - s_properties.add(new Pair(BaseCmd.Properties.USER_ID, Boolean.FALSE)); - } ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// @@ -66,35 +63,39 @@ public class DeleteZoneCmd extends BaseCmd { public String getName() { return s_name; } - public List> getProperties() { - return s_properties; - } - @Override - public List> execute(Map params) { - Long zoneId = (Long) params.get(BaseCmd.Properties.ID.getName()); - Long userId = (Long)params.get(BaseCmd.Properties.USER_ID.getName()); - - if (userId == null) { - userId = Long.valueOf(User.UID_SYSTEM); - } - - //verify input parameters - DataCenterVO zone = getManagementServer().findDataCenterById(zoneId); - if (zone == null) { - throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find zone by id " + zoneId); - } +// @Override +// public List> execute(Map params) { +// Long zoneId = (Long) params.get(BaseCmd.Properties.ID.getName()); +// Long userId = (Long)params.get(BaseCmd.Properties.USER_ID.getName()); +// +// if (userId == null) { +// userId = Long.valueOf(User.UID_SYSTEM); +// } +// +// //verify input parameters +// DataCenterVO zone = getManagementServer().findDataCenterById(zoneId); +// if (zone == null) { +// throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find zone by id " + zoneId); +// } +// +// try { +// getManagementServer().deleteZone(userId, zoneId); +// } catch (Exception ex) { +// s_logger.error("Exception deleting zone", ex); +// throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage()); +// } +// +// List> returnValues = new ArrayList>(); +// returnValues.add(new Pair(BaseCmd.Properties.SUCCESS.getName(), "true")); +// +// return returnValues; +// } - try { - getManagementServer().deleteZone(userId, zoneId); - } catch (Exception ex) { - s_logger.error("Exception deleting zone", ex); - throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage()); - } - List> returnValues = new ArrayList>(); - returnValues.add(new Pair(BaseCmd.Properties.SUCCESS.getName(), "true")); - - return returnValues; - } + @Override + public String getResponse() { + // TODO Auto-generated method stub + return null; + } } diff --git a/server/src/com/cloud/configuration/ConfigurationManager.java b/server/src/com/cloud/configuration/ConfigurationManager.java index b848c90f40d..2d34e9624da 100644 --- a/server/src/com/cloud/configuration/ConfigurationManager.java +++ b/server/src/com/cloud/configuration/ConfigurationManager.java @@ -27,6 +27,7 @@ import com.cloud.api.commands.DeleteDiskOfferingCmd; import com.cloud.api.commands.DeletePodCmd; import com.cloud.api.commands.DeleteServiceOfferingCmd; import com.cloud.api.commands.DeleteVlanIpRangeCmd; +import com.cloud.api.commands.DeleteZoneCmd; import com.cloud.api.commands.UpdateCfgCmd; import com.cloud.api.commands.UpdateDiskOfferingCmd; import com.cloud.api.commands.UpdatePodCmd; @@ -207,7 +208,7 @@ public interface ConfigurationManager extends Manager { * @param userId * @param zoneId */ - void deleteZone(long userId, long zoneId) throws InvalidParameterValueException, InternalErrorException; + void deleteZone(DeleteZoneCmd cmd) throws InvalidParameterValueException, InternalErrorException; /** * Adds a VLAN to the database, along with an IP address range. Can add three types of VLANs: (1) zone-wide VLANs on the virtual public network (2) pod-wide direct attached VLANs (3) account-specific direct attached VLANs diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 084ccdad868..63acfa8f528 100644 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -41,6 +41,7 @@ import com.cloud.api.commands.DeleteDiskOfferingCmd; import com.cloud.api.commands.DeletePodCmd; import com.cloud.api.commands.DeleteServiceOfferingCmd; import com.cloud.api.commands.DeleteVlanIpRangeCmd; +import com.cloud.api.commands.DeleteZoneCmd; import com.cloud.api.commands.UpdateCfgCmd; import com.cloud.api.commands.UpdateDiskOfferingCmd; import com.cloud.api.commands.UpdatePodCmd; @@ -735,7 +736,15 @@ public class ConfigurationManagerImpl implements ConfigurationManager { } @DB - public void deleteZone(long userId, long zoneId) throws InvalidParameterValueException, InternalErrorException { + public void deleteZone(DeleteZoneCmd cmd) throws InvalidParameterValueException, InternalErrorException { + + Long userId = UserContext.current().getUserId(); + Long zoneId = cmd.getId(); + + if (userId == null) { + userId = Long.valueOf(User.UID_SYSTEM); + } + // Make sure the zone exists if (!validZone(zoneId)) { throw new InvalidParameterValueException("A zone with ID: " + zoneId + " does not exist."); diff --git a/server/src/com/cloud/server/ManagementServer.java b/server/src/com/cloud/server/ManagementServer.java index 5f00a212ad2..ef1d64a35a5 100644 --- a/server/src/com/cloud/server/ManagementServer.java +++ b/server/src/com/cloud/server/ManagementServer.java @@ -991,7 +991,7 @@ public interface ManagementServer { * @param userId * @param zoneId */ - void deleteZone(long userId, Long zoneId) throws InvalidParameterValueException, InternalErrorException; +// void deleteZone(long userId, Long zoneId) throws InvalidParameterValueException, InternalErrorException; /** * Change a pod's private IP range diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index e546c96bff6..c037c65a3f1 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -4370,10 +4370,10 @@ public class ManagementServerImpl implements ManagementServer { return _configMgr.createZone(userId, zoneName, dns1, dns2, internalDns1, internalDns2, vnetRange, guestCidr); } - @Override - public void deleteZone(long userId, Long zoneId) throws InvalidParameterValueException, InternalErrorException { - _configMgr.deleteZone(userId, zoneId); - } +// @Override +// public void deleteZone(long userId, Long zoneId) throws InvalidParameterValueException, InternalErrorException { +// _configMgr.deleteZone(userId, zoneId); +// } @Override public String changePrivateIPRange(boolean add, Long podId, String startIP, String endIP) throws InvalidParameterValueException {