Search in sources :

Example 1 with Service

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

the class VpcVirtualRouterElement method applyIps.

@Override
public boolean applyIps(final Network network, final List<? extends PublicIpAddress> ipAddress, final Set<Service> services) throws ResourceUnavailableException {
    boolean canHandle = true;
    for (final Service service : services) {
        if (!canHandle(network, service)) {
            canHandle = false;
            break;
        }
    }
    boolean result = true;
    if (canHandle) {
        final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
        if (routers == null || routers.isEmpty()) {
            s_logger.debug(getName() + " element doesn't need to associate ip addresses on the backend; VPC virtual " + "router doesn't exist in the network " + network.getId());
            return false;
        }
        final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
        final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
        for (final DomainRouterVO domainRouterVO : routers) {
            result = result && networkTopology.associatePublicIP(network, ipAddress, domainRouterVO);
        }
    }
    return result;
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) NetworkTopology(org.apache.cloudstack.network.topology.NetworkTopology) Service(com.cloud.network.Network.Service) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 2 with Service

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

the class NetworkOfferingServiceMapDaoImpl method areServicesSupportedByNetworkOffering.

@Override
public boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services) {
    SearchCriteria<NetworkOfferingServiceMapVO> sc = MultipleServicesSearch.create();
    sc.setParameters("networkOfferingId", networkOfferingId);
    if (services != null) {
        String[] servicesStr = new String[services.length];
        int i = 0;
        for (Service service : services) {
            servicesStr[i] = service.getName();
            i++;
        }
        sc.setParameters("service", (Object[]) servicesStr);
    }
    List<NetworkOfferingServiceMapVO> offeringServices = listBy(sc);
    if (services != null) {
        if (offeringServices.size() == services.length) {
            return true;
        }
    } else if (!offeringServices.isEmpty()) {
        return true;
    }
    return false;
}
Also used : NetworkOfferingServiceMapVO(com.cloud.offerings.NetworkOfferingServiceMapVO) Service(com.cloud.network.Network.Service)

Example 3 with Service

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

the class ContrailManagerImpl method locatePublicNetworkOffering.

