|
103 | 103 | import com.cloud.host.HostVO; |
104 | 104 | import com.cloud.host.dao.HostDao; |
105 | 105 | import com.cloud.hypervisor.Hypervisor.HypervisorType; |
| 106 | +import com.cloud.network.IPAddressVO; |
106 | 107 | import com.cloud.network.Network; |
107 | 108 | import com.cloud.network.Network.Capability; |
108 | 109 | import com.cloud.network.Network.GuestType; |
109 | 110 | import com.cloud.network.Network.Provider; |
110 | 111 | import com.cloud.network.Network.Service; |
111 | | -import com.cloud.network.IPAddressVO; |
112 | 112 | import com.cloud.network.NetworkManager; |
113 | 113 | import com.cloud.network.NetworkVO; |
114 | 114 | import com.cloud.network.Networks.BroadcastDomainType; |
|
163 | 163 | import com.cloud.vm.dao.SecondaryStorageVmDao; |
164 | 164 | import com.cloud.vm.dao.VMInstanceDao; |
165 | 165 |
|
| 166 | +import edu.emory.mathcs.backport.java.util.Arrays; |
| 167 | + |
166 | 168 | @Local(value = { ConfigurationManager.class, ConfigurationService.class }) |
167 | 169 | public class ConfigurationManagerImpl implements ConfigurationManager, ConfigurationService { |
168 | 170 | public static final Logger s_logger = Logger.getLogger(ConfigurationManagerImpl.class.getName()); |
@@ -3200,6 +3202,9 @@ public List<? extends NetworkOffering> searchForNetworkOfferings(ListNetworkOffe |
3200 | 3202 |
|
3201 | 3203 | if (zoneId != null) { |
3202 | 3204 | zone = getZone(zoneId); |
| 3205 | + if (zone == null) { |
| 3206 | + throw new InvalidParameterValueException("Unable to find the zone by id=" + zoneId); |
| 3207 | + } |
3203 | 3208 | } |
3204 | 3209 |
|
3205 | 3210 | Object keyword = cmd.getKeyword(); |
@@ -3288,31 +3293,43 @@ public List<? extends NetworkOffering> searchForNetworkOfferings(ListNetworkOffe |
3288 | 3293 |
|
3289 | 3294 | //filter by supported services |
3290 | 3295 | boolean listBySupportedServices = (supportedServicesStr != null && !supportedServicesStr.isEmpty() && !offerings.isEmpty()); |
3291 | | - boolean parseOfferings = (listBySupportedServices || sourceNatSupported != null); |
| 3296 | + boolean checkIfProvidersAreEnabled = (zoneId != null); |
| 3297 | + boolean parseOfferings = (listBySupportedServices || sourceNatSupported != null || checkIfProvidersAreEnabled); |
3292 | 3298 |
|
3293 | 3299 | if (parseOfferings) { |
3294 | 3300 | List<NetworkOfferingVO> supportedOfferings = new ArrayList<NetworkOfferingVO>(); |
3295 | | - Service[] suppportedServices = null; |
| 3301 | + Service[] supportedServices = null; |
3296 | 3302 |
|
3297 | 3303 | if (listBySupportedServices) { |
3298 | | - suppportedServices = new Service[supportedServicesStr.size()]; |
| 3304 | + supportedServices = new Service[supportedServicesStr.size()]; |
3299 | 3305 | int i = 0; |
3300 | 3306 | for (String supportedServiceStr : supportedServicesStr) { |
3301 | 3307 | Service service = Service.getService(supportedServiceStr); |
3302 | 3308 | if (service == null) { |
3303 | 3309 | throw new InvalidParameterValueException("Invalid service specified " + supportedServiceStr); |
3304 | 3310 | } else { |
3305 | | - suppportedServices[i] = service; |
| 3311 | + supportedServices[i] = service; |
3306 | 3312 | } |
3307 | 3313 | i++; |
3308 | 3314 | } |
3309 | 3315 | } |
3310 | 3316 |
|
3311 | 3317 | for (NetworkOfferingVO offering : offerings) { |
3312 | 3318 | boolean addOffering = true; |
| 3319 | + List<Service> checkForProviders = new ArrayList<Service>(); |
3313 | 3320 |
|
3314 | 3321 | if (listBySupportedServices) { |
3315 | | - addOffering = addOffering && _networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), suppportedServices); |
| 3322 | + addOffering = addOffering && _networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), supportedServices); |
| 3323 | + } |
| 3324 | + |
| 3325 | + if (checkIfProvidersAreEnabled) { |
| 3326 | + if (supportedServices != null && supportedServices.length > 0) { |
| 3327 | + checkForProviders = Arrays.asList(supportedServices); |
| 3328 | + } else { |
| 3329 | + checkForProviders = _networkMgr.listNetworkOfferingServices(offering.getId()); |
| 3330 | + } |
| 3331 | + |
| 3332 | + addOffering = addOffering && _networkMgr.areServicesEnabledInZone(zoneId, offering.getId(), offering.getTags(), checkForProviders); |
3316 | 3333 | } |
3317 | 3334 |
|
3318 | 3335 | if (sourceNatSupported != null) { |
|
0 commit comments