Search in sources :

Example 31 with DeployDestination

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

the class VxlanGuestNetworkGuruTest method testImplementWithCidr.

@Test
public void testImplementWithCidr() throws InsufficientVirtualNetworkCapacityException {
    PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
    when(physnetdao.findById(anyLong())).thenReturn(physnet);
    when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VXLAN" }));
    when(physnet.getId()).thenReturn(42L);
    NetworkOffering offering = mock(NetworkOffering.class);
    when(offering.getId()).thenReturn(42L);
    when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
    when(offering.getGuestType()).thenReturn(GuestType.Isolated);
    NetworkVO network = mock(NetworkVO.class);
    when(network.getName()).thenReturn("testnetwork");
    when(network.getState()).thenReturn(State.Implementing);
    when(network.getGateway()).thenReturn("10.1.1.1");
    when(network.getCidr()).thenReturn("10.1.1.0/24");
    when(network.getPhysicalNetworkId()).thenReturn(42L);
    DeployDestination dest = mock(DeployDestination.class);
    DataCenter dc = mock(DataCenter.class);
    when(dest.getDataCenter()).thenReturn(dc);
    when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
    //TODO(VXLAN): doesn't support VNI specified
    //when(confsvr.getConfigValue((String) any(), (String) any(), anyLong())).thenReturn("true");
    when(dcdao.allocateVnet(anyLong(), anyLong(), anyLong(), (String) any(), eq(true))).thenReturn("42");
    doNothing().when(guru).allocateVnetComplete((Network) any(), (NetworkVO) any(), anyLong(), anyLong(), (String) any(), eq("42"));
    Domain dom = mock(Domain.class);
    when(dom.getName()).thenReturn("domain");
    Account acc = mock(Account.class);
    when(acc.getAccountName()).thenReturn("accountname");
    ReservationContext res = mock(ReservationContext.class);
    when(res.getDomain()).thenReturn(dom);
    when(res.getAccount()).thenReturn(acc);
    Network implementednetwork = guru.implement(network, offering, dest, res);
    assertTrue(implementednetwork != null);
    assertTrue(implementednetwork.getCidr().equals("10.1.1.0/24"));
    assertTrue(implementednetwork.getGateway().equals("10.1.1.1"));
}
Also used : Account(com.cloud.user.Account) NetworkVO(com.cloud.network.dao.NetworkVO) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) DataCenter(com.cloud.dc.DataCenter) NetworkOffering(com.cloud.offering.NetworkOffering) DeployDestination(com.cloud.deploy.DeployDestination) Network(com.cloud.network.Network) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) Domain(com.cloud.domain.Domain) ReservationContext(com.cloud.vm.ReservationContext) Test(org.junit.Test)

Example 32 with DeployDestination

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

the class VxlanGuestNetworkGuruTest method testShutdown.

@Test
public void testShutdown() throws InsufficientVirtualNetworkCapacityException, URISyntaxException {
    PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
    when(physnetdao.findById(anyLong())).thenReturn(physnet);
    when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VXLAN" }));
    when(physnet.getId()).thenReturn(42L);
    NetworkOffering offering = mock(NetworkOffering.class);
    when(offering.getId()).thenReturn(42L);
    when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
    when(offering.getGuestType()).thenReturn(GuestType.Isolated);
    NetworkVO network = mock(NetworkVO.class);
    when(network.getName()).thenReturn("testnetwork");
    when(network.getState()).thenReturn(State.Implementing);
    when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vxlan);
    when(network.getBroadcastUri()).thenReturn(new URI("vxlan:12345"));
    when(network.getPhysicalNetworkId()).thenReturn(42L);
    when(netdao.findById(42L)).thenReturn(network);
    DeployDestination dest = mock(DeployDestination.class);
    DataCenter dc = mock(DataCenter.class);
    when(dest.getDataCenter()).thenReturn(dc);
    when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
    Domain dom = mock(Domain.class);
    when(dom.getName()).thenReturn("domain");
    Account acc = mock(Account.class);
    when(acc.getAccountName()).thenReturn("accountname");
    ReservationContext res = mock(ReservationContext.class);
    when(res.getDomain()).thenReturn(dom);
    when(res.getAccount()).thenReturn(acc);
    NetworkProfile implementednetwork = mock(NetworkProfile.class);
    when(implementednetwork.getId()).thenReturn(42L);
    when(implementednetwork.getBroadcastUri()).thenReturn(new URI("vxlan:12345"));
    when(offering.getSpecifyVlan()).thenReturn(false);
    guru.shutdown(implementednetwork, offering);
    verify(implementednetwork, times(1)).setBroadcastUri(null);
}
Also used : Account(com.cloud.user.Account) NetworkVO(com.cloud.network.dao.NetworkVO) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkProfile(com.cloud.network.NetworkProfile) DataCenter(com.cloud.dc.DataCenter) NetworkOffering(com.cloud.offering.NetworkOffering) DeployDestination(com.cloud.deploy.DeployDestination) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) Domain(com.cloud.domain.Domain) URI(java.net.URI) ReservationContext(com.cloud.vm.ReservationContext) Test(org.junit.Test)

