Search in sources :

Example 11 with DeploymentPlan

use of com.cloud.deploy.DeploymentPlan in project cloudstack by apache.

the class BrocadeVcsGuestNetworkGuruTest method testDesignNoConnectivityInOffering.

@Test
public void testDesignNoConnectivityInOffering() {
    final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
    when(physnetdao.findById((Long) any())).thenReturn(physnet);
    when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VCS" }));
    when(physnet.getId()).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);
    when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(false);
    final DeploymentPlan plan = mock(DeploymentPlan.class);
    final Network network = mock(Network.class);
    final Account account = mock(Account.class);
    final Network designednetwork = guru.design(offering, plan, network, account);
    assertTrue(designednetwork == null);
}
Also used : Account(com.cloud.user.Account) NetworkOffering(com.cloud.offering.NetworkOffering) Network(com.cloud.network.Network) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) DeploymentPlan(com.cloud.deploy.DeploymentPlan) Test(org.junit.Test)

Example 12 with DeploymentPlan

use of com.cloud.deploy.DeploymentPlan in project cloudstack by apache.

the class NuageVspGuestNetworkGuruTest method testDesign.

@Test
public void testDesign() {
    final NuageVspDeviceVO device = mock(NuageVspDeviceVO.class);
    when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(device));
    when(device.getId()).thenReturn(1L);
    final NetworkOffering offering = mock(NetworkOffering.class);
    when(offering.getId()).thenReturn(NETWORK_ID);
    when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
    when(offering.getGuestType()).thenReturn(GuestType.Isolated);
    when(offering.getIsPersistent()).thenReturn(false);
    when(_configurationManager.isOfferingForVpc(any(NetworkOffering.class))).thenReturn(false);
    when(_networkOfferingServiceMapDao.canProviderSupportServiceInNetworkOffering(NETWORK_ID, Service.Connectivity, Network.Provider.NuageVsp)).thenReturn(true);
    when(_networkOfferingServiceMapDao.canProviderSupportServiceInNetworkOffering(NETWORK_ID, Service.SourceNat, Network.Provider.NuageVsp)).thenReturn(true);
    when(_networkModel.getNetworkOfferingServiceProvidersMap(NETWORK_ID)).thenReturn(ImmutableMap.of(Service.Connectivity, Sets.newSet(Network.Provider.NuageVsp), Service.SourceNat, Sets.newSet(Network.Provider.NuageVsp)));
    final DeploymentPlan plan = mock(DeploymentPlan.class);
    final Network network = mock(Network.class);
    final Account account = mock(Account.class);
    final Network designednetwork = _nuageVspGuestNetworkGuru.design(offering, plan, network, account);
    assertThat(designednetwork, notNullValue(Network.class));
    assertThat(designednetwork.getBroadcastDomainType(), is(BroadcastDomainType.Vsp));
    // Can't design non-persistent VPC tier
    when(_configurationManager.isOfferingForVpc(any(NetworkOffering.class))).thenReturn(true);
    assertThat(_nuageVspGuestNetworkGuru.design(offering, plan, network, account), nullValue(Network.class));
}
Also used : NuageVspDeviceVO(com.cloud.network.NuageVspDeviceVO) Account(com.cloud.user.Account) NetworkOffering(com.cloud.offering.NetworkOffering) Network(com.cloud.network.Network) DeploymentPlan(com.cloud.deploy.DeploymentPlan) NuageTest(com.cloud.NuageTest) Test(org.junit.Test)

Example 13 with DeploymentPlan

use of com.cloud.deploy.DeploymentPlan in project cloudstack by apache.

the class InternalLoadBalancerVMManagerImpl method findOrDeployInternalLbVm.

