Changed create/updatePod to accept netmask/gateway instead of cidr

This commit is contained in:
alena 2010-12-06 10:03:52 -08:00
parent bb5d00fb7f
commit 31b3b79f5a
5 changed files with 23 additions and 18 deletions

View File

@ -38,8 +38,8 @@ public class CreatePodCmd extends BaseCmd {
//////////////// API parameters ///////////////////// //////////////// API parameters /////////////////////
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
@Parameter(name=ApiConstants.CIDR, type=CommandType.STRING, required=true, description="the CIDR notation for the base IP address of the Pod") @Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, required=true, description="the netmask for the Pod")
private String cidr; private String netmask;
@Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address for the Pod") @Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address for the Pod")
private String endIp; private String endIp;
@ -61,8 +61,8 @@ public class CreatePodCmd extends BaseCmd {
/////////////////// Accessors /////////////////////// /////////////////// Accessors ///////////////////////
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
public String getCidr() { public String getNetmask() {
return cidr; return netmask;
} }
public String getEndIp() { public String getEndIp() {

View File

@ -38,8 +38,8 @@ public class UpdatePodCmd extends BaseCmd {
//////////////// API parameters ///////////////////// //////////////// API parameters /////////////////////
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
@Parameter(name=ApiConstants.CIDR, type=CommandType.STRING, description="the CIDR notation for the base IP address of the Pod") @Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, description="the netmask of the Pod")
private String cidr; private String netmask;
@Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address for the Pod") @Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address for the Pod")
private String endIp; private String endIp;
@ -60,8 +60,8 @@ public class UpdatePodCmd extends BaseCmd {
/////////////////// Accessors /////////////////////// /////////////////// Accessors ///////////////////////
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
public String getCidr() { public String getNetmask() {
return cidr; return netmask;
} }
public String getEndIp() { public String getEndIp() {

View File

@ -36,8 +36,8 @@ public class PodResponse extends BaseResponse {
@SerializedName("gateway") @Param(description="the gateway of the Pod") @SerializedName("gateway") @Param(description="the gateway of the Pod")
private String gateway; private String gateway;
@SerializedName("cidr") @Param(description="the CIDR notation for the base IP address of the Pod") @SerializedName("netmask") @Param(description="the netmask of the Pod")
private String cidr; private String netmask;
@SerializedName("startip") @Param(description="the starting IP for the Pod") @SerializedName("startip") @Param(description="the starting IP for the Pod")
private String startIp; private String startIp;
@ -85,12 +85,12 @@ public class PodResponse extends BaseResponse {
this.gateway = gateway; this.gateway = gateway;
} }
public String getCidr() { public String getNetmask() {
return cidr; return netmask;
} }
public void setCidr(String cidr) { public void setNetmask(String netmask) {
this.cidr = cidr; this.netmask = netmask;
} }
public String getStartIp() { public String getStartIp() {

View File

@ -836,7 +836,7 @@ public class ApiResponseHelper implements ResponseGenerator {
podResponse.setName(pod.getName()); podResponse.setName(pod.getName());
podResponse.setZoneId(pod.getDataCenterId()); podResponse.setZoneId(pod.getDataCenterId());
podResponse.setZoneName(PodZoneConfig.getZoneName(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.setStartIp(ipRange[0]);
podResponse.setEndIp(((ipRange.length > 1) && (ipRange[1] != null)) ? ipRange[1] : ""); podResponse.setEndIp(((ipRange.length > 1) && (ipRange[1] != null)) ? ipRange[1] : "");
podResponse.setGateway(pod.getGateway()); podResponse.setGateway(pod.getGateway());

View File

@ -480,10 +480,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
{ {
//Input validation //Input validation
String cidr = cmd.getCidr();
String startIp = cmd.getStartIp(); String startIp = cmd.getStartIp();
String endIp = cmd.getEndIp(); String endIp = cmd.getEndIp();
String gateway = cmd.getGateway(); 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(); Long id = cmd.getId();
String name = cmd.getPodName(); String name = cmd.getPodName();
Long userId = UserContext.current().getUserId(); Long userId = UserContext.current().getUserId();
@ -589,12 +593,13 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
@Override @Override
public Pod createPod(CreatePodCmd cmd) { public Pod createPod(CreatePodCmd cmd) {
String cidr = cmd.getCidr();
String endIp = cmd.getEndIp(); String endIp = cmd.getEndIp();
String gateway = cmd.getGateway(); String gateway = cmd.getGateway();
String name = cmd.getPodName(); String name = cmd.getPodName();
String startIp = cmd.getStartIp(); String startIp = cmd.getStartIp();
String netmask = cmd.getNetmask();
Long zoneId = cmd.getZoneId(); Long zoneId = cmd.getZoneId();
String cidr = NetUtils.ipAndNetMaskToCidr(gateway, netmask);
//verify input parameters //verify input parameters
DataCenterVO zone = _zoneDao.findById(zoneId); DataCenterVO zone = _zoneDao.findById(zoneId);