Skip to content

Commit 67301e4

Browse files
author
Dingane Hlaluku
committed
Allow users of all types to create L2 networks
1 parent 58466c8 commit 67301e4

3 files changed

Lines changed: 7 additions & 12 deletions

File tree

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,8 +1117,8 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapac
11171117
}
11181118

11191119
// Only Admin can create Shared networks
1120-
if ((ntwkOff.getGuestType() == GuestType.Shared || ntwkOff.getGuestType() == GuestType.L2) && !_accountMgr.isAdmin(caller.getId())) {
1121-
throw new InvalidParameterValueException("Only Admins can create network with guest type " + GuestType.Shared + " or " + GuestType.L2);
1120+
if ((ntwkOff.getGuestType() == GuestType.Shared) && !_accountMgr.isAdmin(caller.getId())) {
1121+
throw new InvalidParameterValueException("Only Admins can create network with guest type " + GuestType.Shared);
11221122
}
11231123

11241124
// Check if the network is domain specific
@@ -1824,13 +1824,15 @@ public boolean deleteNetwork(long networkId, boolean forced) {
18241824

18251825
// don't allow to delete system network
18261826
if (isNetworkSystem(network)) {
1827+
assert network != null;
18271828
throwInvalidIdException("Network with specified id is system and can't be removed", network.getUuid(), "networkId");
18281829
}
18291830

1831+
assert network != null;
18301832
Account owner = _accountMgr.getAccount(network.getAccountId());
18311833

1832-
// Only Admin can delete Shared and L2 networks
1833-
if ((network.getGuestType() == GuestType.Shared || network.getGuestType() == GuestType.L2) && !_accountMgr.isAdmin(caller.getId())) {
1834+
// Only Admin can delete Shared
1835+
if ((network.getGuestType() == GuestType.Shared) && !_accountMgr.isAdmin(caller.getId())) {
18341836
throw new InvalidParameterValueException("Only Admins can delete network with guest type " + network.getGuestType());
18351837
}
18361838

ui/scripts/network.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@
795795
isHeader: true
796796
}),
797797

798-
rootAdminAddL2Network: $.extend({}, addL2GuestNetwork.def, {
798+
AddL2Network: $.extend({}, addL2GuestNetwork.def, {
799799
isHeader: true
800800
})
801801

ui/scripts/sharedFunctions.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -831,13 +831,6 @@ var addL2GuestNetwork = {
831831
}
832832
},
833833

834-
preFilter: function(args) {
835-
if (isAdmin())
836-
return true;
837-
else
838-
return false;
839-
},
840-
841834
createForm: {
842835
title: 'label.add.l2.guest.network',
843836
fields: {

0 commit comments

Comments
 (0)