/** * This method should reorder the given list of Cluster Ids by applying any necessary heuristic * for this planner * For UserConcentratedPodPlanner we need to order the clusters in a zone across pods, by considering those pods first which have more number of VMs for this account * This reordering is not done incase the clusters within single pod are passed when the allocation is applied at pod-level. * @return List<Long> ordered list of Cluster Ids */ @Override protected List<Long> reorderClusters(long id, boolean isZone, Pair<List<Long>, Map<Long, Double>> clusterCapacityInfo, VirtualMachineProfile vmProfile, DeploymentPlan plan) { List<Long> clusterIdsByCapacity = clusterCapacityInfo.first(); if (vmProfile.getOwner() == null || !isZone) { return clusterIdsByCapacity; } return applyUserConcentrationPodHeuristicToClusters(id, clusterIdsByCapacity, vmProfile.getOwner().getAccountId()); }
protected List<StoragePool> reOrder(List<StoragePool> pools, VirtualMachineProfile vmProfile, DeploymentPlan plan) { if (pools == null) { return null; } Account account = null; if (vmProfile.getVirtualMachine() != null) { account = vmProfile.getOwner(); } if (allocationAlgorithm.equals("random") || allocationAlgorithm.equals("userconcentratedpod_random") || (account == null)) { // Shuffle this so that we don't check the pools in the same order. Collections.shuffle(pools); } else if (allocationAlgorithm.equals("userdispersing")) { pools = reorderPoolsByNumberOfVolumes(plan, pools, account); } else if(allocationAlgorithm.equals("firstfitleastconsumed")){ pools = reorderPoolsByCapacity(plan, pools); } return pools; }
/** * This method should reorder the given list of Pod Ids by applying any necessary heuristic * for this planner * For UserConcentratedPodPlanner we need to order the pods by considering those pods first which have more number of VMs for this account * @return List<Long> ordered list of Pod Ids */ @Override protected List<Long> reorderPods(Pair<List<Long>, Map<Long, Double>> podCapacityInfo, VirtualMachineProfile vmProfile, DeploymentPlan plan) { List<Long> podIdsByCapacity = podCapacityInfo.first(); if (vmProfile.getOwner() == null) { return podIdsByCapacity; } long accountId = vmProfile.getOwner().getAccountId(); //user has VMs in certain pods. - prioritize those pods first //UserConcentratedPod strategy List<Long> podIds = listPodsByUserConcentration(plan.getDataCenterId(), accountId); if (!podIds.isEmpty()) { //remove pods that dont have capacity for this vm podIds.retainAll(podIdsByCapacity); podIdsByCapacity.removeAll(podIds); podIds.addAll(podIdsByCapacity); return podIds; } else { return podIdsByCapacity; } }
/** * This method should reorder the given list of Cluster Ids by applying any necessary heuristic * for this planner * For UserDispersingPlanner we need to order the clusters by considering the number of VMs for this account * @return List<Long> ordered list of Cluster Ids */ @Override protected List<Long> reorderClusters(long id, boolean isZone, Pair<List<Long>, Map<Long, Double>> clusterCapacityInfo, VirtualMachineProfile vmProfile, DeploymentPlan plan) { List<Long> clusterIdsByCapacity = clusterCapacityInfo.first(); if (vmProfile.getOwner() == null) { return clusterIdsByCapacity; } long accountId = vmProfile.getOwner().getAccountId(); Pair<List<Long>, Map<Long, Double>> clusterIdsVmCountInfo = listClustersByUserDispersion(id, isZone, accountId); //now we have 2 cluster lists - one ordered by capacity and the other by number of VMs for this account //need to apply weights to these to find the correct ordering to follow if (_userDispersionWeight == 1.0f) { List<Long> clusterIds = clusterIdsVmCountInfo.first(); clusterIds.retainAll(clusterIdsByCapacity); return clusterIds; } else { //apply weights to the two lists return orderByApplyingWeights(clusterCapacityInfo, clusterIdsVmCountInfo, accountId); } }
/** * This method should reorder the given list of Pod Ids by applying any necessary heuristic * for this planner * For UserDispersingPlanner we need to order the pods by considering the number of VMs for this account * @return List<Long> ordered list of Pod Ids */ @Override protected List<Long> reorderPods(Pair<List<Long>, Map<Long, Double>> podCapacityInfo, VirtualMachineProfile vmProfile, DeploymentPlan plan) { List<Long> podIdsByCapacity = podCapacityInfo.first(); if (vmProfile.getOwner() == null) { return podIdsByCapacity; } long accountId = vmProfile.getOwner().getAccountId(); Pair<List<Long>, Map<Long, Double>> podIdsVmCountInfo = listPodsByUserDispersion(plan.getDataCenterId(), accountId); //now we have 2 pod lists - one ordered by capacity and the other by number of VMs for this account //need to apply weights to these to find the correct ordering to follow if (_userDispersionWeight == 1.0f) { List<Long> podIds = podIdsVmCountInfo.first(); podIds.retainAll(podIdsByCapacity); return podIds; } else { //apply weights to the two lists return orderByApplyingWeights(podCapacityInfo, podIdsVmCountInfo, accountId); } }
ServiceOffering offering = vmProfile.getServiceOffering(); VMTemplateVO template = (VMTemplateVO)vmProfile.getTemplate(); Account account = vmProfile.getOwner(); List<Host> suitableHosts = new ArrayList<Host>(); List<Host> hostsCopy = new ArrayList<Host>(hosts);
Account account = vmProfile.getOwner();
ServiceOffering offering = vmProfile.getServiceOffering(); VMTemplateVO template = (VMTemplateVO)vmProfile.getTemplate(); Account account = vmProfile.getOwner();
List<Long> clusterList = super.orderClusters(vmProfile, plan, avoid); Set<Long> hostsToAvoid = avoid.getHostsToAvoid(); Account account = vmProfile.getOwner();
if (dedicatedZone != null && !_accountMgr.isRootAdmin(vmProfile.getOwner().getId())) { long accountDomainId = vmProfile.getOwner().getDomainId(); long accountId = vmProfile.getOwner().getAccountId(); return; } else { throw new CloudRuntimeException("Failed to deploy VM, Zone " + dc.getName() + " not available for the user account " + vmProfile.getOwner()); throw new CloudRuntimeException("Failed to deploy VM, Zone " + dc.getName() + " not available for the user domain " + vmProfile.getOwner());
private void getBaremetalIp(NicProfile nic, Pod pod, VirtualMachineProfile vm, Network network, String requiredIp) throws InsufficientAddressCapacityException, ConcurrentOperationException { DataCenter dc = _dcDao.findById(pod.getDataCenterId()); if (nic.getIPv4Address() == null) { s_logger.debug(String.format("Requiring ip address: %s", nic.getIPv4Address())); PublicIp ip = _ipAddrMgr.assignPublicIpAddress(dc.getId(), pod.getId(), vm.getOwner(), VlanType.DirectAttached, network.getId(), requiredIp, false, false); nic.setIPv4Address(ip.getAddress().toString()); nic.setFormat(AddressFormat.Ip4); nic.setIPv4Gateway(ip.getGateway()); nic.setIPv4Netmask(ip.getNetmask()); if (ip.getVlanTag() != null && ip.getVlanTag().equalsIgnoreCase(Vlan.UNTAGGED)) { nic.setIsolationUri(IsolationType.Ec2.toUri(Vlan.UNTAGGED)); nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(Vlan.UNTAGGED)); nic.setBroadcastType(BroadcastDomainType.Native); } nic.setReservationId(String.valueOf(ip.getVlanTag())); nic.setMacAddress(ip.getMacAddress()); } nic.setIPv4Dns1(dc.getDns1()); nic.setIPv4Dns2(dc.getDns2()); } }
ip = _ipAddrMgr.assignPublicIpAddress(dc.getId(), pod.getId(), vm.getOwner(), VlanType.DirectAttached, network.getId(), null, false, false);
ip = assignPublicIpAddress(dc.getId(), null, vm.getOwner(), VlanType.DirectAttached, network.getId(), requestedIpv4, false, false);
protected void getIp(NicProfile nic, DataCenter dc, VirtualMachineProfile vm, Network network) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException { if (nic.getIPv4Address() == null) { boolean forSystemVms = false; if (vm.getType().equals(VirtualMachine.Type.ConsoleProxy) || vm.getType().equals(VirtualMachine.Type.SecondaryStorageVm)) { forSystemVms = true; } PublicIp ip = _ipAddrMgr.assignPublicIpAddress(dc.getId(), null, vm.getOwner(), VlanType.VirtualNetwork, null, null, false, forSystemVms); nic.setIPv4Address(ip.getAddress().toString()); nic.setIPv4Gateway(ip.getGateway()); nic.setIPv4Netmask(ip.getNetmask()); if (network.getBroadcastDomainType() == BroadcastDomainType.Vxlan) { nic.setIsolationUri(BroadcastDomainType.Vxlan.toUri(ip.getVlanTag())); nic.setBroadcastUri(BroadcastDomainType.Vxlan.toUri(ip.getVlanTag())); nic.setBroadcastType(BroadcastDomainType.Vxlan); } else { nic.setIsolationUri(IsolationType.Vlan.toUri(ip.getVlanTag())); nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(ip.getVlanTag())); nic.setBroadcastType(BroadcastDomainType.Vlan); } nic.setFormat(AddressFormat.Ip4); nic.setReservationId(String.valueOf(ip.getVlanTag())); nic.setMacAddress(ip.getMacAddress()); } nic.setIPv4Dns1(dc.getDns1()); nic.setIPv4Dns2(dc.getDns2()); }