This is an automated email from the ASF dual-hosted git repository.

sureshanaparti pushed a commit to branch 4.16
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.16 by this push:
     new 216bea1  ipv6: disable IPv6-only shared network with VR (#5810)
216bea1 is described below

commit 216bea197829de7129fd833403da3270db6e3145
Author: Wei Zhou <[email protected]>
AuthorDate: Wed Jan 12 09:03:35 2022 +0100

    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 
<[email protected]>
---
 .../cloudstack/engine/orchestration/NetworkOrchestrator.java |  2 +-
 .../src/main/java/com/cloud/network/NetworkServiceImpl.java  | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git 
a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
 
b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
index 7e206ff..6909c5b 100644
--- 
a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
+++ 
b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
@@ -2642,7 +2642,7 @@ public class NetworkOrchestrator extends ManagerBase 
implements NetworkOrchestra
                 && 
!_networkModel.areServicesSupportedByNetworkOffering(ntwkOff.getId(), 
Service.SourceNat)));
         if (cidr == null && ip6Cidr == null && cidrRequired) {
             if (ntwkOff.getGuestType() == GuestType.Shared) {
-                throw new 
InvalidParameterValueException("StartIp/endIp/gateway/netmask are required when 
create network of" + " type " + Network.GuestType.Shared);
+                throw new 
InvalidParameterValueException(String.format("Gateway/netmask are required when 
creating %s networks.", Network.GuestType.Shared));
             } else {
                 throw new InvalidParameterValueException("gateway/netmask are 
required when create network of" + " type " + GuestType.Isolated + " with 
service " + Service.SourceNat.getName() + " disabled");
             }
diff --git a/server/src/main/java/com/cloud/network/NetworkServiceImpl.java 
b/server/src/main/java/com/cloud/network/NetworkServiceImpl.java
index 2084cd4..178a4c8 100644
--- a/server/src/main/java/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/main/java/com/cloud/network/NetworkServiceImpl.java
@@ -1252,8 +1252,8 @@ public class NetworkServiceImpl extends ManagerBase 
implements NetworkService, C
             }
         }
 
-        boolean ipv4 = true, ipv6 = false;
-        if (startIP != null) {
+        boolean ipv4 = false, ipv6 = false;
+        if (org.apache.commons.lang3.StringUtils.isNoneBlank(gateway, 
netmask)) {
             ipv4 = true;
         }
         if (isNotBlank(ip6Cidr) && isNotBlank(ip6Gateway)) {
@@ -1297,14 +1297,10 @@ public class NetworkServiceImpl extends ManagerBase 
implements NetworkService, C
                 } else if (!NetUtils.isValidIp4(endIP)) {
                     throw new InvalidParameterValueException("Invalid format 
for the endIp parameter");
                 }
-            }
-
-            if (startIP != null && endIP != null) {
                 if (!(gateway != null && netmask != null)) {
                     throw new InvalidParameterValueException("gateway and 
netmask should be defined when startIP/endIP are passed in");
                 }
             }
-
             if (gateway != null && netmask != null) {
                 if (NetUtils.isNetworkorBroadcastIP(gateway, netmask)) {
                     if (s_logger.isDebugEnabled()) {
@@ -1338,6 +1334,10 @@ public class NetworkServiceImpl extends ManagerBase 
implements NetworkService, C
             if(isBlank(zone.getIp6Dns1()) && isBlank(zone.getIp6Dns2())) {
                 throw new InvalidParameterValueException("Can only create IPv6 
network if the zone has IPv6 DNS! Please configure the zone IPv6 DNS1 and/or 
IPv6 DNS2.");
             }
+
+            if (!ipv4 && ntwkOff.getGuestType() == GuestType.Shared && 
_networkModel.isProviderForNetworkOffering(Provider.VirtualRouter, 
networkOfferingId)) {
+                throw new InvalidParameterValueException("Currently IPv6-only 
Shared network with Virtual Router provider is not supported.");
+            }
         }
 
         validateRouterIps(routerIp, routerIpv6, startIP, endIP, gateway, 
netmask, startIPv6, endIPv6, ip6Cidr);

Reply via email to