Skip to content

Commit

Permalink
PR 9346: create VPC with cidrsize
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhouapache committed Jul 5, 2024
1 parent 27a2005 commit 9397b8d
Show file tree
Hide file tree
Showing 13 changed files with 249 additions and 61 deletions.
2 changes: 1 addition & 1 deletion api/src/main/java/com/cloud/network/vpc/VpcService.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public interface VpcService {
* @throws ResourceAllocationException TODO
*/
Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain,
String ip4Dns1, String ip4Dns2, String ip6Dns1, String ip6Dns2, Boolean displayVpc, Integer publicMtu)
String ip4Dns1, String ip4Dns2, String ip6Dns1, String ip6Dns2, Boolean displayVpc, Integer publicMtu, Integer cidrSize)
throws ResourceAllocationException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.cloudstack.api.response.Ipv4SubnetForGuestNetworkResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.cloudstack.api.response.VpcResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.network.Ipv4GuestSubnetNetworkMap;

Expand Down Expand Up @@ -69,6 +70,13 @@ public class ListIpv4SubnetsForGuestNetworkCmd extends BaseListCmd {
description = "UUID of network to which the IPv4 subnet is associated to.")
private Long networkId;

@Parameter(name = ApiConstants.VPC_ID,
type = CommandType.UUID,
entityType = VpcResponse.class,
description = "UUID of VPC to which the IPv4 subnet is associated to.")
private Long vpcId;


/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand All @@ -93,6 +101,10 @@ public Long getNetworkId() {
return networkId;
}

Check warning on line 102 in api/src/main/java/org/apache/cloudstack/api/command/admin/network/ListIpv4SubnetsForGuestNetworkCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/network/ListIpv4SubnetsForGuestNetworkCmd.java#L100-L102

Added lines #L100 - L102 were not covered by tests

public Long getVpcId() {
return vpcId;
}

Check warning on line 106 in api/src/main/java/org/apache/cloudstack/api/command/admin/network/ListIpv4SubnetsForGuestNetworkCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/network/ListIpv4SubnetsForGuestNetworkCmd.java#L104-L106

Added lines #L104 - L106 were not covered by tests

