mirror of https://github.com/apache/cloudstack.git
createNetwork command accepts netmask/gateway instead of cidr. Also return start/endIp in the createNetwork response.
This commit is contained in:
parent
2e5fc3d41f
commit
0dbd21fe23
|
|
@ -56,9 +56,6 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, description="the gateway of the VLAN IP range")
|
||||
private String gateway;
|
||||
|
||||
@Parameter(name=ApiConstants.CIDR, type=CommandType.STRING, description="the cidr of the VLAN IP range")
|
||||
private String cidr;
|
||||
|
||||
@Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, description="the netmask of the VLAN IP range")
|
||||
private String netmask;
|
||||
|
||||
|
|
@ -99,10 +96,6 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||
return gateway;
|
||||
}
|
||||
|
||||
public String getCidr() {
|
||||
return cidr;
|
||||
}
|
||||
|
||||
public String getVlan() {
|
||||
return vlan;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,14 @@ public class NetworkResponse extends BaseResponse{
|
|||
private String gateway;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("cidr")
|
||||
private String cidr;
|
||||
@SerializedName("netmask")
|
||||
private String netmask;
|
||||
|
||||
@SerializedName("startip") @Param(description="the start ip of the network")
|
||||
private String startIp;
|
||||
|
||||
@SerializedName("endip") @Param(description="the end ip of the network")
|
||||
private String endIp;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("zoneid")
|
||||
|
|
@ -51,9 +57,6 @@ public class NetworkResponse extends BaseResponse{
|
|||
@SerializedName("isshared")
|
||||
private Boolean isShared;
|
||||
|
||||
@SerializedName("isdefault") @Param(description="true if network offering is default, false otherwise")
|
||||
private Boolean isDefault;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("state")
|
||||
private String state;
|
||||
|
|
@ -83,6 +86,8 @@ public class NetworkResponse extends BaseResponse{
|
|||
|
||||
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain id associated with the network")
|
||||
private Long domainId;
|
||||
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
|
@ -124,12 +129,12 @@ public class NetworkResponse 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 Long getZoneId() {
|
||||
|
|
@ -243,4 +248,20 @@ public class NetworkResponse extends BaseResponse{
|
|||
public void setIsShared(Boolean isShared) {
|
||||
this.isShared = isShared;
|
||||
}
|
||||
|
||||
public String getStartIp() {
|
||||
return startIp;
|
||||
}
|
||||
|
||||
public void setStartIp(String startIp) {
|
||||
this.startIp = startIp;
|
||||
}
|
||||
|
||||
public String getEndIp() {
|
||||
return endIp;
|
||||
}
|
||||
|
||||
public void setEndIp(String endIp) {
|
||||
this.endIp = endIp;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.cloud.dc.AccountVlanMapVO;
|
|||
import com.cloud.dc.ClusterVO;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.dc.VlanVO;
|
||||
import com.cloud.dc.dao.AccountVlanMapDao;
|
||||
import com.cloud.dc.dao.ClusterDao;
|
||||
|
|
@ -32,6 +33,7 @@ import com.cloud.network.NetworkManager;
|
|||
import com.cloud.network.NetworkRuleConfigVO;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.LoadBalancerDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkRuleConfigDao;
|
||||
import com.cloud.network.security.NetworkGroup;
|
||||
import com.cloud.network.security.NetworkGroupManager;
|
||||
|
|
@ -495,4 +497,8 @@ public class ApiDBUtils {
|
|||
return _networkOfferingDao.findByIdIncludingRemoved(networkOfferingId);
|
||||
}
|
||||
|
||||
public static List<? extends Vlan> listVlanByNetworkId(long networkId) {
|
||||
return _vlanDao.listVlansByNetworkId(networkId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ import com.cloud.user.UserAccount;
|
|||
import com.cloud.user.UserContext;
|
||||
import com.cloud.user.UserStatisticsVO;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.ConsoleProxyVO;
|
||||
import com.cloud.vm.InstanceGroup;
|
||||
import com.cloud.vm.InstanceGroupVO;
|
||||
|
|
@ -2328,8 +2329,20 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
if (network.getGuestType() != null) {
|
||||
response.setType(network.getGuestType().name());
|
||||
}
|
||||
response.setGateway(network.getGateway());
|
||||
response.setCidr(network.getCidr());
|
||||
|
||||
//get start ip and end ip of corresponding vlan
|
||||
List<? extends Vlan> vlan= ApiDBUtils.listVlanByNetworkId(network.getId());
|
||||
if (vlan != null && !vlan.isEmpty()) {
|
||||
Vlan singleVlan = vlan.get(0);
|
||||
String ipRange = singleVlan.getIpRange();
|
||||
String[] range = ipRange.split("-");
|
||||
response.setStartIp(range[0]);
|
||||
response.setEndIp(range[1]);
|
||||
response.setGateway(singleVlan.getVlanGateway());
|
||||
response.setNetmask(singleVlan.getVlanNetmask());
|
||||
}
|
||||
|
||||
|
||||
response.setZoneId(network.getDataCenterId());
|
||||
|
||||
//populate network offering information
|
||||
|
|
|
|||
|
|
@ -1803,10 +1803,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
Long zoneId = cmd.getZoneId();
|
||||
Long podId = cmd.getPodId();
|
||||
String gateway = cmd.getGateway();
|
||||
String cidr = cmd.getCidr();
|
||||
String startIP = cmd.getStartIp();
|
||||
String endIP = cmd.getEndIp();
|
||||
String vlanNetmask = cmd.getNetmask();
|
||||
String cidr = NetUtils.ipAndNetMaskToCidr(gateway, vlanNetmask);
|
||||
String accountName = cmd.getAccountName();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String vlanId = cmd.getVlan();
|
||||
|
|
@ -1899,7 +1899,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
} catch (Exception ex) {
|
||||
s_logger.warn("Unexpected exception while creating network ", ex);
|
||||
txn.rollback();
|
||||
}finally {
|
||||
} finally {
|
||||
txn.close();
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue