Search in sources :

Example 6 with UnsupportedServiceException

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);
}
Also used : ApplicationLoadBalancerRuleVO(org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO) LoadBalancingRule(com.cloud.network.lb.LoadBalancingRule) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) UnsupportedServiceException(com.cloud.exception.UnsupportedServiceException) Ip(com.cloud.utils.net.Ip) LbHealthCheckPolicy(com.cloud.network.lb.LoadBalancingRule.LbHealthCheckPolicy) LbStickinessPolicy(com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy) LbDestination(com.cloud.network.lb.LoadBalancingRule.LbDestination)

Example 7 with UnsupportedServiceException

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;
}
Also used : NetworkOfferingServiceMapVO(com.cloud.offerings.NetworkOfferingServiceMapVO) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) UnsupportedServiceException(com.cloud.exception.UnsupportedServiceException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 8 with UnsupportedServiceException

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);
}
Also used : UnsupportedServiceException(com.cloud.exception.UnsupportedServiceException) ResourceOwnerType(com.cloud.configuration.Resource.ResourceOwnerType) ResourceType(com.cloud.configuration.Resource.ResourceType)

Example 9 with UnsupportedServiceException

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);
}
Also used : UnsupportedServiceException(com.cloud.exception.UnsupportedServiceException) ResourceOwnerType(com.cloud.configuration.Resource.ResourceOwnerType) ResourceType(com.cloud.configuration.Resource.ResourceType)

Example 10 with UnsupportedServiceException

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;
}
Also used : NetworkElement(com.cloud.network.element.NetworkElement) Capability(com.cloud.network.Network.Capability) HashMap(java.util.HashMap) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) UnsupportedServiceException(com.cloud.exception.UnsupportedServiceException) Service(com.cloud.network.Network.Service) NetworkOrchestrationService(com.cloud.engine.orchestration.service.NetworkOrchestrationService) LoadBalancingRulesService(com.cloud.network.lb.LoadBalancingRulesService) ResourceLimitService(com.cloud.user.ResourceLimitService) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

UnsupportedServiceException (com.cloud.exception.UnsupportedServiceException)22 NetworkElement (com.cloud.network.element.NetworkElement)12 HashMap (java.util.HashMap)12 Service (com.cloud.network.Network.Service)11 Map (java.util.Map)10 Capability (com.cloud.network.Network.Capability)9 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)7 Provider (com.cloud.network.Network.Provider)7 UserDataServiceProvider (com.cloud.network.element.UserDataServiceProvider)6 NetworkOrchestrationService (org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService)6 ArrayList (java.util.ArrayList)4 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)3 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)3 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)3 HashSet (java.util.HashSet)3 ResourceOwnerType (com.cloud.configuration.Resource.ResourceOwnerType)2 ResourceType (com.cloud.configuration.Resource.ResourceType)2 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)2 NetworkOfferingServiceMapVO (com.cloud.offerings.NetworkOfferingServiceMapVO)2 ResourceLimitService (com.cloud.user.ResourceLimitService)2