private NetworkOffering locatePublicNetworkOffering(String offeringName, String offeringDisplayText, Provider provider) {
    List<? extends NetworkOffering> offerList = _configService.listNetworkOfferings(TrafficType.Public, 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 };
    for (Service svc : services) {
        serviceProviderMap.put(svc, providerSet);
    }
    ConfigurationManager configMgr = (ConfigurationManager) _configService;
    NetworkOfferingVO voffer = configMgr.createNetworkOffering(offeringName, offeringDisplayText, TrafficType.Public, null, true, Availability.Optional, null, serviceProviderMap, true, Network.GuestType.Shared, false, null, false, null, true, false, null, true, null, false);
    voffer.setState(NetworkOffering.State.Enabled);
    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 4 with Service

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

the class NuageVspElement method implementVpc.

@Override
public boolean implementVpc(Vpc vpc, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
    List<VpcOfferingServiceMapVO> vpcOfferingServices = _vpcOfferingSrvcDao.listByVpcOffId(vpc.getVpcOfferingId());
    Map<Network.Service, Set<Network.Provider>> supportedVpcServices = NuageVspManagerImpl.NUAGE_VSP_VPC_SERVICE_MAP;
    for (VpcOfferingServiceMapVO vpcOfferingService : vpcOfferingServices) {
        Network.Service service = Network.Service.getService(vpcOfferingService.getService());
        if (!supportedVpcServices.containsKey(service)) {
            s_logger.warn(String.format("NuageVsp doesn't support service %s for VPCs", service.getName()));
            return false;
        }
        Network.Provider provider = Network.Provider.getProvider(vpcOfferingService.getProvider());
        if (!supportedVpcServices.get(service).contains(provider)) {
            s_logger.warn(String.format("NuageVsp doesn't support provider %s for service %s for VPCs", provider.getName(), service.getName()));
            return false;
        }
    }
    return true;
}
Also used : VpcOfferingServiceMapVO(com.cloud.network.vpc.VpcOfferingServiceMapVO) Set(java.util.Set) ImmutableSet(com.google.common.collect.ImmutableSet) HashSet(java.util.HashSet) Provider(com.cloud.network.Network.Provider) Network(com.cloud.network.Network) VspNetwork(net.nuage.vsp.acs.client.api.model.VspNetwork) PhysicalNetwork(com.cloud.network.PhysicalNetwork) Service(com.cloud.network.Network.Service) Service(com.cloud.network.Network.Service)

Example 5 with Service

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

the class ApiResponseHelper method createVpcResponse.

@Override
public VpcResponse createVpcResponse(ResponseView view, Vpc vpc) {
    VpcResponse response = new VpcResponse();
    response.setId(vpc.getUuid());
    response.setName(vpc.getName());
    response.setDisplayText(vpc.getDisplayText());
    response.setState(vpc.getState().name());
    VpcOffering voff = ApiDBUtils.findVpcOfferingById(vpc.getVpcOfferingId());
    if (voff != null) {
        response.setVpcOfferingId(voff.getUuid());
    }
    response.setCidr(vpc.getCidr());
    response.setRestartRequired(vpc.isRestartRequired());
    response.setNetworkDomain(vpc.getNetworkDomain());
    response.setForDisplay(vpc.isDisplay());
    response.setUsesDistributedRouter(vpc.usesDistributedRouter());
    response.setRedundantRouter(vpc.isRedundant());
    response.setRegionLevelVpc(vpc.isRegionLevelVpc());
    Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listVpcOffServices(vpc.getVpcOfferingId());
    List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();
    for (Map.Entry<Service, Set<Provider>> entry : serviceProviderMap.entrySet()) {
        Service service = entry.getKey();
        Set<Provider> serviceProviders = entry.getValue();
        ServiceResponse svcRsp = new ServiceResponse();
        // skip gateway service
        if (service == Service.Gateway) {
            continue;
        }
        svcRsp.setName(service.getName());
        List<ProviderResponse> providers = new ArrayList<ProviderResponse>();
        for (Provider provider : serviceProviders) {
            if (provider != null) {
                ProviderResponse providerRsp = new ProviderResponse();
                providerRsp.setName(provider.getName());
                providers.add(providerRsp);
            }
        }
        svcRsp.setProviders(providers);
        serviceResponses.add(svcRsp);
    }
    List<NetworkResponse> networkResponses = new ArrayList<NetworkResponse>();
    List<? extends Network> networks = ApiDBUtils.listVpcNetworks(vpc.getId());
    for (Network network : networks) {
        NetworkResponse ntwkRsp = createNetworkResponse(view, network);
        networkResponses.add(ntwkRsp);
    }
    DataCenter zone = ApiDBUtils.findZoneById(vpc.getZoneId());
    if (zone != null) {
        response.setZoneId(zone.getUuid());
        response.setZoneName(zone.getName());
    }
    response.setNetworks(networkResponses);
    response.setServices(serviceResponses);
    populateOwner(response, vpc);
    // set tag information
    List<? extends ResourceTag> tags = ApiDBUtils.listByResourceTypeAndId(ResourceObjectType.Vpc, vpc.getId());
    List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
    for (ResourceTag tag : tags) {
        ResourceTagResponse tagResponse = createResourceTagResponse(tag, true);
        CollectionUtils.addIgnoreNull(tagResponses, tagResponse);
    }
    response.setTags(tagResponses);
    response.setObjectName("vpc");
    return response;
}
Also used : EnumSet(java.util.EnumSet) HashSet(java.util.HashSet) Set(java.util.Set) ProviderResponse(org.apache.cloudstack.api.response.ProviderResponse) VirtualRouterProviderResponse(org.apache.cloudstack.api.response.VirtualRouterProviderResponse) OvsProviderResponse(org.apache.cloudstack.api.response.OvsProviderResponse) ArrayList(java.util.ArrayList) Service(com.cloud.network.Network.Service) UsageService(org.apache.cloudstack.usage.UsageService) OvsProvider(com.cloud.network.OvsProvider) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider) Provider(com.cloud.network.Network.Provider) ServiceResponse(org.apache.cloudstack.api.response.ServiceResponse) DataCenter(com.cloud.dc.DataCenter) ResourceTag(com.cloud.server.ResourceTag) VpcResponse(org.apache.cloudstack.api.response.VpcResponse) Network(com.cloud.network.Network) PhysicalNetwork(com.cloud.network.PhysicalNetwork) VpcOffering(com.cloud.network.vpc.VpcOffering) NetworkResponse(org.apache.cloudstack.api.response.NetworkResponse) PhysicalNetworkResponse(org.apache.cloudstack.api.response.PhysicalNetworkResponse) ResourceTagResponse(org.apache.cloudstack.api.response.ResourceTagResponse) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

Service (com.cloud.network.Network.Service)76 HashMap (java.util.HashMap)40 ArrayList (java.util.ArrayList)37 Provider (com.cloud.network.Network.Provider)36 HashSet (java.util.HashSet)36 NetworkOrchestrationService (org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService)31 Set (java.util.Set)30 ResourceLimitService (com.cloud.user.ResourceLimitService)28 Map (java.util.Map)22 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)21 Network (com.cloud.network.Network)18 Capability (com.cloud.network.Network.Capability)17 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)15 NetworkElement (com.cloud.network.element.NetworkElement)14 Test (org.junit.Test)13 UserDataServiceProvider (com.cloud.network.element.UserDataServiceProvider)12 NetworkService (com.cloud.network.NetworkService)11 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)11 NetworkOffering (com.cloud.offering.NetworkOffering)10 Account (com.cloud.user.Account)10