/** * Validates requested source ip address of the LB rule based on Lb rule scheme/sourceNetwork * @param sourceIpNtwk * @param requestedSourceIp * @param scheme */ void validateRequestedSourceIpForLbRule(Network sourceIpNtwk, Ip requestedSourceIp, Scheme scheme) { //only Internal scheme is supported in this release if (scheme != Scheme.Internal) { throw new UnsupportedServiceException("Only scheme of type " + Scheme.Internal + " is supported"); } else { //validate guest source ip validateRequestedSourceIpForInternalLbRule(sourceIpNtwk, requestedSourceIp); } }
@Override public boolean verifyServicesCombination(Set<Service> services) { Preconditions.checkNotNull(services); final Sets.SetView<Service> missingServices = Sets.difference(REQUIRED_SERVICES, services); final Sets.SetView<Service> unsupportedServices = Sets.intersection(UNSUPPORTED_SERVICES, services); final Sets.SetView<Service> wantedServices = Sets.intersection(NUAGE_ONLY_SERVICES, new HashSet<>()); if (!missingServices.isEmpty()) { throw new UnsupportedServiceException("Provider " + Provider.NuageVsp + " requires services: " + missingServices); } if (!unsupportedServices.isEmpty()) { // NuageVsp doesn't implement any of these services. // So if these services are requested, we can't handle it. s_logger.debug("Unable to support services combination. The services " + unsupportedServices + " are not supported by Nuage VSP."); return false; } if (!wantedServices.isEmpty()) { throw new UnsupportedServiceException("Provider " + Provider.NuageVsp + " does not support services to be implemented by another provider: " + wantedServices); } return true; }
/** * Validates source IP network for the LB rule * @param sourceNtwk * @param scheme * @return */ protected Network validateSourceIpNtwkForLbRule(Network sourceNtwk, Scheme scheme) { //only Internal scheme is supported in this release if (scheme != Scheme.Internal) { throw new UnsupportedServiceException("Only scheme of type " + Scheme.Internal + " is supported"); } else { //validate source ip network return validateSourceIpNtwkForInternalLbRule(sourceNtwk); } }
private void checkMultipleSubnetsCombinedWithUseData(Network network) { if (isServiceProvidedByVR(network, Network.Service.UserData)) { List<VlanVO> vlanVOs = _vlanDao.listVlansByNetworkId(network.getId()); if (vlanVOs.stream() .map(VlanVO::getVlanGateway) .distinct() .count() > 1) { s_logger.error("NuageVsp provider does not support multiple subnets in combination with user data. Network: " + network + ", vlans: " + vlanVOs); throw new UnsupportedServiceException("NuageVsp provider does not support multiple subnets in combination with user data."); } } }
/** * Detects lb rule conflicts against other rules * @param newLbRule * @throws NetworkRuleConflictException */ protected void detectLbRulesConflicts(ApplicationLoadBalancerRule newLbRule) throws NetworkRuleConflictException { if (newLbRule.getScheme() != Scheme.Internal) { throw new UnsupportedServiceException("Only scheme of type " + Scheme.Internal + " is supported"); } else { detectInternalLbRulesConflict(newLbRule); } }
@Override public Map<Capability, String> getNetworkServiceCapabilities(long networkId, Service service) { if (!areServicesSupportedInNetwork(networkId, service)) { // TBD: networkId to uuid. No VO object being passed. So we will need to call // addProxyObject with hardcoded tablename. Or we should probably look up the correct dao proxy object. throw new UnsupportedServiceException("Service " + service.getName() + " is not supported in the network id=" + networkId); } Map<Capability, String> serviceCapabilities = new HashMap<Capability, String>(); // get the Provider for this Service for this offering String provider = _ntwkSrvcDao.getProviderForServiceInNetwork(networkId, service); NetworkElement element = getElementImplementingProvider(provider); if (element != null) { Map<Service, Map<Capability, String>> elementCapabilities = element.getCapabilities(); ; if (elementCapabilities == null || !elementCapabilities.containsKey(service)) { throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the element=" + element.getName() + " implementing Provider=" + provider); } serviceCapabilities = elementCapabilities.get(service); } return serviceCapabilities; }
@Override public boolean providerSupportsCapability(Set<Provider> providers, Service service, Capability cap) { for (Provider provider : providers) { NetworkElement element = getElementImplementingProvider(provider.getName()); if (element != null) { Map<Service, Map<Capability, String>> elementCapabilities = element.getCapabilities(); if (elementCapabilities == null || !elementCapabilities.containsKey(service)) { throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the element=" + element.getName() + " implementing Provider=" + provider.getName()); } Map<Capability, String> serviceCapabilities = elementCapabilities.get(service); if (serviceCapabilities == null || serviceCapabilities.isEmpty()) { throw new UnsupportedServiceException("Service " + service.getName() + " doesn't have capabilites for element=" + element.getName() + " implementing Provider=" + provider.getName()); } if (serviceCapabilities.containsKey(cap)) { return true; } } else { throw new UnsupportedServiceException("Unable to find network element for provider " + provider.getName()); } } return false; }
throw new UnsupportedServiceException(provider.getName() + " Provider cannot provide service " + service.getName()); throw new UnsupportedServiceException("Provider " + provider.getName() + " doesn't support services combination: " + serviceList);
@Override public void checkCapabilityForProvider(Set<Provider> providers, Service service, Capability cap, String capValue) { for (Provider provider : providers) { NetworkElement element = getElementImplementingProvider(provider.getName()); if (element != null) { Map<Service, Map<Capability, String>> elementCapabilities = element.getCapabilities(); if (elementCapabilities == null || !elementCapabilities.containsKey(service)) { throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the element=" + element.getName() + " implementing Provider=" + provider.getName()); } Map<Capability, String> serviceCapabilities = elementCapabilities.get(service); if (serviceCapabilities == null || serviceCapabilities.isEmpty()) { throw new UnsupportedServiceException("Service " + service.getName() + " doesn't have capabilities for element=" + element.getName() + " implementing Provider=" + provider.getName()); } String value = serviceCapabilities.get(cap); if (value == null || value.isEmpty()) { throw new UnsupportedServiceException("Service " + service.getName() + " doesn't have capability " + cap.getName() + " for element=" + element.getName() + " implementing Provider=" + provider.getName()); } if (!value.toLowerCase().contains(capValue.toLowerCase())) { throw new UnsupportedServiceException("Service " + service.getName() + " doesn't support value " + capValue + " for capability " + cap.getName() + " for element=" + element.getName() + " implementing Provider=" + provider.getName()); } } else { throw new UnsupportedServiceException("Unable to find network element for provider " + provider.getName()); } } }
throw new UnsupportedServiceException("Provider " + provider + " is either not enabled or doesn't " + "support service " + service + " in physical network id=" + physicalNetworkId);
@Override public Map<Capability, String> getNetworkOfferingServiceCapabilities(NetworkOffering offering, 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<Capability, String>(); // get the Provider for this Service for this offering 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 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? NetworkElement element = _networkModel.getElementImplementingProvider(provider); if (element != null) { 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; }
throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the network offering " + offering); throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the element=" + element.getName() + " implementing Provider=" + provider);
@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); }
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); }
@Override public String getProviderForServiceInNetwork(long networkId, Service service) { SearchCriteria<NetworkServiceMapVO> sc = AllFieldsSearch.create(); sc.setParameters("networkId", networkId); sc.setParameters("service", service.getName()); NetworkServiceMapVO ntwkSvc = findOneBy(sc); if (ntwkSvc == null) { throw new UnsupportedServiceException("Service " + service.getName() + " is not supported in the network id=" + networkId); } return ntwkSvc.getProvider(); }
@Override public String getProviderForServiceInVpc(long vpcId, Service service) { SearchCriteria<VpcServiceMapVO> sc = AllFieldsSearch.create(); sc.setParameters("vpcId", vpcId); sc.setParameters("service", service.getName()); VpcServiceMapVO ntwkSvc = findOneBy(sc); if (ntwkSvc == null) { throw new UnsupportedServiceException("Service " + service.getName() + " is not supported in the vpc id=" + vpcId); } return ntwkSvc.getProvider(); }