Search in sources :

Example 46 with Provider

use of com.cloud.network.Network.Provider in project cloudstack by apache.

the class NetworkModelImpl method listSupportedNetworkServiceProviders.

@Override
public List<? extends Provider> listSupportedNetworkServiceProviders(String serviceName) {
    Network.Service service = null;
    if (serviceName != null) {
        service = Network.Service.getService(serviceName);
        if (service == null) {
            throw new InvalidParameterValueException("Invalid Network Service=" + serviceName);
        }
    }
    Set<Provider> supportedProviders = new HashSet<Provider>();
    if (service != null) {
        List<Provider> providers = s_serviceToImplementedProvidersMap.get(service);
        if (providers != null && !providers.isEmpty()) {
            supportedProviders.addAll(providers);
        }
    } else {
        for (List<Provider> pList : s_serviceToImplementedProvidersMap.values()) {
            supportedProviders.addAll(pList);
        }
    }
    return new ArrayList<Provider>(supportedProviders);
}
Also used : InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ArrayList(java.util.ArrayList) Service(com.cloud.network.Network.Service) HashSet(java.util.HashSet) UserDataServiceProvider(com.cloud.network.element.UserDataServiceProvider) Provider(com.cloud.network.Network.Provider)

Example 47 with Provider

use of com.cloud.network.Network.Provider in project cloudstack by apache.

the class NetworkModelImpl method getProviderServicesMap.

Map<Provider, Set<Service>> getProviderServicesMap(long networkId) {
    Map<Provider, Set<Service>> map = new HashMap<Provider, Set<Service>>();
    List<NetworkServiceMapVO> nsms = _ntwkSrvcDao.getServicesInNetwork(networkId);
    for (NetworkServiceMapVO nsm : nsms) {
        Set<Service> services = map.get(Provider.getProvider(nsm.getProvider()));
        if (services == null) {
            services = new HashSet<Service>();
        }
        services.add(Service.getService(nsm.getService()));
        map.put(Provider.getProvider(nsm.getProvider()), services);
    }
    return map;
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Service(com.cloud.network.Network.Service) NetworkServiceMapVO(com.cloud.network.dao.NetworkServiceMapVO) UserDataServiceProvider(com.cloud.network.element.UserDataServiceProvider) Provider(com.cloud.network.Network.Provider)

Example 48 with Provider

use of com.cloud.network.Network.Provider in project cloudstack by apache.

the class ContrailManagerImpl method locateNetworkOffering.

private NetworkOffering locateNetworkOffering(String offeringName, String offeringDisplayText, Provider provider) {
    List<? extends NetworkOffering> offerList = _configService.listNetworkOfferings(TrafficType.Guest, false);
    for (NetworkOffering offer : offerList) {
        if (offer.getName().equals(offeringName)) {
            if (offer.getState() != NetworkOffering.State.Enabled) {
                return EnableNetworkOffering(offer.getId());
            }
            return offer;
        }
    }
    Map<Service, Set<Provider>> serviceProviderMap = new HashMap<Service, Set<Provider>>();
    Set<Provider> providerSet = new HashSet<Provider>();
    providerSet.add(provider);
    final Service[] services = { Service.Connectivity, Service.Dhcp, Service.NetworkACL, Service.StaticNat, Service.SourceNat, Service.Lb };
    for (Service svc : services) {
        if (svc == Service.Lb) {
            if (offeringName.equals(vpcRouterOfferingName)) {
                Set<Provider> lbProviderSet = new HashSet<Provider>();
                lbProviderSet.add(Provider.InternalLbVm);
                serviceProviderMap.put(svc, lbProviderSet);
            }
            continue;
        }
        serviceProviderMap.put(svc, providerSet);
    }
    ConfigurationManager configMgr = (ConfigurationManager) _configService;
    NetworkOfferingVO voffer = configMgr.createNetworkOffering(offeringName, offeringDisplayText, TrafficType.Guest, null, false, Availability.Optional, null, serviceProviderMap, true, Network.GuestType.Isolated, false, null, false, null, false, true, null, true, null, false);
    voffer.setState(NetworkOffering.State.Enabled);
    if (offeringName.equals(vpcRouterOfferingName)) {
        voffer.setInternalLb(true);
    }
    long id = voffer.getId();
    _networkOfferingDao.update(id, voffer);
    return _networkOfferingDao.findById(id);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) NetworkOffering(com.cloud.offering.NetworkOffering) HashMap(java.util.HashMap) Service(com.cloud.network.Network.Service) VpcProvisioningService(com.cloud.network.vpc.VpcProvisioningService) ConfigurationService(com.cloud.configuration.ConfigurationService) Provider(com.cloud.network.Network.Provider) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) ConfigurationManager(com.cloud.configuration.ConfigurationManager) HashSet(java.util.HashSet)

Example 49 with Provider

use of com.cloud.network.Network.Provider in project cloudstack by apache.

the class NetworkModelImpl method getNetworkOfferingServiceProvidersMap.

@Override
public Map<Service, Set<Provider>> getNetworkOfferingServiceProvidersMap(long networkOfferingId) {
    Map<Service, Set<Provider>> serviceProviderMap = new HashMap<Service, Set<Provider>>();
    List<NetworkOfferingServiceMapVO> map = _ntwkOfferingSrvcDao.listByNetworkOfferingId(networkOfferingId);
    for (NetworkOfferingServiceMapVO instance : map) {
        String service = instance.getService();
        Set<Provider> providers;
        providers = serviceProviderMap.get(Service.getService(service));
        if (providers == null) {
            providers = new HashSet<Provider>();
        }
        providers.add(Provider.getProvider(instance.getProvider()));
        serviceProviderMap.put(Service.getService(service), providers);
    }
    return serviceProviderMap;
}
Also used : NetworkOfferingServiceMapVO(com.cloud.offerings.NetworkOfferingServiceMapVO) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Service(com.cloud.network.Network.Service) UserDataServiceProvider(com.cloud.network.element.UserDataServiceProvider) Provider(com.cloud.network.Network.Provider)

Example 50 with Provider

use of com.cloud.network.Network.Provider in project cloudstack by apache.

the class NetworkModelImpl method providerSupportsCapability.

@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;
}
Also used : NetworkElement(com.cloud.network.element.NetworkElement) Capability(com.cloud.network.Network.Capability) UnsupportedServiceException(com.cloud.exception.UnsupportedServiceException) Service(com.cloud.network.Network.Service) Map(java.util.Map) HashMap(java.util.HashMap) UserDataServiceProvider(com.cloud.network.element.UserDataServiceProvider) Provider(com.cloud.network.Network.Provider)

Aggregations

Provider (com.cloud.network.Network.Provider)66 Service (com.cloud.network.Network.Service)35 HashSet (java.util.HashSet)31 HashMap (java.util.HashMap)28 Set (java.util.Set)27 StaticNatServiceProvider (com.cloud.network.element.StaticNatServiceProvider)25 UserDataServiceProvider (com.cloud.network.element.UserDataServiceProvider)25 NetworkElement (com.cloud.network.element.NetworkElement)22 ArrayList (java.util.ArrayList)19 LoadBalancingServiceProvider (com.cloud.network.element.LoadBalancingServiceProvider)18 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)18 Network (com.cloud.network.Network)17 DhcpServiceProvider (com.cloud.network.element.DhcpServiceProvider)15 DnsServiceProvider (com.cloud.network.element.DnsServiceProvider)15 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)12 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)12 Map (java.util.Map)12 ResourceLimitService (com.cloud.user.ResourceLimitService)11 NetworkOrchestrationService (org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService)11 NicProfile (com.cloud.vm.NicProfile)10