use of com.cloud.legacymodel.network.Network.Capability in project cosmic by MissionCriticalCloud.
the class NetworkModelImpl method getNetworkServiceCapabilities.
@Override
public Map<Capability, String> getNetworkServiceCapabilities(final long networkId, final 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<>();
// get the Provider for this Service for this offering
final String provider = _ntwkSrvcDao.getProviderForServiceInNetwork(networkId, service);
final NetworkElement element = getElementImplementingProvider(provider);
if (element != null) {
final 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;
}
use of com.cloud.legacymodel.network.Network.Capability 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;
}
use of com.cloud.legacymodel.network.Network.Capability in project cosmic by MissionCriticalCloud.
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.");
}
}
}
}
use of com.cloud.legacymodel.network.Network.Capability in project cosmic by MissionCriticalCloud.
the class VpcManagerImpl method checkCapabilityPerServiceProvider.
protected void checkCapabilityPerServiceProvider(final Set<Provider> providers, final Capability capability, final Service service) {
// TODO Shouldn't it fail it there are no providers?
if (providers != null) {
for (final Provider provider : providers) {
final NetworkElement element = _ntwkModel.getElementImplementingProvider(provider.getName());
final Map<Service, Map<Capability, String>> capabilities = element.getCapabilities();
if (capabilities != null && !capabilities.isEmpty()) {
final Map<Capability, String> connectivityCapabilities = capabilities.get(service);
if (connectivityCapabilities == null || connectivityCapabilities != null && !connectivityCapabilities.keySet().contains(capability)) {
throw new InvalidParameterValueException(String.format("Provider %s does not support %s capability.", provider.getName(), capability.getName()));
}
}
}
}
}
use of com.cloud.legacymodel.network.Network.Capability in project cosmic by MissionCriticalCloud.
the class VpcVirtualRouterElement method startSite2SiteVpn.
@Override
public boolean startSite2SiteVpn(final Site2SiteVpnConnection conn) throws ResourceUnavailableException {
final Site2SiteVpnGateway vpnGw = _vpnGatewayDao.findById(conn.getVpnGatewayId());
final IpAddress ip = _ipAddressDao.findById(vpnGw.getAddrId());
final Map<Capability, String> vpnCapabilities = capabilities.get(Service.Vpn);
if (!vpnCapabilities.get(Capability.VpnTypes).contains("s2svpn")) {
s_logger.error("try to start site 2 site vpn on unsupported network element?");
return false;
}
final Long vpcId = ip.getVpcId();
final Vpc vpc = _entityMgr.findById(Vpc.class, vpcId);
if (!_ntwkModel.isProviderEnabledInZone(vpc.getZoneId(), Provider.VPCVirtualRouter.getName())) {
throw new ResourceUnavailableException("VPC provider is not enabled in zone " + vpc.getZoneId(), DataCenter.class, vpc.getZoneId());
}
final List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(ip.getVpcId());
if (routers == null) {
throw new ResourceUnavailableException("Cannot enable site-to-site VPN on the backend; virtual router doesn't exist in the vpc " + ip.getVpcId(), DataCenter.class, vpc.getZoneId());
}
boolean result = true;
for (final DomainRouterVO domainRouterVO : routers) {
result = result && _vpcRouterMgr.startSite2SiteVpn(conn, domainRouterVO);
}
return result;
}
Aggregations