Example 33 with DeployDestination

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

the class DeploymentPlanningManagerImplTest method emptyClusterListTest.

@Test
public void emptyClusterListTest() throws InsufficientServerCapacityException, AffinityConflictException {
    ServiceOfferingVO svcOffering = new ServiceOfferingVO("testOffering", 1, 512, 500, 1, 1, false, false, false, "test dpm", ProvisioningType.THIN, false, false, null, false, VirtualMachine.Type.User, domainId, null, "FirstFitPlanner");
    Mockito.when(vmProfile.getServiceOffering()).thenReturn(svcOffering);
    DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
    Mockito.when(avoids.shouldAvoid((DataCenterVO) Matchers.anyObject())).thenReturn(false);
    Mockito.when(_planner.canHandle(vmProfile, plan, avoids)).thenReturn(true);
    Mockito.when(((DeploymentClusterPlanner) _planner).orderClusters(vmProfile, plan, avoids)).thenReturn(null);
    DeployDestination dest = _dpm.planDeployment(vmProfile, plan, avoids, null);
    assertNull("Planner cannot handle, destination should be null! ", dest);
}
Also used : DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) DeploymentClusterPlanner(com.cloud.deploy.DeploymentClusterPlanner) DeployDestination(com.cloud.deploy.DeployDestination) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO) Test(org.junit.Test)

Example 34 with DeployDestination

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

the class DeploymentPlanningManagerImplTest method dataCenterAvoidTest.

@Test
public void dataCenterAvoidTest() throws InsufficientServerCapacityException, AffinityConflictException {
    ServiceOfferingVO svcOffering = new ServiceOfferingVO("testOffering", 1, 512, 500, 1, 1, false, false, false, "test dpm", ProvisioningType.THIN, false, false, null, false, VirtualMachine.Type.User, domainId, null, "FirstFitPlanner");
    Mockito.when(vmProfile.getServiceOffering()).thenReturn(svcOffering);
    DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
    Mockito.when(avoids.shouldAvoid((DataCenterVO) Matchers.anyObject())).thenReturn(true);
    DeployDestination dest = _dpm.planDeployment(vmProfile, plan, avoids, null);
    assertNull("DataCenter is in avoid set, destination should be null! ", dest);
}
Also used : DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) DeployDestination(com.cloud.deploy.DeployDestination) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO) Test(org.junit.Test)

Example 35 with DeployDestination

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

the class DeploymentPlanningManagerImplTest method plannerCannotHandleTest.

@Test
public void plannerCannotHandleTest() throws InsufficientServerCapacityException, AffinityConflictException {
    ServiceOfferingVO svcOffering = new ServiceOfferingVO("testOffering", 1, 512, 500, 1, 1, false, false, false, "test dpm", ProvisioningType.THIN, false, false, null, false, VirtualMachine.Type.User, domainId, null, "UserDispersingPlanner");
    Mockito.when(vmProfile.getServiceOffering()).thenReturn(svcOffering);
    DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
    Mockito.when(avoids.shouldAvoid((DataCenterVO) Matchers.anyObject())).thenReturn(false);
    Mockito.when(_planner.canHandle(vmProfile, plan, avoids)).thenReturn(false);
    DeployDestination dest = _dpm.planDeployment(vmProfile, plan, avoids, null);
    assertNull("Planner cannot handle, destination should be null! ", dest);
}
Also used : DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) DeployDestination(com.cloud.deploy.DeployDestination) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO) Test(org.junit.Test)

Aggregations

DeployDestination (com.cloud.deploy.DeployDestination)56 DataCenter (com.cloud.dc.DataCenter)27 Account (com.cloud.user.Account)27 Test (org.junit.Test)27 ReservationContext (com.cloud.vm.ReservationContext)26 HostVO (com.cloud.host.HostVO)19 Network (com.cloud.network.Network)18 NetworkVO (com.cloud.network.dao.NetworkVO)18 NetworkOffering (com.cloud.offering.NetworkOffering)18 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)18 Domain (com.cloud.domain.Domain)17 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)15 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)15 URI (java.net.URI)13 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)12 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)11 ArrayList (java.util.ArrayList)11 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)8 Host (com.cloud.host.Host)8 NiciraNvpDeviceVO (com.cloud.network.NiciraNvpDeviceVO)8