mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-15 18:12:35 +01:00
Changed create/updatePod to accept netmask/gateway instead of cidr
This commit is contained in:
parent
bb5d00fb7f
commit
31b3b79f5a
@ -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() {
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user