@DB
protected List<DomainRouterVO> findOrDeployInternalLbVm(final Network guestNetwork, final Ip requestedGuestIp, final DeployDestination dest, final Account owner, final Map<Param, Object> params) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
    List<DomainRouterVO> internalLbVms = new ArrayList<DomainRouterVO>();
    final Network lock = _networkDao.acquireInLockTable(guestNetwork.getId(), NetworkOrchestrationService.NetworkLockTimeout.value());
    if (lock == null) {
        throw new ConcurrentOperationException("Unable to lock network " + guestNetwork.getId());
    }
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Lock is acquired for network id " + lock.getId() + " as a part of internal lb startup in " + dest);
    }
    final long internalLbProviderId = getInternalLbProviderId(guestNetwork);
    try {
        assert guestNetwork.getState() == Network.State.Implemented || guestNetwork.getState() == Network.State.Setup || guestNetwork.getState() == Network.State.Implementing : "Network is not yet fully implemented: " + guestNetwork;
        assert guestNetwork.getTrafficType() == TrafficType.Guest;
        //deploy internal lb vm
        final Pair<DeploymentPlan, List<DomainRouterVO>> planAndInternalLbVms = getDeploymentPlanAndInternalLbVms(dest, guestNetwork.getId(), requestedGuestIp);
        internalLbVms = planAndInternalLbVms.second();
        final DeploymentPlan plan = planAndInternalLbVms.first();
        if (internalLbVms.size() > 0) {
            s_logger.debug("Found " + internalLbVms.size() + " internal lb vms for the requested IP " + requestedGuestIp.addr());
            return internalLbVms;
        }
        final LinkedHashMap<Network, List<? extends NicProfile>> networks = createInternalLbVmNetworks(guestNetwork, plan, requestedGuestIp);
        long internalLbVmOfferingId = _internalLbVmOfferingId;
        if (internalLbVmOfferingId == 0L) {
            ServiceOfferingVO serviceOffering = _serviceOfferingDao.findDefaultSystemOffering(ServiceOffering.internalLbVmDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()));
            internalLbVmOfferingId = serviceOffering.getId();
        }
        //Pass startVm=false as we are holding the network lock that needs to be released at the end of vm allocation
        final DomainRouterVO internalLbVm = deployInternalLbVm(owner, dest, plan, params, internalLbProviderId, internalLbVmOfferingId, guestNetwork.getVpcId(), networks, false);
        if (internalLbVm != null) {
            _internalLbVmDao.addRouterToGuestNetwork(internalLbVm, guestNetwork);
            internalLbVms.add(internalLbVm);
        }
    } finally {
        if (lock != null) {
            _networkDao.releaseFromLockTable(lock.getId());
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Lock is released for network id " + lock.getId() + " as a part of internal lb vm startup in " + dest);
            }
        }
    }
    return internalLbVms;
}
Also used : Network(com.cloud.network.Network) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DeploymentPlan(com.cloud.deploy.DeploymentPlan) NicProfile(com.cloud.vm.NicProfile) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO) DomainRouterVO(com.cloud.vm.DomainRouterVO) DB(com.cloud.utils.db.DB)

Example 14 with DeploymentPlan

use of com.cloud.deploy.DeploymentPlan in project cloudstack by apache.

the class NiciraNvpGuestNetworkGuruTest method testDesignNoIsolationMethodSTT.

@Test
public void testDesignNoIsolationMethodSTT() {
    final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
    when(physnetdao.findById((Long) any())).thenReturn(physnet);
    when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VLAN" }));
    when(physnet.getId()).thenReturn(NETWORK_ID);
    mock(NiciraNvpDeviceVO.class);
    when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Collections.<NiciraNvpDeviceVO>emptyList());
    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 DeploymentPlan plan = mock(DeploymentPlan.class);
    final Network network = mock(Network.class);
    final Account account = mock(Account.class);
    final Network designednetwork = guru.design(offering, plan, network, account);
    assertTrue(designednetwork == null);
}
Also used : Account(com.cloud.user.Account) NetworkOffering(com.cloud.offering.NetworkOffering) Network(com.cloud.network.Network) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) DeploymentPlan(com.cloud.deploy.DeploymentPlan) Test(org.junit.Test)

Example 15 with DeploymentPlan

use of com.cloud.deploy.DeploymentPlan in project cloudstack by apache.

the class NiciraNvpGuestNetworkGuruTest method testDesign.

@Test
public void testDesign() {
    final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
    when(physnetdao.findById((Long) any())).thenReturn(physnet);
    when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT", "VXLAN" }));
    when(physnet.getId()).thenReturn(NETWORK_ID);
    final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
    when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
    when(device.getId()).thenReturn(1L);
    final NetworkOffering offering = mock(NetworkOffering.class);
    when(offering.getId()).thenReturn(NETWORK_ID);
    when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
    when(offering.getGuestType()).thenReturn(GuestType.Isolated);
    when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(true);
    final DeploymentPlan plan = mock(DeploymentPlan.class);
    final Network network = mock(Network.class);
    final Account account = mock(Account.class);
    final Network designednetwork = guru.design(offering, plan, network, account);
    assertTrue(designednetwork != null);
    assertTrue(designednetwork.getBroadcastDomainType() == BroadcastDomainType.Lswitch);
}
Also used : Account(com.cloud.user.Account) NetworkOffering(com.cloud.offering.NetworkOffering) NiciraNvpDeviceVO(com.cloud.network.NiciraNvpDeviceVO) Network(com.cloud.network.Network) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) DeploymentPlan(com.cloud.deploy.DeploymentPlan) Test(org.junit.Test)

Aggregations

DeploymentPlan (com.cloud.deploy.DeploymentPlan)22 Test (org.junit.Test)19 Network (com.cloud.network.Network)12 Account (com.cloud.user.Account)12 NetworkOffering (com.cloud.offering.NetworkOffering)11 DataCenterDeployment (com.cloud.deploy.DataCenterDeployment)10 ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)8 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)8 StoragePool (com.cloud.storage.StoragePool)8 Volume (com.cloud.storage.Volume)8 DiskProfile (com.cloud.vm.DiskProfile)8 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)8 StoragePoolAllocator (org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator)8 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)5 NuageTest (com.cloud.NuageTest)3 DiskOfferingVO (com.cloud.storage.DiskOfferingVO)3 ArrayList (java.util.ArrayList)3 NiciraNvpDeviceVO (com.cloud.network.NiciraNvpDeviceVO)2 DomainRouterVO (com.cloud.vm.DomainRouterVO)2 StoragePoolDetailVO (org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO)2