Search in sources :

Example 6 with Capability

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

the class NetworkModelImpl method getNetworkServiceCapabilities.

@Override
public Map<Capability, String> getNetworkServiceCapabilities(long networkId, Service service) {
    if (!areServicesSupportedInNetwork(networkId, service)) {
        // 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;
}
Also used : NetworkElement(com.cloud.network.element.NetworkElement) Capability(com.cloud.network.Network.Capability) HashMap(java.util.HashMap) UnsupportedServiceException(com.cloud.exception.UnsupportedServiceException) Service(com.cloud.network.Network.Service) Map(java.util.Map) HashMap(java.util.HashMap)

Example 7 with Capability

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

the class NetworkModelImpl method getNetworkCapabilities.

@Override
public Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId) {
    Map<Service, Map<Capability, String>> networkCapabilities = new HashMap<Service, Map<Capability, String>>();
    // list all services of this networkOffering
    List<NetworkServiceMapVO> servicesMap = _ntwkSrvcDao.getServicesInNetwork(networkId);
    for (NetworkServiceMapVO instance : servicesMap) {
        Service service = Service.getService(instance.getService());
        NetworkElement element = getElementImplementingProvider(instance.getProvider());
        if (element != null) {
            Map<Service, Map<Capability, String>> elementCapabilities = element.getCapabilities();
            if (elementCapabilities != null) {
                networkCapabilities.put(service, elementCapabilities.get(service));
            }
        }
    }
    return networkCapabilities;
}
Also used : NetworkElement(com.cloud.network.element.NetworkElement) Capability(com.cloud.network.Network.Capability) HashMap(java.util.HashMap) Service(com.cloud.network.Network.Service) NetworkServiceMapVO(com.cloud.network.dao.NetworkServiceMapVO) Map(java.util.Map) HashMap(java.util.HashMap)

Example 8 with Capability

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

the class NetworkModelImpl method getNetworkOfferingServiceCapabilities.

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

Example 9 with Capability

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

the class VpcManagerImpl method validateConnectivtyServiceCapabilities.

private void validateConnectivtyServiceCapabilities(final Set<Provider> providers, final Map serviceCapabilitystList) {
    if (serviceCapabilitystList != null && !serviceCapabilitystList.isEmpty()) {
        final Collection serviceCapabilityCollection = serviceCapabilitystList.values();
        final Iterator iter = serviceCapabilityCollection.iterator();
        while (iter.hasNext()) {
            final HashMap<String, String> svcCapabilityMap = (HashMap<String, String>) iter.next();
            Capability capability = null;
            final String svc = svcCapabilityMap.get(SERVICE);
            final String capabilityName = svcCapabilityMap.get(CAPABILITYTYPE);
            final String capabilityValue = svcCapabilityMap.get(CAPABILITYVALUE);
            if (capabilityName != null) {
                capability = Capability.getCapability(capabilityName);
            }
            if (capability == null || capabilityValue == null) {
                throw new InvalidParameterValueException("Invalid capability:" + capabilityName + " capability value:" + capabilityValue);
            }
            final Service usedService = Service.getService(svc);
            checkCapabilityPerServiceProvider(providers, capability, usedService);
            if (!capabilityValue.equalsIgnoreCase(TRUE_VALUE) && !capabilityValue.equalsIgnoreCase(FALSE_VALUE)) {
                throw new InvalidParameterValueException("Invalid Capability value:" + capabilityValue + " specified.");
            }
        }
    }
}
Also used : Capability(com.cloud.network.Network.Capability) HashMap(java.util.HashMap) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) Iterator(java.util.Iterator) Collection(java.util.Collection) NetworkOrchestrationService(org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService) Service(com.cloud.network.Network.Service) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) NetworkService(com.cloud.network.NetworkService) ResourceLimitService(com.cloud.user.ResourceLimitService) ExecutorService(java.util.concurrent.ExecutorService)

Example 10 with Capability

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

the class InternalLoadBalancerElement method canHandle.

private boolean canHandle(Network config, Scheme lbScheme) {
    //works in Advance zone only
    DataCenter dc = _entityMgr.findById(DataCenter.class, config.getDataCenterId());
    if (dc.getNetworkType() != NetworkType.Advanced) {
        s_logger.trace("Not hanling zone of network type " + dc.getNetworkType());
        return false;
    }
    if (config.getGuestType() != Network.GuestType.Isolated || config.getTrafficType() != TrafficType.Guest) {
        s_logger.trace("Not handling network with Type  " + config.getGuestType() + " and traffic type " + config.getTrafficType());
        return false;
    }
    Map<Capability, String> lbCaps = getCapabilities().get(Service.Lb);
    if (!lbCaps.isEmpty()) {
        String schemeCaps = lbCaps.get(Capability.LbSchemes);
        if (schemeCaps != null && lbScheme != null) {
            if (!schemeCaps.contains(lbScheme.toString())) {
                s_logger.debug("Scheme " + lbScheme.toString() + " is not supported by the provider " + getName());
                return false;
            }
        }
    }
    if (!_ntwkModel.isProviderSupportServiceInNetwork(config.getId(), Service.Lb, getProvider())) {
        s_logger.trace("Element " + getProvider().getName() + " doesn't support service " + Service.Lb + " in the network " + config);
        return false;
    }
    return true;
}
Also used : DataCenter(com.cloud.dc.DataCenter) Capability(com.cloud.network.Network.Capability)

Aggregations

Capability (com.cloud.network.Network.Capability)28 HashMap (java.util.HashMap)19 Service (com.cloud.network.Network.Service)17 Map (java.util.Map)16 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)12 Provider (com.cloud.network.Network.Provider)8 NetworkElement (com.cloud.network.element.NetworkElement)8 ArrayList (java.util.ArrayList)7 NetworkOrchestrationService (org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService)7 ResourceLimitService (com.cloud.user.ResourceLimitService)6 UnsupportedServiceException (com.cloud.exception.UnsupportedServiceException)5 Network (com.cloud.network.Network)5 NetworkService (com.cloud.network.NetworkService)4 PhysicalNetwork (com.cloud.network.PhysicalNetwork)4 UserDataServiceProvider (com.cloud.network.element.UserDataServiceProvider)4 HashSet (java.util.HashSet)4 Vpc (com.cloud.network.vpc.Vpc)3 Collection (java.util.Collection)3 Iterator (java.util.Iterator)3 Set (java.util.Set)3