weizhouapache commented on a change in pull request #5844:
URL: https://github.com/apache/cloudstack/pull/5844#discussion_r781313480



##########
File path: server/src/main/java/com/cloud/network/NetworkServiceImpl.java
##########
@@ -1360,12 +1360,22 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) 
throws InsufficientCapac
 
         performBasicPrivateVlanChecks(vlanId, secondaryVlanId, 
privateVlanType);
 
-        // Regular user can create Guest Isolated Source Nat enabled network 
only
-        if (_accountMgr.isNormalUser(caller.getId()) && 
(ntwkOff.getTrafficType() != TrafficType.Guest
-                || ntwkOff.getGuestType() != Network.GuestType.Isolated && 
areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat))) {
-            throw new InvalidParameterValueException(
-                    String.format("Regular users can only create a network 
from network offerings having traffic type [%s] and network type [%s] with a 
service [%s] enabled.", TrafficType.Guest,
-                            Network.GuestType.Isolated, 
Service.SourceNat.getName()));
+        // Regular user can create Guest Isolated Source Nat enabled network 
or L2 network only
+        if (_accountMgr.isNormalUser(caller.getId())) {
+            if (ntwkOff.getTrafficType() != TrafficType.Guest) {
+                throw new InvalidParameterValueException("Regular users can 
only create a Guest network");
+            }
+            if (ntwkOff.getGuestType() == GuestType.Isolated && 
areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat)) {
+                s_logger.debug(String.format("Creating a network from network 
offerings having traffic type [%s] and network type [%s] with a service [%s] 
enabled.",
+                        TrafficType.Guest, GuestType.Isolated, 
Service.SourceNat.getName()));
+            } else if (ntwkOff.getGuestType() == GuestType.L2) {
+                s_logger.debug(String.format("Creating a network from network 
offerings having traffic type [%s] and network type [%s].",
+                        TrafficType.Guest, GuestType.L2));
+            } else {
+                throw new InvalidParameterValueException(
+                        String.format("Regular users can only create an %s 
network with a service [%s] enabled, or a %s network.",
+                                GuestType.Isolated, 
Service.SourceNat.getName(), GuestType.L2));
+            }
         }

Review comment:
       @DaanHoogland done. thanks for review




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to