mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Direct network guru takes care of only sourceNatDisabled networks in Advance zone
This commit is contained in:
parent
6dcc1691a1
commit
104ed0a2a2
@ -294,5 +294,6 @@ public class ApiConstants {
|
||||
public static final String SERVICE_LIST = "servicelist";
|
||||
public static final String CAN_ENABLE_INDIVIDUAL_SERVICE = "canenableindividualservice";
|
||||
public static final String SUPPORTED_SERVICES = "supportedservices";
|
||||
public static final String SOURCE_NAT_ENABLED = "sourcenatenabled";
|
||||
|
||||
}
|
||||
|
||||
@ -72,6 +72,9 @@ public class ListNetworksCmd extends BaseListCmd {
|
||||
|
||||
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="list networks by physical network id")
|
||||
private Long physicalNetworkId;
|
||||
|
||||
@Parameter(name=ApiConstants.SOURCE_NAT_ENABLED, type=CommandType.BOOLEAN, description="list networks that support/don't support sourceNat service")
|
||||
private Boolean sourceNatEnabled;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
@ -121,6 +124,10 @@ public class ListNetworksCmd extends BaseListCmd {
|
||||
return physicalNetworkId;
|
||||
}
|
||||
|
||||
public Boolean getSourceNatEnabled() {
|
||||
return sourceNatEnabled;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -110,8 +110,7 @@ public interface Network extends ControlledEntity {
|
||||
*/
|
||||
public static class Provider {
|
||||
private static List<Provider> supportedProviders = new ArrayList<Provider>();
|
||||
|
||||
|
||||
|
||||
public static final Provider VirtualRouter = new Provider("VirtualRouter", false);
|
||||
public static final Provider JuniperSRX = new Provider("JuniperSRX", true);
|
||||
public static final Provider F5BigIp = new Provider("F5BigIp", true);
|
||||
|
||||
@ -2018,6 +2018,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
String path = null;
|
||||
Long sharedNetworkDomainId = null;
|
||||
Long physicalNetworkId = cmd.getPhysicalNetworkId();
|
||||
Boolean sourceNatEnabled = cmd.getSourceNatEnabled();
|
||||
|
||||
//1) default is system to false if not specified
|
||||
//2) reset parameter to false if it's specified by the regular user
|
||||
@ -2102,10 +2103,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
sb.and("removed", sb.entity().getRemoved(), Op.NULL);
|
||||
|
||||
List<NetworkVO> networksToReturn = new ArrayList<NetworkVO>();
|
||||
if (isSystem == null || !isSystem) {
|
||||
//Get domain level + account/zone level networks
|
||||
List<NetworkVO> networksToReturn = new ArrayList<NetworkVO>();
|
||||
|
||||
if (sharedNetworkDomainId != null) {
|
||||
networksToReturn.addAll(listDomainLevelNetworks(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, isDefault, trafficType, isShared, physicalNetworkId), searchFilter, sharedNetworkDomainId));
|
||||
} else {
|
||||
@ -2119,11 +2119,25 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (!permittedAccounts.isEmpty() || (domainId == null && accountName == null && projectId == null)) {
|
||||
networksToReturn.addAll(listAccountSpecificAndZoneLevelNetworks(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, isDefault, trafficType, isShared, physicalNetworkId), searchFilter, path, permittedAccounts));
|
||||
}
|
||||
|
||||
return networksToReturn;
|
||||
|
||||
} else {
|
||||
return _networksDao.search(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, isDefault, trafficType, isShared, physicalNetworkId), searchFilter);
|
||||
networksToReturn = _networksDao.search(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, isDefault, trafficType, isShared, physicalNetworkId), searchFilter);
|
||||
}
|
||||
|
||||
//sort networks by sourceNatEnabled parameter
|
||||
if (sourceNatEnabled != null) {
|
||||
List<Network> supportedNetworks = new ArrayList<Network>();
|
||||
|
||||
for (Network network : networksToReturn) {
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
boolean isSupported = areServicesSupportedByNetworkOffering(offering.getId(), Service.SourceNat);
|
||||
if (isSupported == sourceNatEnabled.booleanValue()) {
|
||||
supportedNetworks.add(network);
|
||||
}
|
||||
}
|
||||
|
||||
return supportedNetworks;
|
||||
} else {
|
||||
return networksToReturn;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -75,17 +75,9 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
NetworkOfferingDao _networkOfferingDao;
|
||||
|
||||
protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
|
||||
// this guru handles only non-system network with:
|
||||
//1) type=Shared
|
||||
//2) type=Isolated and Source nat service disabled
|
||||
//TODO - after broadCastDomainType + physical network are introduced, don't rely on network type of the dc
|
||||
// this guru handles only Guest networks in Advance zone with source nat service disabled
|
||||
if (dc.getNetworkType() == NetworkType.Advanced && !_networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Service.SourceNat)&& offering.getTrafficType() == TrafficType.Guest) {
|
||||
if (_networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Service.SecurityGroup)) {
|
||||
return true;
|
||||
} else if (!offering.isSystemOnly()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
} else {
|
||||
s_logger.trace("We only take care of Guest Direct networks");
|
||||
return false;
|
||||
|
||||
@ -80,7 +80,6 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
|
||||
@Override
|
||||
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
|
||||
|
||||
if (_ovsNetworkMgr.isOvsNetworkEnabled() || _tunnelMgr.isOvsTunnelEnabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -79,11 +79,11 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
}
|
||||
|
||||
protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
|
||||
// This guru handles only non-system Guest Isolated network that supports Source nat service
|
||||
if (dc.getNetworkType() == NetworkType.Advanced && offering.getTrafficType() == TrafficType.Guest && offering.getGuestType() == Network.GuestType.Isolated && _networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Service.SourceNat) && !offering.isSystemOnly()) {
|
||||
// This guru handles only Guest Isolated network that supports Source nat service
|
||||
if (dc.getNetworkType() == NetworkType.Advanced && offering.getTrafficType() == TrafficType.Guest && offering.getGuestType() == Network.GuestType.Isolated && _networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Service.SourceNat)) {
|
||||
return true;
|
||||
} else {
|
||||
s_logger.trace("We only take care of Guest Virtual networks in zone of type " + NetworkType.Advanced);
|
||||
s_logger.trace("We only take care of Guest networks with service " + Service.SourceNat + " enabled in zone of type " + NetworkType.Advanced);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user