Skip to content

Commit 216bea1

Browse files
ipv6: disable IPv6-only shared network with VR (#5810)
* ipv6: disable IPv6-only shared network with VR * Update #5810: import org.apache.commons.lang3.StringUtils * Update #5810: do not import org.apache.commons.lang3.StringUtils * Update server/src/main/java/com/cloud/network/NetworkServiceImpl.java * Update engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com>
1 parent 223bc11 commit 216bea1

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2642,7 +2642,7 @@ private Network createGuestNetwork(final long networkOfferingId, final String na
26422642
&& !_networkModel.areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat)));
26432643
if (cidr == null && ip6Cidr == null && cidrRequired) {
26442644
if (ntwkOff.getGuestType() == GuestType.Shared) {
2645-
throw new InvalidParameterValueException("StartIp/endIp/gateway/netmask are required when create network of" + " type " + Network.GuestType.Shared);
2645+
throw new InvalidParameterValueException(String.format("Gateway/netmask are required when creating %s networks.", Network.GuestType.Shared));
26462646
} else {
26472647
throw new InvalidParameterValueException("gateway/netmask are required when create network of" + " type " + GuestType.Isolated + " with service " + Service.SourceNat.getName() + " disabled");
26482648
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,8 +1252,8 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapac
12521252
}
12531253
}
12541254

1255-
boolean ipv4 = true, ipv6 = false;
1256-
if (startIP != null) {
1255+
boolean ipv4 = false, ipv6 = false;
1256+
if (org.apache.commons.lang3.StringUtils.isNoneBlank(gateway, netmask)) {
12571257
ipv4 = true;
12581258
}
12591259
if (isNotBlank(ip6Cidr) && isNotBlank(ip6Gateway)) {
@@ -1297,14 +1297,10 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapac
12971297
} else if (!NetUtils.isValidIp4(endIP)) {
12981298
throw new InvalidParameterValueException("Invalid format for the endIp parameter");
12991299
}
1300-
}
1301-
1302-
if (startIP != null && endIP != null) {
13031300
if (!(gateway != null && netmask != null)) {
13041301
throw new InvalidParameterValueException("gateway and netmask should be defined when startIP/endIP are passed in");
13051302
}
13061303
}
1307-
13081304
if (gateway != null && netmask != null) {
13091305
if (NetUtils.isNetworkorBroadcastIP(gateway, netmask)) {
13101306
if (s_logger.isDebugEnabled()) {
@@ -1338,6 +1334,10 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapac
13381334
if(isBlank(zone.getIp6Dns1()) && isBlank(zone.getIp6Dns2())) {
13391335
throw new InvalidParameterValueException("Can only create IPv6 network if the zone has IPv6 DNS! Please configure the zone IPv6 DNS1 and/or IPv6 DNS2.");
13401336
}
1337+
1338+
if (!ipv4 && ntwkOff.getGuestType() == GuestType.Shared && _networkModel.isProviderForNetworkOffering(Provider.VirtualRouter, networkOfferingId)) {
1339+
throw new InvalidParameterValueException("Currently IPv6-only Shared network with Virtual Router provider is not supported.");
1340+
}
13411341
}
13421342

13431343
validateRouterIps(routerIp, routerIpv6, startIP, endIP, gateway, netmask, startIPv6, endIPv6, ip6Cidr);

0 commit comments

Comments
 (0)