Skip to content

Commit 84a0250

Browse files
Validate Zone IPv6 DNS
Prevent deploying IPv6 network if zone has no IPv6 DNS configured.
1 parent 0d4f67a commit 84a0250

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -726,10 +726,10 @@ public NicSecondaryIp allocateSecondaryGuestIP(final long nicId, IpAddresses req
726726
String ip6addr = null;
727727
//Isolated network can exist in Basic zone only, so no need to verify the zone type
728728
if (network.getGuestType() == Network.GuestType.Isolated) {
729-
if ((ipv4Address != null || NetUtils.isIpv4(network.getGateway()) && org.apache.commons.lang3.StringUtils.isBlank(ipv6Address))) {
729+
if ((ipv4Address != null || NetUtils.isIpv4(network.getGateway()) && isBlank(ipv6Address))) {
730730
ipaddr = _ipAddrMgr.allocateGuestIP(network, ipv4Address);
731731
}
732-
if (ipv6Address != null) {
732+
if (isNotBlank(ipv6Address)) {
733733
ip6addr = ipv6AddrMgr.allocateGuestIpv6(network, ipv6Address);
734734
}
735735
} else if (network.getGuestType() == Network.GuestType.Shared) {
@@ -763,7 +763,7 @@ public NicSecondaryIp allocateSecondaryGuestIP(final long nicId, IpAddresses req
763763
return null;
764764
}
765765

766-
if (ipaddr != null || ip6addr != null) {
766+
if (isNotBlank(ipaddr) || isNotBlank(ip6addr)) {
767767
// we got the ip addr so up the nics table and secodary ip
768768
final String ip4AddrFinal = ipaddr;
769769
final String ip6AddrFinal = ip6addr;
@@ -1270,6 +1270,10 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapac
12701270
}
12711271
_networkModel.checkIp6Parameters(startIPv6, endIPv6, ip6Gateway, ip6Cidr);
12721272

1273+
if(isBlank(zone.getIp6Dns1()) && isBlank(zone.getIp6Dns2())) {
1274+
throw new InvalidParameterValueException("Can only create IPv6 network if the zone has IPv6 DNS! Please configure the zone IPv6 DNS1 and/or IPv6 DNS2.");
1275+
}
1276+
12731277
if (zone.getNetworkType() != NetworkType.Advanced || ntwkOff.getGuestType() != Network.GuestType.Shared) {
12741278
throw new InvalidParameterValueException("Can only support create IPv6 network with advance shared network!");
12751279
}
@@ -2749,7 +2753,7 @@ private void verifyAlreadyMigratedTiers(long migratedVpcId, long vpcOfferingId,
27492753
for (Network tier : migratedTiers) {
27502754
String tierNetworkOfferingUuid = networkToOffering.get(tier.getUuid());
27512755

2752-
if (!StringUtils.isNotBlank(tierNetworkOfferingUuid)) {
2756+
if (!isNotBlank(tierNetworkOfferingUuid)) {
27532757
throwInvalidIdException("Failed to resume migrating VPC as the specified tierNetworkOfferings is not complete", String.valueOf(tier.getUuid()), "networkUuid");
27542758
}
27552759

0 commit comments

Comments
 (0)