diff --git a/api/src/com/cloud/api/commands/CreatePodCmd.java b/api/src/com/cloud/api/commands/CreatePodCmd.java index 4bdfe5b27ed..4177e3f8b3f 100644 --- a/api/src/com/cloud/api/commands/CreatePodCmd.java +++ b/api/src/com/cloud/api/commands/CreatePodCmd.java @@ -38,8 +38,8 @@ public class CreatePodCmd extends BaseCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name=ApiConstants.CIDR, type=CommandType.STRING, required=true, description="the CIDR notation for the base IP address of the Pod") - private String cidr; + @Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, required=true, description="the netmask for the Pod") + private String netmask; @Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address for the Pod") private String endIp; @@ -61,8 +61,8 @@ public class CreatePodCmd extends BaseCmd { /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// - public String getCidr() { - return cidr; + public String getNetmask() { + return netmask; } public String getEndIp() { diff --git a/api/src/com/cloud/api/commands/UpdatePodCmd.java b/api/src/com/cloud/api/commands/UpdatePodCmd.java index bd7c858f65f..df132eac885 100644 --- a/api/src/com/cloud/api/commands/UpdatePodCmd.java +++ b/api/src/com/cloud/api/commands/UpdatePodCmd.java @@ -38,8 +38,8 @@ public class UpdatePodCmd extends BaseCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name=ApiConstants.CIDR, type=CommandType.STRING, description="the CIDR notation for the base IP address of the Pod") - private String cidr; + @Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, description="the netmask of the Pod") + private String netmask; @Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address for the Pod") private String endIp; @@ -60,8 +60,8 @@ public class UpdatePodCmd extends BaseCmd { /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// - public String getCidr() { - return cidr; + public String getNetmask() { + return netmask; } public String getEndIp() { diff --git a/api/src/com/cloud/api/response/PodResponse.java b/api/src/com/cloud/api/response/PodResponse.java index da9cb9a4f5b..87d4e262f03 100644 --- a/api/src/com/cloud/api/response/PodResponse.java +++ b/api/src/com/cloud/api/response/PodResponse.java @@ -36,8 +36,8 @@ public class PodResponse extends BaseResponse { @SerializedName("gateway") @Param(description="the gateway of the Pod") private String gateway; - @SerializedName("cidr") @Param(description="the CIDR notation for the base IP address of the Pod") - private String cidr; + @SerializedName("netmask") @Param(description="the netmask of the Pod") + private String netmask; @SerializedName("startip") @Param(description="the starting IP for the Pod") private String startIp; @@ -85,12 +85,12 @@ public class PodResponse extends BaseResponse { this.gateway = gateway; } - public String getCidr() { - return cidr; + public String getNetmask() { + return netmask; } - public void setCidr(String cidr) { - this.cidr = cidr; + public void setNetmask(String netmask) { + this.netmask = netmask; } public String getStartIp() { diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index e6934ae0386..c301a174e1f 100644 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -836,7 +836,7 @@ public class ApiResponseHelper implements ResponseGenerator { podResponse.setName(pod.getName()); podResponse.setZoneId(pod.getDataCenterId()); podResponse.setZoneName(PodZoneConfig.getZoneName(pod.getDataCenterId())); - podResponse.setCidr(pod.getCidrAddress() + "/" + pod.getCidrSize()); + podResponse.setNetmask(NetUtils.getCidrNetmask(pod.getCidrSize())); podResponse.setStartIp(ipRange[0]); podResponse.setEndIp(((ipRange.length > 1) && (ipRange[1] != null)) ? ipRange[1] : ""); podResponse.setGateway(pod.getGateway()); diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index b34daa5cadb..4f389d37934 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -479,11 +479,15 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura public Pod editPod(UpdatePodCmd cmd) { - //Input validation - String cidr = cmd.getCidr(); + //Input validation String startIp = cmd.getStartIp(); String endIp = cmd.getEndIp(); String gateway = cmd.getGateway(); + String netmask = cmd.getNetmask(); + String cidr = null; + if (gateway != null && netmask != null) { + cidr = NetUtils.ipAndNetMaskToCidr(gateway, netmask); + } Long id = cmd.getId(); String name = cmd.getPodName(); Long userId = UserContext.current().getUserId(); @@ -589,12 +593,13 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura @Override public Pod createPod(CreatePodCmd cmd) { - String cidr = cmd.getCidr(); String endIp = cmd.getEndIp(); String gateway = cmd.getGateway(); String name = cmd.getPodName(); String startIp = cmd.getStartIp(); + String netmask = cmd.getNetmask(); Long zoneId = cmd.getZoneId(); + String cidr = NetUtils.ipAndNetMaskToCidr(gateway, netmask); //verify input parameters DataCenterVO zone = _zoneDao.findById(zoneId);