@Override
public void execute() {
List<? extends Ipv4GuestSubnetNetworkMap> subnets = routedIpv4Manager.listIpv4GuestSubnetsForGuestNetwork(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,15 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd implements UserCmd {

private String displayText;

@Parameter(name = ApiConstants.CIDR, type = CommandType.STRING, required = true, description = "the cidr of the VPC. All VPC " +
"guest networks' cidrs should be within this CIDR")
@Parameter(name = ApiConstants.CIDR, type = CommandType.STRING,
description = "the cidr of the VPC. All VPC guest networks' cidrs should be within this CIDR")
private String cidr;

@Parameter(name = ApiConstants.CIDR_SIZE, type = CommandType.INTEGER,
description = "the CIDR size of VPC. For regular users, this is required for VPC with ROUTED mode.",
since = "4.20")
private Integer cidrSize;

@Parameter(name = ApiConstants.VPC_OFF_ID, type = CommandType.UUID, entityType = VpcOfferingResponse.class,
required = true, description = "the ID of the VPC offering")
private Long vpcOffering;
Expand Down Expand Up @@ -141,6 +146,10 @@ public String getCidr() {
return cidr;
}

public Integer getCidrSize() {
return cidrSize;
}

Check warning on line 151 in api/src/main/java/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java#L149-L151

Added lines #L149 - L151 were not covered by tests

public String getDisplayText() {
return StringUtils.isEmpty(displayText) ? vpcName : displayText;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.cloud.network.Network;
import com.cloud.network.rules.FirewallRule;
import com.cloud.network.vpc.Vpc;
import com.cloud.network.vpc.VpcOffering;
import com.cloud.offering.NetworkOffering;
import com.cloud.utils.Pair;
import com.cloud.utils.component.PluggableService;
Expand All @@ -46,12 +47,20 @@

public interface RoutedIpv4Manager extends PluggableService, Configurable {

ConfigKey<Integer> RoutedIPv4NetworkMaxCidrSize = new ConfigKey<>(ConfigKey.CATEGORY_NETWORK, Integer.class,
"routed.ipv4.network.max.cidr.size", "30", "The maximum value of the cidr size for isolated networks in ROUTED mode",
ConfigKey<Integer> RoutedNetworkIPv4MaxCidrSize = new ConfigKey<>(ConfigKey.CATEGORY_NETWORK, Integer.class,
"routed.network.ipv4.max.cidr.size", "30", "The maximum value of the cidr size for isolated networks in ROUTED mode",
true, ConfigKey.Scope.Account);

ConfigKey<Integer> RoutedIPv4NetworkMinCidrSize = new ConfigKey<>(ConfigKey.CATEGORY_NETWORK, Integer.class,
"routed.ipv4.network.min.cidr.size", "24", "The minimum value of the cidr size for isolated networks in ROUTED mode",
ConfigKey<Integer> RoutedNetworkIPv4MinCidrSize = new ConfigKey<>(ConfigKey.CATEGORY_NETWORK, Integer.class,
"routed.network.ipv4.min.cidr.size", "24", "The minimum value of the cidr size for isolated networks in ROUTED mode",
true, ConfigKey.Scope.Account);

ConfigKey<Integer> RoutedVpcIPv4MaxCidrSize = new ConfigKey<>(ConfigKey.CATEGORY_NETWORK, Integer.class,
"routed.ipv4.vpc.max.cidr.size", "29", "The maximum value of the cidr size for VPC in ROUTED mode",
true, ConfigKey.Scope.Account);

ConfigKey<Integer> RoutedVpcIPv4MinCidrSize = new ConfigKey<>(ConfigKey.CATEGORY_NETWORK, Integer.class,
"routed.ipv4.vpc.min.cidr.size", "23", "The minimum value of the cidr size for VPC in ROUTED mode",
true, ConfigKey.Scope.Account);

ConfigKey<Boolean> RoutedIPv4NetworkCidrAutoAllocationEnabled = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED, Boolean.class,
Expand Down Expand Up @@ -92,9 +101,11 @@ public interface RoutedIpv4Manager extends PluggableService, Configurable {
// Methods for internal calls
void getOrCreateIpv4SubnetForGuestNetwork(Network network, String networkCidr);

Ipv4GuestSubnetNetworkMap getOrCreateIpv4SubnetForGuestNetwork(Network network, Integer networkCidrSize);

void getOrCreateIpv4SubnetForVpc(Vpc vpc, String networkCidr);

Ipv4GuestSubnetNetworkMap getOrCreateIpv4SubnetForGuestNetwork(Network network, Integer networkCidrSize);
Ipv4GuestSubnetNetworkMap getOrCreateIpv4SubnetForVpc(Vpc vpc, Integer vpcCidrSize);

void assignIpv4SubnetToNetwork(String cidr, long networkId);

Expand All @@ -119,4 +130,5 @@ public interface RoutedIpv4Manager extends PluggableService, Configurable {

boolean isRoutedVpc(Vpc vpc);

boolean isVpcVirtualRouterGateway(VpcOffering vpcOffering);
}
4 changes: 4 additions & 0 deletions engine/schema/src/main/java/com/cloud/network/vpc/VpcVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ public String getCidr() {
return cidr;
}

public void setCidr(String cidr) {
this.cidr = cidr;
}

Check warning on line 164 in engine/schema/src/main/java/com/cloud/network/vpc/VpcVO.java

View check run for this annotation

Codecov / codecov/patch

engine/schema/src/main/java/com/cloud/network/vpc/VpcVO.java#L162-L164

Added lines #L162 - L164 were not covered by tests

@Override
public long getDomainId() {
return domainId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public Long makeCopyOfVpc(long vpcId, long vpcOfferingId) {

copyOfVpc = _vpcService.createVpc(vpc.getZoneId(), vpcOfferingId, vpc.getAccountId(), vpc.getName(),
vpc.getDisplayText(), vpc.getCidr(), vpc.getNetworkDomain(), vpc.getIp4Dns1(), vpc.getIp4Dns2(),
vpc.getIp6Dns1(), vpc.getIp6Dns2(), vpc.isDisplay(), vpc.getPublicMtu());
vpc.getIp6Dns1(), vpc.getIp6Dns2(), vpc.isDisplay(), vpc.getPublicMtu(), null);

Check warning on line 304 in server/src/main/java/com/cloud/network/NetworkMigrationManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/NetworkMigrationManagerImpl.java#L304

Added line #L304 was not covered by tests

copyOfVpcId = copyOfVpc.getId();
//on resume of migration the uuid will be swapped already. So the copy will have the value of the original vpcid.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,9 @@ void validateNetworkCidrSize(Account caller, Integer cidrSize, String cidr, Netw
}
return;
}
if (ObjectUtils.allNotNull(cidr, cidrSize)) {
throw new InvalidParameterValueException("network cidr and cidr size are mutually exclusive");

Check warning on line 1392 in server/src/main/java/com/cloud/network/NetworkServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/NetworkServiceImpl.java#L1392

Added line #L1392 was not covered by tests
}
if (NetworkOffering.NetworkMode.ROUTED.name().equals(networkOffering.getNetworkMode())
&& routedIpv4Manager.isVirtualRouterGateway(networkOffering)) {
if (cidr != null) {
Expand All @@ -1399,11 +1402,11 @@ void validateNetworkCidrSize(Account caller, Integer cidrSize, String cidr, Netw
if (cidrSize == null) {
throw new InvalidParameterValueException("network cidr or cidr size is required for Isolated networks with ROUTED mode");

Check warning on line 1403 in server/src/main/java/com/cloud/network/NetworkServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/NetworkServiceImpl.java#L1403

Added line #L1403 was not covered by tests
}
Integer maxCidrSize = routedIpv4Manager.RoutedIPv4NetworkMaxCidrSize.valueIn(accountId);
Integer maxCidrSize = routedIpv4Manager.RoutedNetworkIPv4MaxCidrSize.valueIn(accountId);

Check warning on line 1405 in server/src/main/java/com/cloud/network/NetworkServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/NetworkServiceImpl.java#L1405

Added line #L1405 was not covered by tests
if (cidrSize > maxCidrSize) {
throw new InvalidParameterValueException("network cidr size cannot be bigger than maximum cidr size " + maxCidrSize);

Check warning on line 1407 in server/src/main/java/com/cloud/network/NetworkServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/NetworkServiceImpl.java#L1407

Added line #L1407 was not covered by tests
}
Integer minCidrSize = routedIpv4Manager.RoutedIPv4NetworkMinCidrSize.valueIn(accountId);
Integer minCidrSize = routedIpv4Manager.RoutedNetworkIPv4MinCidrSize.valueIn(accountId);

Check warning on line 1409 in server/src/main/java/com/cloud/network/NetworkServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/NetworkServiceImpl.java#L1409

Added line #L1409 was not covered by tests
if (cidrSize < minCidrSize) {
throw new InvalidParameterValueException("network cidr size cannot be smaller than minimum cidr size " + minCidrSize);

Check warning on line 1411 in server/src/main/java/com/cloud/network/NetworkServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/NetworkServiceImpl.java#L1411

Added line #L1411 was not covered by tests
}
Expand Down
79 changes: 63 additions & 16 deletions server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
import org.apache.cloudstack.network.Ipv4GuestSubnetNetworkMap;
import org.apache.cloudstack.network.RoutedIpv4Manager;
import org.apache.cloudstack.query.QueryService;
import org.apache.commons.collections.CollectionUtils;
Expand Down Expand Up @@ -1083,7 +1084,8 @@ public List<Long> getVpcOfferingZones(Long vpcOfferingId) {
@Override
@ActionEvent(eventType = EventTypes.EVENT_VPC_CREATE, eventDescription = "creating vpc", create = true)
public Vpc createVpc(final long zoneId, final long vpcOffId, final long vpcOwnerId, final String vpcName, final String displayText, final String cidr, String networkDomain,
final String ip4Dns1, final String ip4Dns2, final String ip6Dns1, final String ip6Dns2, final Boolean displayVpc, Integer publicMtu) throws ResourceAllocationException {
final String ip4Dns1, final String ip4Dns2, final String ip6Dns1, final String ip6Dns2, final Boolean displayVpc, Integer publicMtu,
final Integer cidrSize) throws ResourceAllocationException {
final Account caller = CallContext.current().getCallingAccount();
final Account owner = _accountMgr.getAccount(vpcOwnerId);

Expand Down Expand Up @@ -1112,6 +1114,9 @@ public Vpc createVpc(final long zoneId, final long vpcOffId, final long vpcOwner
throw ex;
}

// Validate VPC cidr/cidrsize
validateVpcCidrSize(caller, owner.getAccountId(), vpcOff, cidr, cidrSize);

final boolean isRegionLevelVpcOff = vpcOff.isOffersRegionLevelVPC();
if (isRegionLevelVpcOff && networkDomain == null) {
throw new InvalidParameterValueException("Network domain must be specified for region level VPC");
Expand Down Expand Up @@ -1153,21 +1158,68 @@ public Vpc createVpc(final long zoneId, final long vpcOffId, final long vpcOwner

checkVpcDns(vpcOff, ip4Dns1, ip4Dns2, ip6Dns1, ip6Dns2);

// validate network domain
if (!NetUtils.verifyDomainName(networkDomain)) {
throw new InvalidParameterValueException("Invalid network domain. Total length shouldn't exceed 190 chars. Each domain "

Check warning on line 1163 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L1163

Added line #L1163 was not covered by tests
+ "label must be between 1 and 63 characters long, can contain ASCII letters 'a' through 'z', " + "the digits '0' through '9', "
+ "and the hyphen ('-'); can't start or end with \"-\"");
}

final boolean useDistributedRouter = vpcOff.isSupportsDistributedRouter();
final VpcVO vpc = new VpcVO(zoneId, vpcName, displayText, owner.getId(), owner.getDomainId(), vpcOffId, cidr, networkDomain, useDistributedRouter, isRegionLevelVpcOff,
vpcOff.isRedundantRouter(), ip4Dns1, ip4Dns2, ip6Dns1, ip6Dns2);
vpc.setPublicMtu(publicMtu);
vpc.setDisplay(Boolean.TRUE.equals(displayVpc));

if (vpc.getCidr() == null && cidrSize != null) {
// Allocate a CIDR for VPC
Ipv4GuestSubnetNetworkMap subnet = routedIpv4Manager.getOrCreateIpv4SubnetForVpc(vpc, cidrSize);

Check warning on line 1176 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L1176

Added line #L1176 was not covered by tests
if (subnet != null) {
vpc.setCidr(subnet.getSubnet());

Check warning on line 1178 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L1178

Added line #L1178 was not covered by tests
} else {
throw new CloudRuntimeException("Failed to allocate a CIDR with requested size for VPC.");

Check warning on line 1180 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L1180

Added line #L1180 was not covered by tests
}
}

return createVpc(displayVpc, vpc);
}

private void validateVpcCidrSize(Account caller, long accountId, VpcOffering vpcOffering, String cidr, Integer cidrSize) {
if (ObjectUtils.allNull(cidr, cidrSize)) {
throw new InvalidParameterValueException("VPC cidr or cidr size must be specified");

Check warning on line 1189 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L1189

Added line #L1189 was not covered by tests
}
if (ObjectUtils.allNotNull(cidr, cidrSize)) {
throw new InvalidParameterValueException("VPC cidr and cidr size are mutually exclusive");

Check warning on line 1192 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L1192

Added line #L1192 was not covered by tests
}
if (routedIpv4Manager.isVpcVirtualRouterGateway(vpcOffering)) {
if (cidr != null) {
if (!_accountMgr.isRootAdmin(caller.getId())) {
throw new InvalidParameterValueException("Only root admin can set the gateway/netmask of VPC with ROUTED mode");

Check warning on line 1197 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L1197

Added line #L1197 was not covered by tests
}
return;

Check warning on line 1199 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L1199

Added line #L1199 was not covered by tests
}
// verify VPC cidrsize
Integer maxCidrSize = routedIpv4Manager.RoutedVpcIPv4MaxCidrSize.valueIn(accountId);

Check warning on line 1202 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L1202

Added line #L1202 was not covered by tests
if (cidrSize > maxCidrSize) {
throw new InvalidParameterValueException("VPC cidr size cannot be bigger than maximum cidr size " + maxCidrSize);

Check warning on line 1204 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L1204

Added line #L1204 was not covered by tests
}
Integer minCidrSize = routedIpv4Manager.RoutedNetworkIPv4MinCidrSize.valueIn(accountId);

Check warning on line 1206 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L1206

Added line #L1206 was not covered by tests
if (cidrSize < minCidrSize) {
throw new InvalidParameterValueException("VPC cidr size cannot be smaller than minimum cidr size " + minCidrSize);

Check warning on line 1208 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L1208

Added line #L1208 was not covered by tests
}
} else {

Check warning on line 1210 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L1210

Added line #L1210 was not covered by tests
if (cidrSize != null) {
throw new InvalidParameterValueException("VPC cidr size is only applicable on VPC with Routed mode");

Check warning on line 1212 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L1212

Added line #L1212 was not covered by tests
}
}
}

@Override
@ActionEvent(eventType = EventTypes.EVENT_VPC_CREATE, eventDescription = "creating vpc", create = true)
public Vpc createVpc(CreateVPCCmd cmd) throws ResourceAllocationException {
Vpc vpc = createVpc(cmd.getZoneId(), cmd.getVpcOffering(), cmd.getEntityOwnerId(), cmd.getVpcName(), cmd.getDisplayText(),
cmd.getCidr(), cmd.getNetworkDomain(), cmd.getIp4Dns1(), cmd.getIp4Dns2(), cmd.getIp6Dns1(),
cmd.getIp6Dns2(), cmd.isDisplay(), cmd.getPublicMtu());
cmd.getIp6Dns2(), cmd.isDisplay(), cmd.getPublicMtu(), cmd.getCidrSize());

Check warning on line 1222 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L1222

Added line #L1222 was not covered by tests

String sourceNatIP = cmd.getSourceNatIP();
boolean forNsx = isVpcForNsx(vpc);
Expand Down Expand Up @@ -1217,21 +1269,16 @@ private String reserveSourceNatIpForNsxVpc(Account account, DataCenter zone) thr
@DB
protected Vpc createVpc(final Boolean displayVpc, final VpcVO vpc) {
final String cidr = vpc.getCidr();
// Validate CIDR
if (!NetUtils.isValidIp4Cidr(cidr)) {
throw new InvalidParameterValueException("Invalid CIDR specified " + cidr);
}

// cidr has to be RFC 1918 complient
if (!NetUtils.validateGuestCidr(cidr, !ConfigurationManager.AllowNonRFC1918CompliantIPs.value())) {
throw new InvalidParameterValueException("Guest Cidr " + cidr + " is not RFC1918 compliant");
}
if (cidr != null) {
// Validate CIDR
if (!NetUtils.isValidIp4Cidr(cidr)) {
throw new InvalidParameterValueException("Invalid CIDR specified " + cidr);

Check warning on line 1275 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L1275

Added line #L1275 was not covered by tests
}

// validate network domain
if (!NetUtils.verifyDomainName(vpc.getNetworkDomain())) {
throw new InvalidParameterValueException("Invalid network domain. Total length shouldn't exceed 190 chars. Each domain "
+ "label must be between 1 and 63 characters long, can contain ASCII letters 'a' through 'z', " + "the digits '0' through '9', "
+ "and the hyphen ('-'); can't start or end with \"-\"");
// cidr has to be RFC 1918 complient
if (!NetUtils.validateGuestCidr(cidr, !ConfigurationManager.AllowNonRFC1918CompliantIPs.value())) {
throw new InvalidParameterValueException("Guest Cidr " + cidr + " is not RFC1918 compliant");

Check warning on line 1280 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L1280

Added line #L1280 was not covered by tests
}
}

// get or create Ipv4 subnet for ROUTED VPC
Expand Down
Loading

0 comments on commit 9397b8d

Please sign in to comment.