use of com.cloud.exception.UnsupportedServiceException in project cloudstack by apache.
the class ApplicationLoadBalancerManagerImpl method createApplicationLoadBalancer.
protected ApplicationLoadBalancerRule createApplicationLoadBalancer(String name, String description, Scheme scheme, Network sourceIpNtwk, String sourceIp, int sourcePort, int instancePort, String algorithm, Account lbOwner, Network guestNtwk, Boolean forDisplay) throws NetworkRuleConflictException, InsufficientVirtualNetworkCapacityException {
// Only Internal scheme is supported in this release
if (scheme != Scheme.Internal) {
throw new UnsupportedServiceException("Only scheme of type " + Scheme.Internal + " is supported");
}
// 1) Validate LB rule's parameters
validateLbRule(sourcePort, instancePort, algorithm, guestNtwk, scheme);
// 2) Validate source network
validateSourceIpNtwkForLbRule(sourceIpNtwk, scheme);
// 3) Get source ip address
Ip sourceIpAddr = getSourceIp(scheme, sourceIpNtwk, sourceIp);
ApplicationLoadBalancerRuleVO newRule = new ApplicationLoadBalancerRuleVO(name, description, sourcePort, instancePort, algorithm, guestNtwk.getId(), lbOwner.getId(), lbOwner.getDomainId(), sourceIpAddr, sourceIpNtwk.getId(), scheme);
if (forDisplay != null) {
newRule.setDisplay(forDisplay);
}
// 4) Validate Load Balancing rule on the providers
LoadBalancingRule loadBalancing = new LoadBalancingRule(newRule, new ArrayList<LbDestination>(), new ArrayList<LbStickinessPolicy>(), new ArrayList<LbHealthCheckPolicy>(), sourceIpAddr, null, null);
if (!_lbMgr.validateLbRule(loadBalancing)) {
throw new InvalidParameterValueException("LB service provider cannot support this rule");
}
// 5) Persist Load Balancer rule
return persistLbRule(newRule);
}
use of com.cloud.exception.UnsupportedServiceException in project cosmic by MissionCriticalCloud.
the class NetworkOrchestrator method finalizeServicesAndProvidersForNetwork.
@Override
public Map<String, String> finalizeServicesAndProvidersForNetwork(final NetworkOffering offering, final Long physicalNetworkId) {
final Map<String, String> svcProviders = new HashMap<>();
final Map<String, List<String>> providerSvcs = new HashMap<>();
final List<NetworkOfferingServiceMapVO> servicesMap = _ntwkOfferingSrvcDao.listByNetworkOfferingId(offering.getId());
final boolean checkPhysicalNetwork = physicalNetworkId != null;
for (final NetworkOfferingServiceMapVO serviceMap : servicesMap) {
if (svcProviders.containsKey(serviceMap.getService())) {
// provider load, etc
continue;
}
final String service = serviceMap.getService();
String provider = serviceMap.getProvider();
if (provider == null) {
provider = _networkModel.getDefaultUniqueProviderForService(service).getName();
}
// check that provider is supported
if (checkPhysicalNetwork) {
if (!_pNSPDao.isServiceProviderEnabled(physicalNetworkId, provider, service)) {
throw new UnsupportedServiceException("Provider " + provider + " is either not enabled or doesn't " + "support service " + service + " in physical network id=" + physicalNetworkId);
}
}
svcProviders.put(service, provider);
List<String> l = providerSvcs.get(provider);
if (l == null) {
providerSvcs.put(provider, l = new ArrayList<>());
}
l.add(service);
}
return svcProviders;
}
use of com.cloud.exception.UnsupportedServiceException in project cosmic by MissionCriticalCloud.
the class ResourceCountDaoImpl method persist.
@Override
public ResourceCountVO persist(final ResourceCountVO resourceCountVO) {
final ResourceOwnerType ownerType = resourceCountVO.getResourceOwnerType();
final ResourceType resourceType = resourceCountVO.getType();
if (!resourceType.supportsOwner(ownerType)) {
throw new UnsupportedServiceException("Resource type " + resourceType + " is not supported for owner of type " + ownerType.getName());
}
return super.persist(resourceCountVO);
}
use of com.cloud.exception.UnsupportedServiceException in project cloudstack by apache.
the class ResourceCountDaoImpl method persist.
@Override
public ResourceCountVO persist(ResourceCountVO resourceCountVO) {
ResourceOwnerType ownerType = resourceCountVO.getResourceOwnerType();
ResourceType resourceType = resourceCountVO.getType();
if (!resourceType.supportsOwner(ownerType)) {
throw new UnsupportedServiceException("Resource type " + resourceType + " is not supported for owner of type " + ownerType.getName());
}
return super.persist(resourceCountVO);
}
use of com.cloud.exception.UnsupportedServiceException in project cosmic by MissionCriticalCloud.
the class NetworkServiceImpl method getNetworkOfferingServiceCapabilities.
@Override
public Map<Capability, String> getNetworkOfferingServiceCapabilities(final NetworkOffering offering, final Service service) {
if (!areServicesSupportedByNetworkOffering(offering.getId(), service)) {
// TBD: We should be sending networkOfferingId and not the offering object itself.
throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the network offering " + offering);
}
Map<Capability, String> serviceCapabilities = new HashMap<>();
// get the Provider for this Service for this offering
final List<String> providers = _ntwkOfferingSrvcDao.listProvidersForServiceForNetworkOffering(offering.getId(), service);
if (providers.isEmpty()) {
// TBD: We should be sending networkOfferingId and not the offering object itself.
throw new InvalidParameterValueException("Service " + service.getName() + " is not supported by the network offering " + offering);
}
// FIXME - in post 3.0 we are going to support multiple providers for the same service per network offering, so
// we have to calculate capabilities for all of them
final String provider = providers.get(0);
// FIXME we return the capabilities of the first provider of the service - what if we have multiple providers
// for same Service?
final NetworkElement element = _networkModel.getElementImplementingProvider(provider);
if (element != null) {
final Map<Service, Map<Capability, String>> elementCapabilities = element.getCapabilities();
if (elementCapabilities == null || !elementCapabilities.containsKey(service)) {
// TBD: We should be sending providerId and not the offering object itself.
throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the element=" + element.getName() + " implementing Provider=" + provider);
}
serviceCapabilities = elementCapabilities.get(service);
}
return serviceCapabilities;
}
Aggregations