Search in sources :

Example 51 with Service

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

the class F5ExternalLoadBalancerElement method getCapabilities.

@Override
public Map<Service, Map<Capability, String>> getCapabilities() {
    Map<Service, Map<Capability, String>> capabilities = new HashMap<Service, Map<Capability, String>>();
    // Set capabilities for LB service
    Map<Capability, String> lbCapabilities = new HashMap<Capability, String>();
    // Specifies that the RoundRobin and Leastconn algorithms are supported for load balancing rules
    lbCapabilities.put(Capability.SupportedLBAlgorithms, "roundrobin,leastconn");
    // specifies that F5 BIG IP network element can provide shared mode only
    lbCapabilities.put(Capability.SupportedLBIsolation, "dedicated, shared");
    // Specifies that load balancing rules can be made for either TCP or UDP traffic
    lbCapabilities.put(Capability.SupportedProtocols, "tcp,udp");
    // Specifies that this element can measure network usage on a per public IP basis
    lbCapabilities.put(Capability.TrafficStatistics, "per public ip");
    // Specifies that load balancing rules can only be made with public IPs that aren't source NAT IPs
    lbCapabilities.put(Capability.LoadBalancingSupportedIps, "additional");
    // Support inline mode with firewall
    lbCapabilities.put(Capability.InlineMode, "true");
    //support only for public lb
    lbCapabilities.put(Capability.LbSchemes, LoadBalancerContainer.Scheme.Public.toString());
    LbStickinessMethod method;
    List<LbStickinessMethod> methodList = new ArrayList<LbStickinessMethod>();
    method = new LbStickinessMethod(StickinessMethodType.LBCookieBased, "This is cookie based sticky method, can be used only for http");
    methodList.add(method);
    method.addParam("holdtime", false, "time period (in seconds) for which persistence is in effect.", false);
    Gson gson = new Gson();
    String stickyMethodList = gson.toJson(methodList);
    lbCapabilities.put(Capability.SupportedStickinessMethods, stickyMethodList);
    capabilities.put(Service.Lb, lbCapabilities);
    return capabilities;
}
Also used : Capability(com.cloud.network.Network.Capability) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Service(com.cloud.network.Network.Service) Gson(com.google.gson.Gson) Map(java.util.Map) HashMap(java.util.HashMap) LbStickinessMethod(com.cloud.network.rules.LbStickinessMethod)

Example 52 with Service

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

the class NiciraNvpElementTest method applyIpTest.

@Test
public void applyIpTest() throws ResourceUnavailableException {
    final Network network = mock(Network.class);
    when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
    when(network.getId()).thenReturn(NETWORK_ID);
    when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
    final NetworkOffering offering = mock(NetworkOffering.class);
    when(offering.getId()).thenReturn(NETWORK_ID);
    when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
    when(offering.getGuestType()).thenReturn(GuestType.Isolated);
    final List<PublicIpAddress> ipAddresses = new ArrayList<PublicIpAddress>();
    final PublicIpAddress pipReleased = mock(PublicIpAddress.class);
    final PublicIpAddress pipAllocated = mock(PublicIpAddress.class);
    final Ip ipReleased = new Ip("42.10.10.10");
    final Ip ipAllocated = new Ip("10.10.10.10");
    when(pipAllocated.getState()).thenReturn(IpAddress.State.Allocated);
    when(pipAllocated.getAddress()).thenReturn(ipAllocated);
    when(pipAllocated.getNetmask()).thenReturn("255.255.255.0");
    when(pipReleased.getState()).thenReturn(IpAddress.State.Releasing);
    when(pipReleased.getAddress()).thenReturn(ipReleased);
    when(pipReleased.getNetmask()).thenReturn("255.255.255.0");
    ipAddresses.add(pipAllocated);
    ipAddresses.add(pipReleased);
    final Set<Service> services = new HashSet<Service>();
    services.add(Service.SourceNat);
    services.add(Service.StaticNat);
    services.add(Service.PortForwarding);
    final List<NiciraNvpDeviceVO> deviceList = new ArrayList<NiciraNvpDeviceVO>();
    final NiciraNvpDeviceVO nndVO = mock(NiciraNvpDeviceVO.class);
    final NiciraNvpRouterMappingVO nnrmVO = mock(NiciraNvpRouterMappingVO.class);
    when(niciraNvpRouterMappingDao.findByNetworkId(NETWORK_ID)).thenReturn(nnrmVO);
    when(nnrmVO.getLogicalRouterUuid()).thenReturn("abcde");
    when(nndVO.getHostId()).thenReturn(NETWORK_ID);
    final HostVO hvo = mock(HostVO.class);
    when(hvo.getId()).thenReturn(NETWORK_ID);
    when(hvo.getDetail("l3gatewayserviceuuid")).thenReturn("abcde");
    when(hostDao.findById(NETWORK_ID)).thenReturn(hvo);
    deviceList.add(nndVO);
    when(niciraNvpDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(deviceList);
    final ConfigurePublicIpsOnLogicalRouterAnswer answer = mock(ConfigurePublicIpsOnLogicalRouterAnswer.class);
    when(answer.getResult()).thenReturn(true);
    when(agentManager.easySend(eq(NETWORK_ID), any(ConfigurePublicIpsOnLogicalRouterCommand.class))).thenReturn(answer);
    assertTrue(element.applyIps(network, ipAddresses, services));
    verify(agentManager, atLeast(1)).easySend(eq(NETWORK_ID), argThat(new ArgumentMatcher<ConfigurePublicIpsOnLogicalRouterCommand>() {

        @Override
        public boolean matches(final Object argument) {
            final ConfigurePublicIpsOnLogicalRouterCommand command = (ConfigurePublicIpsOnLogicalRouterCommand) argument;
            if (command.getPublicCidrs().size() == 1)
                return true;
            return false;
        }
    }));
}
Also used : NetworkOffering(com.cloud.offering.NetworkOffering) Ip(com.cloud.utils.net.Ip) PublicIp(com.cloud.network.addr.PublicIp) NiciraNvpDeviceVO(com.cloud.network.NiciraNvpDeviceVO) ArrayList(java.util.ArrayList) NetworkOrchestrationService(org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService) Service(com.cloud.network.Network.Service) HostVO(com.cloud.host.HostVO) PublicIpAddress(com.cloud.network.PublicIpAddress) NiciraNvpRouterMappingVO(com.cloud.network.NiciraNvpRouterMappingVO) Network(com.cloud.network.Network) ArgumentMatcher(org.mockito.ArgumentMatcher) ConfigurePublicIpsOnLogicalRouterAnswer(com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterAnswer) ConfigurePublicIpsOnLogicalRouterCommand(com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterCommand) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 53 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 54 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 55 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)

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