@@ -1357,12 +1357,9 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapac
13571357
13581358 performBasicPrivateVlanChecks (vlanId , secondaryVlanId , privateVlanType );
13591359
1360- // Regular user can create Guest Isolated Source Nat enabled network only
1361- if (_accountMgr .isNormalUser (caller .getId ()) && (ntwkOff .getTrafficType () != TrafficType .Guest
1362- || ntwkOff .getGuestType () != Network .GuestType .Isolated && areServicesSupportedByNetworkOffering (ntwkOff .getId (), Service .SourceNat ))) {
1363- throw new InvalidParameterValueException (
1364- 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 ,
1365- Network .GuestType .Isolated , Service .SourceNat .getName ()));
1360+ // Regular user can create Guest Isolated Source Nat enabled network or L2 network only
1361+ if (_accountMgr .isNormalUser (caller .getId ())) {
1362+ validateNetworkOfferingForRegularUser (ntwkOff );
13661363 }
13671364
13681365 // Don't allow to specify vlan if the caller is not ROOT admin
@@ -1454,6 +1451,23 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapac
14541451 return network ;
14551452 }
14561453
1454+ private void validateNetworkOfferingForRegularUser (NetworkOfferingVO ntwkOff ) {
1455+ if (ntwkOff .getTrafficType () != TrafficType .Guest ) {
1456+ throw new InvalidParameterValueException ("Regular users can only create a Guest network" );
1457+ }
1458+ if (ntwkOff .getGuestType () == GuestType .Isolated && areServicesSupportedByNetworkOffering (ntwkOff .getId (), Service .SourceNat )) {
1459+ s_logger .debug (String .format ("Creating a network from network offerings having traffic type [%s] and network type [%s] with a service [%s] enabled." ,
1460+ TrafficType .Guest , GuestType .Isolated , Service .SourceNat .getName ()));
1461+ } else if (ntwkOff .getGuestType () == GuestType .L2 ) {
1462+ s_logger .debug (String .format ("Creating a network from network offerings having traffic type [%s] and network type [%s]." ,
1463+ TrafficType .Guest , GuestType .L2 ));
1464+ } else {
1465+ throw new InvalidParameterValueException (
1466+ String .format ("Regular users can only create an %s network with a service [%s] enabled, or a %s network." ,
1467+ GuestType .Isolated , Service .SourceNat .getName (), GuestType .L2 ));
1468+ }
1469+ }
1470+
14571471 /**
14581472 * Retrieve information (if set) for private VLAN when creating the network
14591473 */
0 commit comments