mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-16 18:43:26 +01:00
listNetworkOfferings: added an ability to filter based on the Services supported
This commit is contained in:
parent
7aab227b37
commit
17a7b7cda4
@ -292,6 +292,7 @@ public class ApiConstants {
|
||||
public static final String NETWORK_SERVICE_PROVIDER_ID = "nspid";
|
||||
public static final String SECURITY_GROUP_SERVICE = "securitygroupservice";
|
||||
public static final String SERVICE_LIST = "servicelist";
|
||||
public static final String CAN_ENABLE_INDIVIDUAL_SERVICE = "canEnableIndividualService";
|
||||
public static final String CAN_ENABLE_INDIVIDUAL_SERVICE = "canenableindividualservice";
|
||||
public static final String SUPPORTED_SERVICES = "supportedservices";
|
||||
|
||||
}
|
||||
|
||||
@ -27,7 +27,6 @@ import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.BaseCmd.CommandType;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.NetworkOfferingResponse;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
@ -77,6 +76,10 @@ public class ListNetworkOfferingsCmd extends BaseListCmd {
|
||||
@Parameter(name=ApiConstants.GUEST_IP_TYPE, type=CommandType.STRING, description="list network offerings by guest type: Shared or Isolated")
|
||||
private String guestIpType;
|
||||
|
||||
//Network information
|
||||
@Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, collectionType=CommandType.STRING, description="list network offerings supporting certain services")
|
||||
private List<String> supportedServices;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -129,6 +132,10 @@ public class ListNetworkOfferingsCmd extends BaseListCmd {
|
||||
return guestIpType;
|
||||
}
|
||||
|
||||
public List<String> getSupportedServices() {
|
||||
return supportedServices;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -3034,6 +3034,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
DataCenter zone = null;
|
||||
Long networkId = cmd.getNetworkId();
|
||||
String guestIpType = cmd.getGuestIpType();
|
||||
List<String> supportedServicesStr = cmd.getSupportedServices();
|
||||
|
||||
if (zoneId != null) {
|
||||
zone = getZone(zoneId);
|
||||
@ -3096,7 +3097,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
// Don't return system network offerings to the user
|
||||
sc.addAnd("systemOnly", SearchCriteria.Op.EQ, false);
|
||||
|
||||
// list offerings available for upgrade only
|
||||
// if networkId is specified, list offerings available for upgrade only (for this network)
|
||||
if (networkId != null) {
|
||||
// check if network exists and the caller can operate with it
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
@ -3124,7 +3125,32 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
sc.addAnd("id", SearchCriteria.Op.EQ, id);
|
||||
}
|
||||
|
||||
return _networkOfferingDao.search(sc, searchFilter);
|
||||
List<NetworkOfferingVO> offerings = _networkOfferingDao.search(sc, searchFilter);;
|
||||
|
||||
if (supportedServicesStr != null && !supportedServicesStr.isEmpty() && !offerings.isEmpty()) {
|
||||
List<NetworkOfferingVO> supportedOfferings = new ArrayList<NetworkOfferingVO>();
|
||||
Service[] suppportedServices = new Service[supportedServicesStr.size()];
|
||||
int i = 0;
|
||||
for (String supportedServiceStr : supportedServicesStr) {
|
||||
Service service = Service.getService(supportedServiceStr);
|
||||
if (service == null) {
|
||||
throw new InvalidParameterValueException("Invalid service specified " + supportedServiceStr);
|
||||
} else {
|
||||
suppportedServices[i] = service;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
for (NetworkOfferingVO offering : offerings) {
|
||||
if (_networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), suppportedServices)) {
|
||||
supportedOfferings.add(offering);
|
||||
}
|
||||
}
|
||||
|
||||
return supportedOfferings;
|
||||
} else {
|
||||
return offerings;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -190,7 +190,7 @@ public interface NetworkManager extends NetworkService {
|
||||
|
||||
boolean applyIpAssociations(Network network, boolean continueOnError) throws ResourceUnavailableException;
|
||||
|
||||
boolean isServiceSupportedByNetworkOffering(long networkOfferingId, Network.Service service);
|
||||
boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services);
|
||||
|
||||
NetworkVO getNetworkWithSecurityGroupEnabled(Long zoneId);
|
||||
|
||||
|
||||
@ -1386,7 +1386,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
// associate a source NAT IP (if one isn't already associated with the network)
|
||||
|
||||
boolean sharedSourceNat = false;
|
||||
if (isServiceSupportedByNetworkOffering(network.getNetworkOfferingId(), Service.SourceNat)) {
|
||||
if (areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Service.SourceNat)) {
|
||||
Map<Network.Capability, String> sourceNatCapabilities = getServiceCapabilities(network.getNetworkOfferingId(), Service.SourceNat);
|
||||
if (sourceNatCapabilities != null) {
|
||||
String supportedSourceNatTypes = sourceNatCapabilities.get(Capability.SupportedSourceNatTypes).toLowerCase();
|
||||
@ -1396,7 +1396,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
if (network.getGuestType() == Network.GuestType.Isolated && isServiceSupportedByNetworkOffering(network.getNetworkOfferingId(), Service.SourceNat) && !sharedSourceNat) {
|
||||
if (network.getGuestType() == Network.GuestType.Isolated && areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Service.SourceNat) && !sharedSourceNat) {
|
||||
List<IPAddressVO> ips = _ipAddressDao.listByAssociatedNetwork(network.getId(), true);
|
||||
|
||||
if (ips.isEmpty()) {
|
||||
@ -1600,7 +1600,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
Network associatedNetwork = getNetwork(ipVO.getAssociatedWithNetworkId());
|
||||
|
||||
if (isServiceSupportedByNetworkOffering(associatedNetwork.getNetworkOfferingId(), Service.SourceNat)) {
|
||||
if (areServicesSupportedByNetworkOffering(associatedNetwork.getNetworkOfferingId(), Service.SourceNat)) {
|
||||
throw new IllegalArgumentException("ip address is used for source nat purposes and can not be disassociated.");
|
||||
}
|
||||
|
||||
@ -1805,7 +1805,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
|
||||
// Regular user can create Guest Isolated Source Nat enabled network only
|
||||
if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL && (networkOffering.getTrafficType() != TrafficType.Guest || networkOffering.getGuestType() != Network.GuestType.Isolated && isServiceSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat))) {
|
||||
if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL && (networkOffering.getTrafficType() != TrafficType.Guest || networkOffering.getGuestType() != Network.GuestType.Isolated && areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat))) {
|
||||
throw new InvalidParameterValueException("Regular user can create a network only from the network offering having traffic type " + TrafficType.Guest + " and network type "
|
||||
+ Network.GuestType.Isolated + " with a service " + Service.SourceNat + " enabled");
|
||||
}
|
||||
@ -1844,7 +1844,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
//Vlan is created in 2 cases:
|
||||
//1) GuestType is Shared
|
||||
//2) GuestType is Isolated, but SourceNat service is disabled
|
||||
boolean createVlan = ((network.getGuestType() == Network.GuestType.Shared) || (network.getGuestType() == GuestType.Isolated && !isServiceSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat)));
|
||||
boolean createVlan = ((network.getGuestType() == Network.GuestType.Shared) || (network.getGuestType() == GuestType.Isolated && !areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat)));
|
||||
|
||||
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN && createVlan && defineNetworkConfig) {
|
||||
// Create vlan ip range
|
||||
@ -1904,7 +1904,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
|
||||
// If networkDomain is not specified, take it from the global configuration
|
||||
if (isServiceSupportedByNetworkOffering(networkOfferingId, Service.Dns)) {
|
||||
if (areServicesSupportedByNetworkOffering(networkOfferingId, Service.Dns)) {
|
||||
Map<Network.Capability, String> dnsCapabilities = getServiceCapabilities(networkOfferingId, Service.Dns);
|
||||
String isUpdateDnsSupported = dnsCapabilities.get(Capability.AllowDnsSuffixModification);
|
||||
if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) {
|
||||
@ -2731,7 +2731,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
@Override
|
||||
public Map<Capability, String> getServiceCapabilities(Long networkOfferingId, Service service) {
|
||||
|
||||
if (!isServiceSupportedByNetworkOffering(networkOfferingId, service)) {
|
||||
if (!areServicesSupportedByNetworkOffering(networkOfferingId, service)) {
|
||||
throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the network offering id=" + networkOfferingId);
|
||||
}
|
||||
|
||||
@ -3021,7 +3021,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (zone.getNetworkType() == NetworkType.Advanced) {
|
||||
if (usesJuniperForGatewayService && usesJuniperForFirewallService) {
|
||||
return true;
|
||||
} else if (_ntwkOfferingSrvcDao.isServiceSupported(networkOfferingId, Service.Gateway) && (usesF5ForLBService || usesNetscalarForLBService)) {
|
||||
} else if (_ntwkOfferingSrvcDao.areServicesSupported(networkOfferingId, Service.Gateway) && (usesF5ForLBService || usesNetscalarForLBService)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -3033,8 +3033,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServiceSupportedByNetworkOffering(long networkOfferingId, Network.Service service) {
|
||||
return (_ntwkOfferingSrvcDao.isServiceSupported(networkOfferingId, service));
|
||||
public boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services) {
|
||||
return (_ntwkOfferingSrvcDao.areServicesSupported(networkOfferingId, services));
|
||||
}
|
||||
|
||||
private boolean cleanupIpResources(long ipId, long userId, Account caller) {
|
||||
@ -3504,7 +3504,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
NetworkOffering newNetworkOffering = _networkOfferingDao.findById(newNetworkOfferingId);
|
||||
|
||||
//security group service should be the same
|
||||
if (isServiceSupportedByNetworkOffering(oldNetworkOfferingId, Service.SecurityGroup) != isServiceSupportedByNetworkOffering(newNetworkOfferingId, Service.SecurityGroup)) {
|
||||
if (areServicesSupportedByNetworkOffering(oldNetworkOfferingId, Service.SecurityGroup) != areServicesSupportedByNetworkOffering(newNetworkOfferingId, Service.SecurityGroup)) {
|
||||
s_logger.debug("Offerings " + newNetworkOfferingId + " and " + oldNetworkOfferingId + " have different securityGroupProperty, can't upgrade");
|
||||
return false;
|
||||
}
|
||||
@ -4228,14 +4228,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
List<Long> offeringsToReturn = new ArrayList<Long>();
|
||||
NetworkOffering originalOffering = _configMgr.getNetworkOffering(getNetwork(networkId).getNetworkOfferingId());
|
||||
|
||||
boolean securityGroupSupportedByOriginalOff = isServiceSupportedByNetworkOffering(originalOffering.getId(), Service.SecurityGroup);
|
||||
boolean securityGroupSupportedByOriginalOff = areServicesSupportedByNetworkOffering(originalOffering.getId(), Service.SecurityGroup);
|
||||
|
||||
//security group supported property should be the same
|
||||
|
||||
List<Long> offerings = _networkOfferingDao.getOfferingIdsToUpgradeFrom(originalOffering);
|
||||
|
||||
for (Long offeringId : offerings) {
|
||||
if (isServiceSupportedByNetworkOffering(offeringId, Service.SecurityGroup) == securityGroupSupportedByOriginalOff) {
|
||||
if (areServicesSupportedByNetworkOffering(offeringId, Service.SecurityGroup) == securityGroupSupportedByOriginalOff) {
|
||||
offeringsToReturn.add(offeringId);
|
||||
}
|
||||
}
|
||||
@ -4723,7 +4723,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
@Override
|
||||
public boolean isServiceEnabled(long physicalNetworkId, long networkOfferingId, Service service) {
|
||||
//check if the service is supported by the network offering
|
||||
if (!isServiceSupportedByNetworkOffering(networkOfferingId, service)) {
|
||||
if (!areServicesSupportedByNetworkOffering(networkOfferingId, service)) {
|
||||
s_logger.debug("Service " + service.getName() + " is not supported by the network offering id=" + networkOfferingId);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -78,8 +78,8 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
|
||||
// this guru handles only non-system network with type=Shared and serviceNat service disabled
|
||||
//TODO - after broadCastDomainType + physical network are introduced, don't rely on network type of the dc
|
||||
if (dc.getNetworkType() == NetworkType.Advanced && offering.getGuestType() == Network.GuestType.Shared && !_networkMgr.isServiceSupportedByNetworkOffering(offering.getId(), Service.SourceNat)&& offering.getTrafficType() == TrafficType.Guest) {
|
||||
if (_networkMgr.isServiceSupportedByNetworkOffering(offering.getId(), Service.SecurityGroup)) {
|
||||
if (dc.getNetworkType() == NetworkType.Advanced && offering.getGuestType() == Network.GuestType.Shared && !_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;
|
||||
@ -127,7 +127,7 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
|
||||
}
|
||||
|
||||
boolean isSecurityGroupEnabled = _networkMgr.isServiceSupportedByNetworkOffering(offering.getId(), Service.SecurityGroup);
|
||||
boolean isSecurityGroupEnabled = _networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Service.SecurityGroup);
|
||||
if (isSecurityGroupEnabled) {
|
||||
config.setName("SecurityGroupEnabledNetwork");
|
||||
config.setDisplayText("SecurityGroupEnabledNetwork");
|
||||
|
||||
@ -80,7 +80,7 @@ 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.isServiceSupportedByNetworkOffering(offering.getId(), Service.SourceNat) && !offering.isSystemOnly()) {
|
||||
if (dc.getNetworkType() == NetworkType.Advanced && offering.getTrafficType() == TrafficType.Guest && offering.getGuestType() == Network.GuestType.Isolated && _networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Service.SourceNat) && !offering.isSystemOnly()) {
|
||||
return true;
|
||||
} else {
|
||||
s_logger.trace("We only take care of Guest Virtual networks in zone of type " + NetworkType.Advanced);
|
||||
|
||||
@ -421,7 +421,7 @@ public class LoadBalancingRulesManagerImpl implements LoadBalancingRulesManager,
|
||||
_accountMgr.checkAccess(caller.getCaller(), null, ipAddr);
|
||||
|
||||
// verify that lb service is supported by the network
|
||||
if (!_networkMgr.isServiceSupportedByNetworkOffering(network.getNetworkOfferingId(), Service.Lb)) {
|
||||
if (!_networkMgr.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Service.Lb)) {
|
||||
throw new InvalidParameterValueException("LB service is not supported in network id= " + networkId);
|
||||
|
||||
}
|
||||
|
||||
@ -1031,9 +1031,9 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
|
||||
long dcId = dest.getDataCenter().getId();
|
||||
DataCenterDeployment plan = new DataCenterDeployment(dcId);
|
||||
boolean isPodBased = (dest.getDataCenter().getNetworkType() == NetworkType.Basic || _networkMgr.isServiceSupportedByNetworkOffering(guestNetwork.getNetworkOfferingId(), Service.SecurityGroup)) && guestNetwork.getTrafficType() == TrafficType.Guest;
|
||||
boolean isPodBased = (dest.getDataCenter().getNetworkType() == NetworkType.Basic || _networkMgr.areServicesSupportedByNetworkOffering(guestNetwork.getNetworkOfferingId(), Service.SecurityGroup)) && guestNetwork.getTrafficType() == TrafficType.Guest;
|
||||
boolean publicNetwork = false;
|
||||
if (_networkMgr.isServiceSupportedByNetworkOffering(guestNetwork.getNetworkOfferingId(), Service.SourceNat)) {
|
||||
if (_networkMgr.areServicesSupportedByNetworkOffering(guestNetwork.getNetworkOfferingId(), Service.SourceNat)) {
|
||||
publicNetwork = true;
|
||||
}
|
||||
if (isRedundant && !publicNetwork) {
|
||||
@ -1333,7 +1333,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
DataCenterDeployment plan = null;
|
||||
DataCenter dc = dest.getDataCenter();
|
||||
long dcId = dc.getId();
|
||||
boolean isPodBased = (dc.getNetworkType() == NetworkType.Basic || _networkMgr.isServiceSupportedByNetworkOffering(guestNetwork.getNetworkOfferingId(), Service.SecurityGroup)) && guestNetwork.getTrafficType() == TrafficType.Guest;
|
||||
boolean isPodBased = (dc.getNetworkType() == NetworkType.Basic || _networkMgr.areServicesSupportedByNetworkOffering(guestNetwork.getNetworkOfferingId(), Service.SecurityGroup)) && guestNetwork.getTrafficType() == TrafficType.Guest;
|
||||
DomainRouterVO router = null;
|
||||
|
||||
List<DomainRouterVO> routers = null;
|
||||
|
||||
@ -343,7 +343,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
}
|
||||
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
if (!_networkMgr.isServiceSupportedByNetworkOffering(network.getNetworkOfferingId(), Service.Firewall)) {
|
||||
if (!_networkMgr.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Service.Firewall)) {
|
||||
throw new InvalidParameterValueException("Unable to create static nat rule; Firewall service is not supported in network id=" + networkId);
|
||||
}
|
||||
|
||||
|
||||
@ -139,7 +139,7 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
|
||||
|
||||
//Verify that vpn service is enabled for the network
|
||||
Network network = _networkMgr.getNetwork(ipAddr.getAssociatedWithNetworkId());
|
||||
if (!_networkMgr.isServiceSupportedByNetworkOffering(network.getNetworkOfferingId(), Service.Vpn)) {
|
||||
if (!_networkMgr.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Service.Vpn)) {
|
||||
throw new InvalidParameterValueException("Vpn service is not supported in network id=" + ipAddr.getAssociatedWithNetworkId());
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ import com.cloud.utils.db.GenericDao;
|
||||
*
|
||||
*/
|
||||
public interface NetworkOfferingServiceMapDao extends GenericDao<NetworkOfferingServiceMapVO, Long> {
|
||||
boolean isServiceSupported(long networkOfferingId, Service service);
|
||||
boolean areServicesSupported(long networkOfferingId, Service... services);
|
||||
boolean isProviderSupported(long networkOfferingId, Service service, Provider provider);
|
||||
List<String> getServicesForProvider(long networkOfferingId, Provider provider);
|
||||
List<String> getProvidersForService(long networkOfferingid, Service service);
|
||||
|
||||
@ -39,6 +39,7 @@ import com.cloud.utils.db.SearchCriteria;
|
||||
@Local(value=NetworkOfferingServiceMapDao.class) @DB(txn=false)
|
||||
public class NetworkOfferingServiceMapDaoImpl extends GenericDaoBase<NetworkOfferingServiceMapVO, Long> implements NetworkOfferingServiceMapDao {
|
||||
final SearchBuilder<NetworkOfferingServiceMapVO> AllFieldsSearch;
|
||||
final SearchBuilder<NetworkOfferingServiceMapVO> MultipleServicesSearch;
|
||||
|
||||
protected NetworkOfferingServiceMapDaoImpl() {
|
||||
super();
|
||||
@ -47,18 +48,42 @@ public class NetworkOfferingServiceMapDaoImpl extends GenericDaoBase<NetworkOffe
|
||||
AllFieldsSearch.and("service", AllFieldsSearch.entity().getService(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.and("provider", AllFieldsSearch.entity().getProvider(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.done();
|
||||
|
||||
MultipleServicesSearch = createSearchBuilder();
|
||||
MultipleServicesSearch.and("networkOfferingId", MultipleServicesSearch.entity().getNetworkOfferingId(), SearchCriteria.Op.EQ);
|
||||
MultipleServicesSearch.and("service", MultipleServicesSearch.entity().getService(), SearchCriteria.Op.IN);
|
||||
MultipleServicesSearch.and("provider", MultipleServicesSearch.entity().getProvider(), SearchCriteria.Op.EQ);
|
||||
MultipleServicesSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServiceSupported(long networkOfferingId, Service service) {
|
||||
SearchCriteria<NetworkOfferingServiceMapVO> sc = AllFieldsSearch.create();
|
||||
public boolean areServicesSupported(long networkOfferingId, Service... services) {
|
||||
SearchCriteria<NetworkOfferingServiceMapVO> sc = MultipleServicesSearch.create();
|
||||
sc.setParameters("networkOfferingId", networkOfferingId);
|
||||
sc.setParameters("service", service.getName());
|
||||
if (findOneBy(sc) != null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
if (services != null) {
|
||||
String[] servicesStr = new String[services.length];
|
||||
|
||||
int i = 0;
|
||||
for (Service service : services) {
|
||||
servicesStr[i] = service.getName();
|
||||
i++;
|
||||
}
|
||||
|
||||
sc.setParameters("service", (Object[])servicesStr);
|
||||
}
|
||||
|
||||
List<NetworkOfferingServiceMapVO> offerings = listBy(sc);
|
||||
|
||||
if (services != null) {
|
||||
if (offerings.size() == services.length) {
|
||||
return true;
|
||||
}
|
||||
} else if (!offerings.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -360,7 +360,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServiceSupportedByNetworkOffering(long networkOfferingId, Service service) {
|
||||
public boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user