use of com.cloud.deploy.DataCenterDeployment in project cosmic by MissionCriticalCloud.
the class ImplicitPlannerTest method checkPreferredModeNoHostsAvailable.
@Test
public void checkPreferredModeNoHostsAvailable() throws InsufficientServerCapacityException {
final VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
final DataCenterDeployment plan = mock(DataCenterDeployment.class);
final ExcludeList avoids = new ExcludeList();
initializeForTest(vmProfile, plan);
initializeForImplicitPlannerTest(false);
// Mark the host 5, 6 and 7 to be in avoid list.
avoids.addHost(5L);
avoids.addHost(6L);
avoids.addHost(7L);
final List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);
// Validations.
// Check cluster list is empty.
assertTrue("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty()));
}
use of com.cloud.deploy.DataCenterDeployment in project cosmic by MissionCriticalCloud.
the class ImplicitPlannerTest method checkStrictModeHostWithCurrentAccountVmsFull.
@Test
public void checkStrictModeHostWithCurrentAccountVmsFull() throws InsufficientServerCapacityException {
final VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
final DataCenterDeployment plan = mock(DataCenterDeployment.class);
final ExcludeList avoids = new ExcludeList();
initializeForTest(vmProfile, plan);
initializeForImplicitPlannerTest(false);
// Mark the host 5 with current account vms to be in avoid list.
avoids.addHost(5L);
final List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);
// Validations.
// Check cluster 1 and 3 are not in the cluster list.
// Host 5 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 != 2) {
fail("Found a cluster that shouldn't have been present, cluster id : " + cluster);
} else {
foundNeededCluster = true;
}
}
assertTrue("Didn't find cluster 2 in the list. It should have been present", foundNeededCluster);
final Set<Long> hostsInAvoidList = avoids.getHostsToAvoid();
assertFalse("Host 6 shouldn't have be in the avoid list, but it is present", hostsInAvoidList.contains(6L));
final Set<Long> hostsThatShouldBeInAvoidList = new HashSet<>();
hostsThatShouldBeInAvoidList.add(5L);
hostsThatShouldBeInAvoidList.add(7L);
assertTrue("Hosts 5 and 7 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 RecreateHostAllocator method allocateTo.
@Override
public List<Host> allocateTo(final VirtualMachineProfile vm, final DeploymentPlan plan, final Type type, final ExcludeList avoid, final int returnUpTo) {
List<Host> hosts = super.allocateTo(vm, plan, type, avoid, returnUpTo);
if (hosts != null && !hosts.isEmpty()) {
return hosts;
}
s_logger.debug("First fit was unable to find a host");
final VirtualMachine.Type vmType = vm.getType();
if (vmType == VirtualMachine.Type.User) {
s_logger.debug("vm is not a system vm so let's just return empty list");
return new ArrayList<>();
}
final DataCenter dc = _dcDao.findById(plan.getDataCenterId());
final List<PodCluster> pcs = _resourceMgr.listByDataCenter(dc.getId());
// basic network type for zone maps to direct untagged case
if (dc.getNetworkType().equals(NetworkType.Basic)) {
s_logger.debug("Direct Networking mode so we can only allow the host to be allocated in the same pod due to public ip address cannot change");
final List<VolumeVO> vols = _volsDao.findByInstance(vm.getId());
final VolumeVO vol = vols.get(0);
final long podId = vol.getPodId();
s_logger.debug("Pod id determined from volume " + vol.getId() + " is " + podId);
final Iterator<PodCluster> it = pcs.iterator();
while (it.hasNext()) {
final PodCluster pc = it.next();
if (pc.getPod().getId() != podId) {
it.remove();
}
}
}
final Set<Pair<Long, Long>> avoidPcs = new HashSet<>();
final Set<Long> hostIdsToAvoid = avoid.getHostsToAvoid();
if (hostIdsToAvoid != null) {
for (final Long hostId : hostIdsToAvoid) {
final Host h = _hostDao.findById(hostId);
if (h != null) {
avoidPcs.add(new Pair<>(h.getPodId(), h.getClusterId()));
}
}
}
for (final Pair<Long, Long> pcId : avoidPcs) {
s_logger.debug("Removing " + pcId + " from the list of available pods");
pcs.remove(new PodCluster(new HostPodVO(pcId.first()), pcId.second() != null ? new ClusterVO(pcId.second()) : null));
}
for (final PodCluster p : pcs) {
if (p.getPod().getAllocationState() != AllocationState.Enabled) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Pod name: " + p.getPod().getName() + ", podId: " + p.getPod().getId() + " is in " + p.getPod().getAllocationState().name() + " state, skipping this and trying other pods");
}
continue;
}
final Long clusterId = p.getCluster() == null ? null : p.getCluster().getId();
if (p.getCluster() != null && p.getCluster().getAllocationState() != AllocationState.Enabled) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Cluster name: " + p.getCluster().getName() + ", clusterId: " + clusterId + " is in " + p.getCluster().getAllocationState().name() + " state, skipping this and trying other pod-clusters");
}
continue;
}
final DataCenterDeployment newPlan = new DataCenterDeployment(plan.getDataCenterId(), p.getPod().getId(), clusterId, null, null, null);
hosts = super.allocateTo(vm, newPlan, type, avoid, returnUpTo);
if (hosts != null && !hosts.isEmpty()) {
return hosts;
}
}
s_logger.debug("Unable to find any available pods at all!");
return new ArrayList<>();
}
use of com.cloud.deploy.DataCenterDeployment in project cosmic by MissionCriticalCloud.
the class ConfigurationManagerImpl method createDefaultSystemNetworks.
@Override
public void createDefaultSystemNetworks(final long zoneId) throws ConcurrentOperationException {
final DataCenterVO zone = _zoneDao.findById(zoneId);
final String networkDomain = null;
// the zone creation
if (zone != null) {
final List<NetworkOfferingVO> ntwkOff = _networkOfferingDao.listSystemNetworkOfferings();
for (final NetworkOfferingVO offering : ntwkOff) {
final DataCenterDeployment plan = new DataCenterDeployment(zone.getId(), null, null, null, null, null);
final NetworkVO userNetwork = new NetworkVO();
final Account systemAccount = _accountDao.findById(Account.ACCOUNT_ID_SYSTEM);
BroadcastDomainType broadcastDomainType = null;
if (offering.getTrafficType() == TrafficType.Management) {
broadcastDomainType = BroadcastDomainType.Native;
} else if (offering.getTrafficType() == TrafficType.Control) {
broadcastDomainType = BroadcastDomainType.LinkLocal;
} else if (offering.getTrafficType() == TrafficType.Public) {
if (zone.getNetworkType() == NetworkType.Advanced || zone.getNetworkType() == NetworkType.Basic) {
broadcastDomainType = BroadcastDomainType.Vlan;
} else {
// so broadcastDomainType remains null! why have None/Undecided/UnKnown?
continue;
}
} else if (offering.getTrafficType() == TrafficType.Guest) {
continue;
}
userNetwork.setBroadcastDomainType(broadcastDomainType);
userNetwork.setNetworkDomain(networkDomain);
_networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, false, Domain.ROOT_DOMAIN, null, null, null, null, true, null, null, null);
}
}
}
use of com.cloud.deploy.DataCenterDeployment in project cosmic by MissionCriticalCloud.
the class ConsoleProxyManagerImpl method createProxyInstance.
protected Map<String, Object> createProxyInstance(final long dataCenterId, final VMTemplateVO template) throws ConcurrentOperationException {
final long id = _consoleProxyDao.getNextInSequence(Long.class, "id");
final String name = VirtualMachineName.getConsoleProxyName(id, _instance);
final Zone zone = zoneRepository.findOne(dataCenterId);
final Account systemAcct = _accountMgr.getSystemAccount();
final DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
final NetworkVO defaultNetwork = getDefaultNetworkForCreation(zone);
final List<? extends NetworkOffering> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemControlNetwork, NetworkOffering.SystemManagementNetwork);
final LinkedHashMap<Network, List<? extends NicProfile>> networks = new LinkedHashMap<>(offerings.size() + 1);
final NicProfile defaultNic = new NicProfile();
defaultNic.setDefaultNic(true);
networks.put(_networkMgr.setupNetwork(systemAcct, _networkOfferingDao.findById(defaultNetwork.getNetworkOfferingId()), plan, null, null, false).get(0), new ArrayList<>(Arrays.asList(defaultNic)));
for (final NetworkOffering offering : offerings) {
networks.put(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false).get(0), new ArrayList<>());
}
ServiceOfferingVO serviceOffering = _serviceOffering;
if (serviceOffering == null) {
serviceOffering = _offeringDao.findDefaultSystemOffering(ServiceOffering.consoleProxyDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId));
}
ConsoleProxyVO proxy = new ConsoleProxyVO(id, serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId, systemAcct.getDomainId(), systemAcct.getId(), _accountMgr.getSystemUser().getId(), 0, serviceOffering.getOfferHA());
proxy.setDynamicallyScalable(template.isDynamicallyScalable());
proxy = _consoleProxyDao.persist(proxy);
try {
_itMgr.allocate(name, template, serviceOffering, networks, plan, null);
} catch (final InsufficientCapacityException e) {
logger.warn("InsufficientCapacity", e);
throw new CloudRuntimeException("Insufficient capacity exception", e);
}
final Map<String, Object> context = new HashMap<>();
context.put("dc", zone);
final HostPodVO pod = _podDao.findById(proxy.getPodIdToDeployIn());
context.put("pod", pod);
context.put("proxyVmId", proxy.getId());
return context;
}
Aggregations