Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions server/src/main/java/com/cloud/network/NetworkServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1360,9 +1360,8 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapac

performBasicPrivateVlanChecks(vlanId, secondaryVlanId, privateVlanType);

// Regular user can create Guest Isolated Source Nat enabled network or L2 network only
if (_accountMgr.isNormalUser(caller.getId())) {
validateNetworkOfferingForRegularUser(ntwkOff);
if (!_accountMgr.isRootAdmin(caller.getId())) {
validateNetworkOfferingForNonRootAdminUser(ntwkOff);
}

// Don't allow to specify vlan if the caller is not ROOT admin
Expand Down Expand Up @@ -1454,20 +1453,16 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapac
return network;
}

private void validateNetworkOfferingForRegularUser(NetworkOfferingVO ntwkOff) {
private void validateNetworkOfferingForNonRootAdminUser(NetworkOfferingVO ntwkOff) {
if (ntwkOff.getTrafficType() != TrafficType.Guest) {
throw new InvalidParameterValueException("Regular users can only create a Guest network");
throw new InvalidParameterValueException("This user 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) {
if (ntwkOff.getGuestType() == GuestType.L2 || ntwkOff.getGuestType() == GuestType.Isolated) {
s_logger.debug(String.format("Creating a network from network offerings having traffic type [%s] and network type [%s].",
TrafficType.Guest, GuestType.L2));
TrafficType.Guest, ntwkOff.getGuestType()));
} 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));
String.format("This user can only create an %s network or a %s network.", GuestType.Isolated, GuestType.L2));
}
}

Expand Down