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);
}
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;
}
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);
}
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;
}
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;
}
Aggregations