You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2019/03/25 07:42:25 UTC

[cloudstack] branch 4.11 updated: server: Allow users to create L2 network types (#3158)

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

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


The following commit(s) were added to refs/heads/4.11 by this push:
     new 55fb1c4  server: Allow users to create L2 network types (#3158)
55fb1c4 is described below

commit 55fb1c4eb61662adfe3b56b68b772f4cdc6e3c0e
Author: Dingane Hlaluku <dr...@gmail.com>
AuthorDate: Mon Mar 25 09:42:19 2019 +0200

    server: Allow users to create L2 network types (#3158)
    
    Allow users of all types to create L2 guest networks.
    
    Fixes #3081
---
 server/src/com/cloud/network/NetworkServiceImpl.java | 8 ++++----
 ui/scripts/network.js                                | 2 +-
 ui/scripts/sharedFunctions.js                        | 9 +--------
 3 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index 33a8178..b0839f9 100644
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -1101,8 +1101,8 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
         }
 
         // Only Admin can create Shared networks
-        if ((ntwkOff.getGuestType() == GuestType.Shared || ntwkOff.getGuestType() == GuestType.L2) && !_accountMgr.isAdmin(caller.getId())) {
-            throw new InvalidParameterValueException("Only Admins can create network with guest type " + GuestType.Shared + " or " + GuestType.L2);
+        if ((ntwkOff.getGuestType() == GuestType.Shared) && !_accountMgr.isAdmin(caller.getId())) {
+            throw new InvalidParameterValueException("Only Admins can create network with guest type " + GuestType.Shared);
         }
 
         // Check if the network is domain specific
@@ -1822,8 +1822,8 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
 
         Account owner = _accountMgr.getAccount(network.getAccountId());
 
-        // Only Admin can delete Shared and L2 networks
-        if ((network.getGuestType() == GuestType.Shared || network.getGuestType() == GuestType.L2) && !_accountMgr.isAdmin(caller.getId())) {
+        // Only Admin can delete Shared
+        if ((network.getGuestType() == GuestType.Shared) && !_accountMgr.isAdmin(caller.getId())) {
             throw new InvalidParameterValueException("Only Admins can delete network with guest type " + network.getGuestType());
         }
 
diff --git a/ui/scripts/network.js b/ui/scripts/network.js
index 22ddb10..f5be849 100644
--- a/ui/scripts/network.js
+++ b/ui/scripts/network.js
@@ -795,7 +795,7 @@
                             isHeader: true
                         }),
 
-                        rootAdminAddL2Network: $.extend({}, addL2GuestNetwork.def, {
+                        AddL2Network: $.extend({}, addL2GuestNetwork.def, {
                             isHeader: true
                         })
 
diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js
index 606fed4..e2ad3ba 100644
--- a/ui/scripts/sharedFunctions.js
+++ b/ui/scripts/sharedFunctions.js
@@ -831,13 +831,6 @@ var addL2GuestNetwork = {
             }
         },
 
-        preFilter: function(args) {
-            if (isAdmin())
-                return true;
-            else
-                return false;
-        },
-
         createForm: {
             title: 'label.add.l2.guest.network',
             fields: {
@@ -867,7 +860,7 @@ var addL2GuestNetwork = {
                             url: createURL('listZones'),
                             success: function(json) {
                                 var zones = $.grep(json.listzonesresponse.zone, function(zone) {
-                                    return (zone.networktype == 'Advanced' && zone.securitygroupsenabled != true); //Isolated networks can only be created in Advanced SG-disabled zone (but not in Basic zone nor Advanced SG-enabled zone)
+                                    return (zone.networktype == 'Advanced'); //Isolated networks can only be created in Advanced SG-disabled zone (but not in Basic zone nor Advanced SG-enabled zone)
                                 });
 
                                 args.response.success({