Search in sources :

Example 56 with Service

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

the class NetscalerElement method verifyServicesCombination.

@Override
public boolean verifyServicesCombination(Set<Service> services) {
    Set<Service> netscalerServices = new HashSet<Service>();
    netscalerServices.add(Service.Lb);
    netscalerServices.add(Service.StaticNat);
    // NetScaler can only act as Lb and Static Nat service provider
    if (services != null && !services.isEmpty() && !netscalerServices.containsAll(services)) {
        s_logger.warn("NetScaler network element can only support LB and Static NAT services and service combination " + services + " is not supported.");
        StringBuffer buff = new StringBuffer();
        for (Service service : services) {
            buff.append(service.getName());
            buff.append(" ");
        }
        s_logger.warn("NetScaler network element can only support LB and Static NAT services and service combination " + buff.toString() + " is not supported.");
        s_logger.warn("NetScaler network element can only support LB and Static NAT services and service combination " + services + " is not supported.");
        return false;
    }
    return true;
}
Also used : Service(com.cloud.network.Network.Service) HashSet(java.util.HashSet)

Example 57 with Service

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

the class ApiResponseHelper method createNetworkServiceProviderResponse.

@Override
public ProviderResponse createNetworkServiceProviderResponse(PhysicalNetworkServiceProvider result) {
    ProviderResponse response = new ProviderResponse();
    response.setId(result.getUuid());
    response.setName(result.getProviderName());
    PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(result.getPhysicalNetworkId());
    if (pnw != null) {
        response.setPhysicalNetworkId(pnw.getUuid());
    }
    PhysicalNetwork dnw = ApiDBUtils.findPhysicalNetworkById(result.getDestinationPhysicalNetworkId());
    if (dnw != null) {
        response.setDestinationPhysicalNetworkId(dnw.getUuid());
    }
    response.setState(result.getState().toString());
    // set enabled services
    List<String> services = new ArrayList<String>();
    for (Service service : result.getEnabledServices()) {
        services.add(service.getName());
    }
    response.setServices(services);
    Provider serviceProvider = Provider.getProvider(result.getProviderName());
    boolean canEnableIndividualServices = ApiDBUtils.canElementEnableIndividualServices(serviceProvider);
    response.setCanEnableIndividualServices(canEnableIndividualServices);
    response.setObjectName("networkserviceprovider");
    return response;
}
Also used : ProviderResponse(org.apache.cloudstack.api.response.ProviderResponse) VirtualRouterProviderResponse(org.apache.cloudstack.api.response.VirtualRouterProviderResponse) OvsProviderResponse(org.apache.cloudstack.api.response.OvsProviderResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork) 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)

Example 58 with Service

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

the class CreateNetworkOfferingTest method createIsolatedNtwkOffWithSpecifyIpRangesAndNoSourceNat.

@Test
public void createIsolatedNtwkOffWithSpecifyIpRangesAndNoSourceNat() {
    Map<Service, Set<Provider>> serviceProviderMap = new HashMap<Network.Service, Set<Network.Provider>>();
    Set<Network.Provider> vrProvider = new HashSet<Network.Provider>();
    NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, false, Availability.Optional, 200, serviceProviderMap, false, Network.GuestType.Isolated, false, null, false, null, true, false, null, false, null, true);
    assertNotNull("Isolated network offering with specifyIpRanges=true and with no sourceNatService, failed to create", off);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) Network(com.cloud.network.Network) Service(com.cloud.network.Network.Service) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) Provider(com.cloud.network.Network.Provider) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 59 with Service

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

the class CreateNetworkOfferingTest method createVpcNtwkOffWithNetscaler.

@Test
public void createVpcNtwkOffWithNetscaler() {
    Map<Service, Set<Provider>> serviceProviderMap = new HashMap<Network.Service, Set<Network.Provider>>();
    Set<Network.Provider> vrProvider = new HashSet<Network.Provider>();
    Set<Network.Provider> lbProvider = new HashSet<Network.Provider>();
    vrProvider.add(Provider.VPCVirtualRouter);
    lbProvider.add(Provider.Netscaler);
    serviceProviderMap.put(Network.Service.Dhcp, vrProvider);
    serviceProviderMap.put(Network.Service.Dns, vrProvider);
    serviceProviderMap.put(Network.Service.Lb, vrProvider);
    serviceProviderMap.put(Network.Service.SourceNat, vrProvider);
    serviceProviderMap.put(Network.Service.Gateway, vrProvider);
    serviceProviderMap.put(Network.Service.Lb, lbProvider);
    NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, true, Availability.Optional, 200, serviceProviderMap, false, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true);
    // System.out.println("Creating Vpc Network Offering");
    assertNotNull("Vpc Isolated network offering with Vpc and Netscaler provider ", off);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) Network(com.cloud.network.Network) Service(com.cloud.network.Network.Service) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) Provider(com.cloud.network.Network.Provider) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 60 with Service

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

the class CreateNetworkOfferingTest method createIsolatedNtwkOffWithSpecifyIpRangesAndSourceNat.

@Test(expected = InvalidParameterValueException.class)
public void createIsolatedNtwkOffWithSpecifyIpRangesAndSourceNat() {
    Map<Service, Set<Provider>> serviceProviderMap = new HashMap<Network.Service, Set<Network.Provider>>();
    Set<Network.Provider> vrProvider = new HashSet<Network.Provider>();
    vrProvider.add(Provider.VirtualRouter);
    serviceProviderMap.put(Network.Service.SourceNat, vrProvider);
    NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, false, Availability.Optional, 200, serviceProviderMap, false, Network.GuestType.Isolated, false, null, false, null, true, false, null, false, null, true);
    assertNull("Isolated network offering with specifyIpRanges=true and source nat service enabled, was created", off);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) Network(com.cloud.network.Network) Service(com.cloud.network.Network.Service) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) Provider(com.cloud.network.Network.Provider) HashSet(java.util.HashSet) Test(org.junit.Test)

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