mirror of https://github.com/apache/cloudstack.git
bug 13971: return only offerings with matching tags when zoneId is passed in and corresponding zone has more than 1 physical network
status 13971: resolved fixed Reviewed-by: Prachi Damle
This commit is contained in:
parent
6795f3ed11
commit
8934c06ade
|
|
@ -3508,6 +3508,22 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
|
||||
List<NetworkOfferingVO> offerings = _networkOfferingDao.search(sc, searchFilter);
|
||||
Boolean sourceNatSupported = cmd.getSourceNatSupported();
|
||||
List<String> pNtwkTags = new ArrayList<String>();
|
||||
boolean checkForTags = false;
|
||||
if (zone != null) {
|
||||
List<PhysicalNetworkVO> pNtwks = _physicalNetworkDao.listByZoneAndTrafficType(zoneId, TrafficType.Guest);
|
||||
if (pNtwks.size() > 1) {
|
||||
checkForTags = true;
|
||||
//go through tags
|
||||
for (PhysicalNetworkVO pNtwk : pNtwks) {
|
||||
List<String> pNtwkTag = pNtwk.getTags();
|
||||
if (pNtwkTag == null || pNtwkTag.isEmpty()) {
|
||||
throw new CloudRuntimeException("Tags are not defined for physical network in the zone id=" + zoneId);
|
||||
}
|
||||
pNtwkTags.addAll(pNtwkTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// filter by supported services
|
||||
boolean listBySupportedServices = (supportedServicesStr != null && !supportedServicesStr.isEmpty() && !offerings.isEmpty());
|
||||
|
|
@ -3535,7 +3551,13 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
for (NetworkOfferingVO offering : offerings) {
|
||||
boolean addOffering = true;
|
||||
List<Service> checkForProviders = new ArrayList<Service>();
|
||||
|
||||
|
||||
if (checkForTags) {
|
||||
if (!pNtwkTags.contains(offering.getTags())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (listBySupportedServices) {
|
||||
addOffering = addOffering && _networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), supportedServices);
|
||||
}
|
||||
|
|
@ -3553,10 +3575,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
if (sourceNatSupported != null) {
|
||||
addOffering = addOffering && (_networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.SourceNat) == sourceNatSupported);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (addOffering) {
|
||||
supportedOfferings.add(offering);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return supportedOfferings;
|
||||
|
|
|
|||
|
|
@ -26,9 +26,11 @@ import com.cloud.network.PhysicalNetworkVO;
|
|||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.GenericSearchBuilder;
|
||||
import com.cloud.utils.db.JoinBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Func;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
|
||||
@Local(value=PhysicalNetworkDao.class) @DB(txn=false)
|
||||
|
|
@ -42,7 +44,6 @@ public class PhysicalNetworkDaoImpl extends GenericDaoBase<PhysicalNetworkVO, Lo
|
|||
ZoneSearch = createSearchBuilder();
|
||||
ZoneSearch.and("dataCenterId", ZoneSearch.entity().getDataCenterId(), Op.EQ);
|
||||
ZoneSearch.done();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue