Search in sources :

Example 86 with DataCenterDeployment

use of com.cloud.deploy.DataCenterDeployment in project cosmic by MissionCriticalCloud.

the class RouterDeploymentDefinition method generateDeploymentPlan.

protected void generateDeploymentPlan() {
    final long dcId = dest.getZone().getId();
    Long podId = null;
    if (isBasic()) {
        if (dest.getPod() == null) {
            throw new CloudRuntimeException("Pod id is expected in deployment destination");
        }
        podId = dest.getPod().getId();
    }
    plan = new DataCenterDeployment(dcId, podId, null, null, null, null);
}
Also used : DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException)

Example 87 with DataCenterDeployment

use of com.cloud.deploy.DataCenterDeployment in project cosmic by MissionCriticalCloud.

the class ImplicitPlannerTest method checkWhenDcInAvoidList.

@Test
public void checkWhenDcInAvoidList() throws InsufficientServerCapacityException {
    final Zone zone = mock(Zone.class);
    final ExcludeList avoids = mock(ExcludeList.class);
    final VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    final VMInstanceVO vm = mock(VMInstanceVO.class);
    final DataCenterDeployment plan = mock(DataCenterDeployment.class);
    when(avoids.shouldAvoid(zone)).thenReturn(true);
    when(vmProfile.getVirtualMachine()).thenReturn(vm);
    when(vm.getDataCenterId()).thenReturn(1L);
    when(zoneRepository.findById(1L)).thenReturn(Optional.of(zone));
    final List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);
    assertTrue("Cluster list should be null/empty if the dc is in avoid list", (clusterList == null || clusterList.isEmpty()));
}
Also used : ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) VirtualMachineProfileImpl(com.cloud.vm.VirtualMachineProfileImpl) Zone(com.cloud.db.model.Zone) VMInstanceVO(com.cloud.vm.VMInstanceVO) Test(org.junit.Test)

Example 88 with DataCenterDeployment

use of com.cloud.deploy.DataCenterDeployment in project cosmic by MissionCriticalCloud.

the class ImplicitPlannerTest method checkPreferredModePreferredHostAvailable.

@Test
public void checkPreferredModePreferredHostAvailable() throws InsufficientServerCapacityException {
    final VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    final DataCenterDeployment plan = mock(DataCenterDeployment.class);
    final ExcludeList avoids = new ExcludeList();
    initializeForTest(vmProfile, plan);
    initializeForImplicitPlannerTest(true);
    // Mark the host 5 and 6 to be in avoid list.
    avoids.addHost(5L);
    avoids.addHost(6L);
    final List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);
    // Validations.
    // Check cluster 1 and 2 are not in the cluster list.
    // Host 5 and 6 should also be in avoid list.
    assertFalse("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty()));
    boolean foundNeededCluster = false;
    for (final Long cluster : clusterList) {
        if (cluster != 3) {
            fail("Found a cluster that shouldn't have been present, cluster id : " + cluster);
        } else {
            foundNeededCluster = true;
        }
    }
    assertTrue("Didn't find cluster 3 in the list. It should have been present", foundNeededCluster);
    final Set<Long> hostsInAvoidList = avoids.getHostsToAvoid();
    assertFalse("Host 7 shouldn't have be in the avoid list, but it is present", hostsInAvoidList.contains(7L));
    final Set<Long> hostsThatShouldBeInAvoidList = new HashSet<>();
    hostsThatShouldBeInAvoidList.add(5L);
    hostsThatShouldBeInAvoidList.add(6L);
    assertTrue("Hosts 5 and 6 that should have been present were not found in avoid list", hostsInAvoidList.containsAll(hostsThatShouldBeInAvoidList));
}
Also used : ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) VirtualMachineProfileImpl(com.cloud.vm.VirtualMachineProfileImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 89 with DataCenterDeployment

use of com.cloud.deploy.DataCenterDeployment in project cosmic by MissionCriticalCloud.

the class ImplicitPlannerTest method checkStrictModeWithCurrentAccountVmsPresent.

@Test
public void checkStrictModeWithCurrentAccountVmsPresent() throws InsufficientServerCapacityException {
    final VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    final DataCenterDeployment plan = mock(DataCenterDeployment.class);
    final ExcludeList avoids = new ExcludeList();
    initializeForTest(vmProfile, plan);
    initializeForImplicitPlannerTest(false);
    final List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);
    // Validations.
    // Check cluster 2 and 3 are not in the cluster list.
    // Host 6 and 7 should also be in avoid list.
    assertFalse("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty()));
    boolean foundNeededCluster = false;
    for (final Long cluster : clusterList) {
        if (cluster != 1) {
            fail("Found a cluster that shouldn't have been present, cluster id : " + cluster);
        } else {
            foundNeededCluster = true;
        }
    }
    assertTrue("Didn't find cluster 1 in the list. It should have been present", foundNeededCluster);
    final Set<Long> hostsInAvoidList = avoids.getHostsToAvoid();
    assertFalse("Host 5 shouldn't have be in the avoid list, but it is present", hostsInAvoidList.contains(5L));
    final Set<Long> hostsThatShouldBeInAvoidList = new HashSet<>();
    hostsThatShouldBeInAvoidList.add(6L);
    hostsThatShouldBeInAvoidList.add(7L);
    assertTrue("Hosts 6 and 7 that should have been present were not found in avoid list", hostsInAvoidList.containsAll(hostsThatShouldBeInAvoidList));
}
Also used : ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) VirtualMachineProfileImpl(com.cloud.vm.VirtualMachineProfileImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

DataCenterDeployment (com.cloud.deploy.DataCenterDeployment)89 ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)45 ArrayList (java.util.ArrayList)28 Test (org.junit.Test)28 VirtualMachineProfileImpl (com.cloud.vm.VirtualMachineProfileImpl)24 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)23 StoragePool (com.cloud.storage.StoragePool)19 HashMap (java.util.HashMap)19 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)18 ServiceOfferingVO (com.cloud.service.ServiceOfferingVO)17 DeployDestination (com.cloud.deploy.DeployDestination)16 VolumeVO (com.cloud.storage.VolumeVO)16 LinkedHashMap (java.util.LinkedHashMap)16 StoragePoolAllocator (org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator)14 DeploymentPlan (com.cloud.deploy.DeploymentPlan)13 NetworkVO (com.cloud.network.dao.NetworkVO)13 List (java.util.List)13 DiskProfile (com.cloud.vm.DiskProfile)12 VMInstanceVO (com.cloud.vm.VMInstanceVO)12 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)11