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);
}
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()));
}
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));
}
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));
}
Aggregations