当前位置: 首页>>代码示例>>Java>>正文


Java ServiceOffering.getSpeed方法代码示例

本文整理汇总了Java中com.cloud.offering.ServiceOffering.getSpeed方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceOffering.getSpeed方法的具体用法?Java ServiceOffering.getSpeed怎么用?Java ServiceOffering.getSpeed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.cloud.offering.ServiceOffering的用法示例。


在下文中一共展示了ServiceOffering.getSpeed方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeClustersCrossingThreshold

import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
/**
 * This method should remove the clusters crossing capacity threshold to avoid further vm allocation on it.
 *
 * @param clusterListForVmAllocation
 * @param avoid
 * @param vmProfile
 * @param plan
 */
protected void removeClustersCrossingThreshold(final List<Long> clusterListForVmAllocation, final ExcludeList avoid,
                                               final VirtualMachineProfile vmProfile, final DeploymentPlan plan) {

    final List<Short> capacityList = getCapacitiesForCheckingThreshold();
    List<Long> clustersCrossingThreshold = new ArrayList<>();

    final ServiceOffering offering = vmProfile.getServiceOffering();
    final int cpu_requested = offering.getCpu() * offering.getSpeed();
    final long ram_requested = offering.getRamSize() * 1024L * 1024L;

    // For each capacity get the cluster list crossing the threshold and
    // remove it from the clusterList that will be used for vm allocation.
    for (final short capacity : capacityList) {

        if (clusterListForVmAllocation == null || clusterListForVmAllocation.size() == 0) {
            return;
        }
        if (capacity == Capacity.CAPACITY_TYPE_CPU) {
            clustersCrossingThreshold =
                    capacityDao.listClustersCrossingThreshold(capacity, plan.getDataCenterId(), ClusterCPUCapacityDisableThreshold.key(), cpu_requested);
        } else if (capacity == Capacity.CAPACITY_TYPE_MEMORY) {
            clustersCrossingThreshold =
                    capacityDao.listClustersCrossingThreshold(capacity, plan.getDataCenterId(), ClusterMemoryCapacityDisableThreshold.key(), ram_requested);
        }

        if (clustersCrossingThreshold != null && clustersCrossingThreshold.size() != 0) {
            // addToAvoid Set
            avoid.addClusterList(clustersCrossingThreshold);
            // Remove clusters crossing disabled threshold
            clusterListForVmAllocation.removeAll(clustersCrossingThreshold);

            s_logger.debug("Cannot allocate cluster list " + clustersCrossingThreshold.toString() + " for vm creation since their allocated percentage" +
                    " crosses the disable capacity threshold defined at each cluster/ at global value for capacity Type : " + capacity + ", skipping these clusters");
        }
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:45,代码来源:FirstFitPlanner.java

示例2: validateServiceOffering

import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
public boolean validateServiceOffering(ServiceOffering offering) {
    final int cpu_requested = offering.getCpu() * offering.getSpeed();
    final int ram_requested = offering.getRamSize();
    if (offering.isDynamic()){
        throw new InvalidParameterValueException("This service offering is not suitable for k8s cluster as this is dynamic, service offering id is " + offering.getId());
    }
    if (ram_requested < 64){
        throw new InvalidParameterValueException("This service offering is not suitable for k8s cluster as this has less than 256M of Ram, service offering id is " +  offering.getId());
    }
    if( cpu_requested < 200) {
        throw new InvalidParameterValueException("This service offering is not suitable for k8s cluster as this has less than 600MHz of CPU, service offering id is " +  offering.getId());
    }
    return true;
}
 
开发者ID:shapeblue,项目名称:ccs,代码行数:15,代码来源:ContainerClusterManagerImpl.java

示例3: checkIfCanUpgrade

import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
@Override
public void checkIfCanUpgrade(final VirtualMachine vmInstance, final ServiceOffering newServiceOffering) {
    if (newServiceOffering == null) {
        throw new InvalidParameterValueException("Invalid parameter, newServiceOffering can't be null");
    }

    // Check that the VM is stopped / running
    if (!(vmInstance.getState().equals(State.Stopped) || vmInstance.getState().equals(State.Running))) {
        s_logger.warn("Unable to upgrade virtual machine " + vmInstance.toString() + " in state " + vmInstance.getState());
        throw new InvalidParameterValueException("Unable to upgrade virtual machine " + vmInstance.toString() + " " + " in state " + vmInstance.getState() +
                "; make sure the virtual machine is stopped/running");
    }

    // Check if the service offering being upgraded to is what the VM is already running with
    if (vmInstance.getServiceOfferingId() == newServiceOffering.getId()) {
        if (s_logger.isInfoEnabled()) {
            s_logger.info("Not upgrading vm " + vmInstance.toString() + " since it already has the requested " + "service offering (" + newServiceOffering.getName() +
                    ")");
        }

        throw new InvalidParameterValueException("Not upgrading vm " + vmInstance.toString() + " since it already " + "has the requested service offering (" +
                newServiceOffering.getName() + ")");
    }

    final ServiceOfferingVO currentServiceOffering = _offeringDao.findByIdIncludingRemoved(vmInstance.getId(), vmInstance.getServiceOfferingId());

    // Check that the service offering being upgraded to has the same storage pool preference as the VM's current service
    // offering
    if (currentServiceOffering.getUseLocalStorage() != newServiceOffering.getUseLocalStorage()) {
        throw new InvalidParameterValueException("Unable to upgrade virtual machine " + vmInstance.toString() +
                ", cannot switch between local storage and shared storage service offerings.  Current offering " + "useLocalStorage=" +
                currentServiceOffering.getUseLocalStorage() + ", target offering useLocalStorage=" + newServiceOffering.getUseLocalStorage());
    }

    // if vm is a system vm, check if it is a system service offering, if yes return with error as it cannot be used for user vms
    if (currentServiceOffering.getSystemUse() != newServiceOffering.getSystemUse()) {
        throw new InvalidParameterValueException("isSystem property is different for current service offering and new service offering");
    }

    // Check that there are enough resources to upgrade the service offering
    if (!isVirtualMachineUpgradable(vmInstance, newServiceOffering)) {
        throw new InvalidParameterValueException("Unable to upgrade virtual machine, not enough resources available " + "for an offering of " +
                newServiceOffering.getCpu() + " cpu(s) at " + newServiceOffering.getSpeed() + " Mhz, and " + newServiceOffering.getRamSize() + " MB of memory");
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:46,代码来源:VirtualMachineManagerImpl.java

示例4: toVirtualMachineTO

import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
protected VirtualMachineTO toVirtualMachineTO(final VirtualMachineProfile vmProfile) {
    final ServiceOffering offering = _serviceOfferingDao.findById(vmProfile.getId(), vmProfile.getServiceOfferingId());
    final VirtualMachine vm = vmProfile.getVirtualMachine();
    final Long minMemory = (long) (offering.getRamSize() / vmProfile.getMemoryOvercommitRatio());
    final int minspeed = (int) (offering.getSpeed() / vmProfile.getCpuOvercommitRatio());
    final int maxspeed = offering.getSpeed();
    final VirtualMachineTO to =
            new VirtualMachineTO(vm.getId(), vm.getInstanceName(), vm.getType(), offering.getCpu(), minspeed, maxspeed, minMemory * 1024l * 1024l,
                    offering.getRamSize() * 1024l * 1024l, null, null, vm.isHaEnabled(), vm.limitCpuUse(), vm.getVncPassword());
    to.setBootArgs(vmProfile.getBootArgs());

    final List<NicProfile> nicProfiles = vmProfile.getNics();
    final NicTO[] nics = new NicTO[nicProfiles.size()];
    int i = 0;
    for (final NicProfile nicProfile : nicProfiles) {
        nics[i++] = toNicTO(nicProfile);
    }

    to.setNics(nics);
    to.setDisks(vmProfile.getDisks().toArray(new DiskTO[vmProfile.getDisks().size()]));

    if (vmProfile.getTemplate().getBits() == 32) {
        to.setArch("i686");
    } else {
        to.setArch("x86_64");
    }

    final Map<String, String> detailsInVm = _userVmDetailsDao.listDetailsKeyPairs(vm.getId());
    if (detailsInVm != null) {
        to.setDetails(detailsInVm);
    }

    // Set GPU details
    ServiceOfferingDetailsVO offeringDetail;
    if ((offeringDetail = _serviceOfferingDetailsDao.findDetail(offering.getId(), GPU.Keys.vgpuType.toString())) != null) {
        final ServiceOfferingDetailsVO groupName = _serviceOfferingDetailsDao.findDetail(offering.getId(), GPU.Keys.pciDevice.toString());
        to.setGpuDevice(_resourceMgr.getGPUDevice(vm.getHostId(), groupName.getValue(), offeringDetail.getValue()));
    }

    // Workaround to make sure the TO has the UUID we need for Niciri integration
    final VMInstanceVO vmInstance = _virtualMachineDao.findById(to.getId());
    // check if XStools tools are present in the VM and dynamic scaling feature is enabled (per zone/global)
    final Boolean isDynamicallyScalable = vmInstance.isDynamicallyScalable() && UserVmManager.EnableDynamicallyScaleVm.valueIn(vm.getDataCenterId());
    to.setEnableDynamicallyScaleVm(isDynamicallyScalable);
    to.setUuid(vmInstance.getUuid());

    to.setVmData(vmProfile.getVmData());
    to.setConfigDriveLabel(vmProfile.getConfigDriveLabel());
    to.setConfigDriveIsoRootFolder(vmProfile.getConfigDriveIsoRootFolder());
    to.setConfigDriveIsoFile(vmProfile.getConfigDriveIsoFile());

    final MetadataTO metadataTO = new MetadataTO();

    final DomainVO domain = _domainDao.findById(vm.getDomainId());
    metadataTO.setDomainUuid(domain.getUuid());

    to.setMetadata(metadataTO);

    return to;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:61,代码来源:HypervisorGuruBase.java

示例5: orderClusters

import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
@Override
public List<Long> orderClusters(final VirtualMachineProfile vmProfile, final DeploymentPlan plan, final ExcludeList avoid) throws InsufficientServerCapacityException {
    final VirtualMachine vm = vmProfile.getVirtualMachine();
    final Zone zone = zoneRepository.findOne(vm.getDataCenterId());

    //check if datacenter is in avoid set
    if (avoid.shouldAvoid(zone)) {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("DataCenter id = '" + zone.getId() + "' provided is in avoid set, DeploymentPlanner cannot allocate the VM, returning.");
        }
        return null;
    }

    List<Long> clusterList = new ArrayList<>();
    if (plan.getClusterId() != null) {
        final Long clusterIdSpecified = plan.getClusterId();
        s_logger.debug("Searching resources only under specified Cluster: " + clusterIdSpecified);
        final ClusterVO cluster = clusterDao.findById(plan.getClusterId());
        if (cluster != null) {
            if (avoid.shouldAvoid(cluster)) {
                s_logger.debug("The specified cluster is in avoid set, returning.");
            } else {
                clusterList.add(clusterIdSpecified);
                removeClustersCrossingThreshold(clusterList, avoid, vmProfile, plan);
            }
        } else {
            s_logger.debug("The specified cluster cannot be found, returning.");
            avoid.addCluster(plan.getClusterId());
            return null;
        }
    } else if (plan.getPodId() != null) {
        //consider clusters under this pod only
        final Long podIdSpecified = plan.getPodId();
        s_logger.debug("Searching resources only under specified Pod: " + podIdSpecified);

        final HostPodVO pod = podDao.findById(podIdSpecified);
        if (pod != null) {
            if (avoid.shouldAvoid(pod)) {
                s_logger.debug("The specified pod is in avoid set, returning.");
            } else {
                clusterList = scanClustersForDestinationInZoneOrPod(podIdSpecified, false, vmProfile, plan, avoid);
                if (clusterList == null) {
                    avoid.addPod(plan.getPodId());
                }
            }
        } else {
            s_logger.debug("The specified Pod cannot be found, returning.");
            avoid.addPod(plan.getPodId());
            return null;
        }
    } else {
        s_logger.debug("Searching all possible resources under this Zone: " + plan.getDataCenterId());

        final boolean applyAllocationAtPods = Boolean.parseBoolean(configDao.getValue(Config.ApplyAllocationAlgorithmToPods.key()));
        if (applyAllocationAtPods) {
            //start scan at all pods under this zone.
            clusterList = scanPodsForDestination(vmProfile, plan, avoid);
        } else {
            //start scan at clusters under this zone.
            clusterList = scanClustersForDestinationInZoneOrPod(plan.getDataCenterId(), true, vmProfile, plan, avoid);
        }
    }

    if (clusterList != null && !clusterList.isEmpty()) {
        final ServiceOffering offering = vmProfile.getServiceOffering();
        // In case of non-GPU VMs, protect GPU enabled Hosts and prefer VM deployment on non-GPU Hosts.
        if ((serviceOfferingDetailsDao.findDetail(offering.getId(), GPU.Keys.vgpuType.toString()) == null) && !(hostGpuGroupsDao.listHostIds().isEmpty())) {
            final int requiredCpu = offering.getCpu() * offering.getSpeed();
            final long requiredRam = offering.getRamSize() * 1024L * 1024L;
            reorderClustersBasedOnImplicitTags(clusterList, requiredCpu, requiredRam);
        }
    }
    return clusterList;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:75,代码来源:FirstFitPlanner.java

示例6: scanPodsForDestination

import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
private List<Long> scanPodsForDestination(final VirtualMachineProfile vmProfile, final DeploymentPlan plan, final ExcludeList avoid) {

        final ServiceOffering offering = vmProfile.getServiceOffering();
        final int requiredCpu = offering.getCpu() * offering.getSpeed();
        final long requiredRam = offering.getRamSize() * 1024L * 1024L;
        //list pods under this zone by cpu and ram capacity
        List<Long> prioritizedPodIds = new ArrayList<>();
        final Pair<List<Long>, Map<Long, Double>> podCapacityInfo = listPodsByCapacity(plan.getDataCenterId(), requiredCpu, requiredRam);
        final List<Long> podsWithCapacity = podCapacityInfo.first();

        if (!podsWithCapacity.isEmpty()) {
            if (avoid.getPodsToAvoid() != null) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("Removing from the podId list these pods from avoid set: " + avoid.getPodsToAvoid());
                }
                podsWithCapacity.removeAll(avoid.getPodsToAvoid());
            }
            if (!isRootAdmin(vmProfile)) {
                final List<Long> disabledPods = listDisabledPods(plan.getDataCenterId());
                if (!disabledPods.isEmpty()) {
                    if (s_logger.isDebugEnabled()) {
                        s_logger.debug("Removing from the podId list these pods that are disabled: " + disabledPods);
                    }
                    podsWithCapacity.removeAll(disabledPods);
                }
            }
        } else {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("No pods found having a host with enough capacity, returning.");
            }
            return null;
        }

        if (!podsWithCapacity.isEmpty()) {

            prioritizedPodIds = reorderPods(podCapacityInfo, vmProfile, plan);
            if (prioritizedPodIds == null || prioritizedPodIds.isEmpty()) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("No Pods found for destination, returning.");
                }
                return null;
            }

            final List<Long> clusterList = new ArrayList<>();
            //loop over pods
            for (final Long podId : prioritizedPodIds) {
                s_logger.debug("Checking resources under Pod: " + podId);
                final List<Long> clustersUnderPod = scanClustersForDestinationInZoneOrPod(podId, false, vmProfile, plan, avoid);
                if (clustersUnderPod != null) {
                    clusterList.addAll(clustersUnderPod);
                }
            }
            return clusterList;
        } else {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("No Pods found after removing disabled pods and pods in avoid list, returning.");
            }
            return null;
        }
    }
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:61,代码来源:FirstFitPlanner.java

示例7: scanClustersForDestinationInZoneOrPod

import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
private List<Long> scanClustersForDestinationInZoneOrPod(final long id, final boolean isZone, final VirtualMachineProfile vmProfile, final DeploymentPlan plan, final
ExcludeList avoid) {

    final VirtualMachine vm = vmProfile.getVirtualMachine();
    final ServiceOffering offering = vmProfile.getServiceOffering();
    final int requiredCpu = offering.getCpu() * offering.getSpeed();
    final long requiredRam = offering.getRamSize() * 1024L * 1024L;

    //list clusters under this zone by cpu and ram capacity
    final Pair<List<Long>, Map<Long, Double>> clusterCapacityInfo = listClustersByCapacity(id, requiredCpu, requiredRam, avoid, isZone);
    final List<Long> prioritizedClusterIds = clusterCapacityInfo.first();
    if (!prioritizedClusterIds.isEmpty()) {
        if (avoid.getClustersToAvoid() != null) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Removing from the clusterId list these clusters from avoid set: " + avoid.getClustersToAvoid());
            }
            prioritizedClusterIds.removeAll(avoid.getClustersToAvoid());
        }

        if (!isRootAdmin(vmProfile)) {
            List<Long> disabledClusters = new ArrayList<>();
            if (isZone) {
                disabledClusters = listDisabledClusters(plan.getDataCenterId(), null);
            } else {
                disabledClusters = listDisabledClusters(plan.getDataCenterId(), id);
            }
            if (!disabledClusters.isEmpty()) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("Removing from the clusterId list these clusters that are disabled/clusters under disabled pods: " + disabledClusters);
                }
                prioritizedClusterIds.removeAll(disabledClusters);
            }
        }

        removeClustersCrossingThreshold(prioritizedClusterIds, avoid, vmProfile, plan);
    } else {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("No clusters found having a host with enough capacity, returning.");
        }
        return null;
    }
    if (!prioritizedClusterIds.isEmpty()) {
        return reorderClusters(id, isZone, clusterCapacityInfo, vmProfile, plan); //return checkClustersforDestination(clusterList, vmProfile, plan, avoid, dc);
    } else {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("No clusters found after removing disabled clusters and clusters in avoid list, returning.");
        }
        return null;
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:51,代码来源:FirstFitPlanner.java

示例8: checkIfCanUpgrade

import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
@Override
public void checkIfCanUpgrade(final VirtualMachine vmInstance, final ServiceOffering newServiceOffering) {
    if (newServiceOffering == null) {
        throw new InvalidParameterValueException("Invalid parameter, newServiceOffering can't be null");
    }

    // Check that the VM is stopped / running
    if (!(vmInstance.getState().equals(State.Stopped) || vmInstance.getState().equals(State.Running))) {
        s_logger.warn("Unable to upgrade virtual machine " + vmInstance.toString() + " in state " + vmInstance.getState());
        throw new InvalidParameterValueException("Unable to upgrade virtual machine " + vmInstance.toString() + " " + " in state " + vmInstance.getState() +
                "; make sure the virtual machine is stopped/running");
    }

    // Check if the service offering being upgraded to is what the VM is already running with
    if (!newServiceOffering.isDynamic() && vmInstance.getServiceOfferingId() == newServiceOffering.getId()) {
        if (s_logger.isInfoEnabled()) {
            s_logger.info("Not upgrading vm " + vmInstance.toString() + " since it already has the requested " + "service offering (" + newServiceOffering.getName() +
                    ")");
        }

        throw new InvalidParameterValueException("Not upgrading vm " + vmInstance.toString() + " since it already " + "has the requested service offering (" +
                newServiceOffering.getName() + ")");
    }

    final ServiceOfferingVO currentServiceOffering = _offeringDao.findByIdIncludingRemoved(vmInstance.getId(), vmInstance.getServiceOfferingId());

    // Check that the service offering being upgraded to has the same Guest IP type as the VM's current service offering
    // NOTE: With the new network refactoring in 2.2, we shouldn't need the check for same guest IP type anymore.
    /*
     * if (!currentServiceOffering.getGuestIpType().equals(newServiceOffering.getGuestIpType())) { String errorMsg =
     * "The service offering being upgraded to has a guest IP type: " + newServiceOffering.getGuestIpType(); errorMsg +=
     * ". Please select a service offering with the same guest IP type as the VM's current service offering (" +
     * currentServiceOffering.getGuestIpType() + ")."; throw new InvalidParameterValueException(errorMsg); }
     */

    // Check that the service offering being upgraded to has the same storage pool preference as the VM's current service
    // offering
    if (currentServiceOffering.getUseLocalStorage() != newServiceOffering.getUseLocalStorage()) {
        throw new InvalidParameterValueException("Unable to upgrade virtual machine " + vmInstance.toString() +
                ", cannot switch between local storage and shared storage service offerings.  Current offering " + "useLocalStorage=" +
                currentServiceOffering.getUseLocalStorage() + ", target offering useLocalStorage=" + newServiceOffering.getUseLocalStorage());
    }

    // if vm is a system vm, check if it is a system service offering, if yes return with error as it cannot be used for user vms
    if (currentServiceOffering.getSystemUse() != newServiceOffering.getSystemUse()) {
        throw new InvalidParameterValueException("isSystem property is different for current service offering and new service offering");
    }

    // Check that there are enough resources to upgrade the service offering
    if (!isVirtualMachineUpgradable(vmInstance, newServiceOffering)) {
        throw new InvalidParameterValueException("Unable to upgrade virtual machine, not enough resources available " + "for an offering of " +
                newServiceOffering.getCpu() + " cpu(s) at " + newServiceOffering.getSpeed() + " Mhz, and " + newServiceOffering.getRamSize() + " MB of memory");
    }

    // Check that the service offering being upgraded to has all the tags of the current service offering.
    final List<String> currentTags = StringUtils.csvTagsToList(currentServiceOffering.getTags());
    final List<String> newTags = StringUtils.csvTagsToList(newServiceOffering.getTags());
    if (!newTags.containsAll(currentTags)) {
        throw new InvalidParameterValueException("Unable to upgrade virtual machine; the current service offering " + " should have tags as subset of " +
                "the new service offering tags. Current service offering tags: " + currentTags + "; " + "new service " + "offering tags: " + newTags);
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:63,代码来源:VirtualMachineManagerImpl.java

示例9: toVirtualMachineTO

import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
protected VirtualMachineTO toVirtualMachineTO(VirtualMachineProfile vmProfile) {
    ServiceOffering offering = _serviceOfferingDao.findById(vmProfile.getId(), vmProfile.getServiceOfferingId());
    VirtualMachine vm = vmProfile.getVirtualMachine();
    Long minMemory = (long)(offering.getRamSize() / vmProfile.getMemoryOvercommitRatio());
    int minspeed = (int)(offering.getSpeed() / vmProfile.getCpuOvercommitRatio());
    int maxspeed = (offering.getSpeed());
    VirtualMachineTO to = new VirtualMachineTO(vm.getId(), vm.getInstanceName(), vm.getType(), offering.getCpu(), minspeed, maxspeed, minMemory * 1024l * 1024l,
            offering.getRamSize() * 1024l * 1024l, null, null, vm.isHaEnabled(), vm.limitCpuUse(), vm.getVncPassword());
    to.setBootArgs(vmProfile.getBootArgs());

    List<NicProfile> nicProfiles = vmProfile.getNics();
    NicTO[] nics = new NicTO[nicProfiles.size()];
    int i = 0;
    for (NicProfile nicProfile : nicProfiles) {
        if (vm.getType() == VirtualMachine.Type.NetScalerVm) {
            nicProfile.setBroadcastType(BroadcastDomainType.Native);
        }
        NicTO nicTo = toNicTO(nicProfile);
        final NetworkVO network = _networkDao.findByUuid(nicTo.getNetworkUuid());
        if (network != null) {
            final Map<NetworkOffering.Detail, String> details = networkOfferingDetailsDao.getNtwkOffDetails(network.getNetworkOfferingId());
            if (details != null) {
                details.putIfAbsent(NetworkOffering.Detail.PromiscuousMode, NetworkOrchestrationService.PromiscuousMode.value().toString());
                details.putIfAbsent(NetworkOffering.Detail.MacAddressChanges, NetworkOrchestrationService.MacAddressChanges.value().toString());
                details.putIfAbsent(NetworkOffering.Detail.ForgedTransmits, NetworkOrchestrationService.ForgedTransmits.value().toString());
            }
            nicTo.setDetails(details);
        }
        nics[i++] = nicTo;
    }

    to.setNics(nics);
    to.setDisks(vmProfile.getDisks().toArray(new DiskTO[vmProfile.getDisks().size()]));

    if (vmProfile.getTemplate().getBits() == 32) {
        to.setArch("i686");
    } else {
        to.setArch("x86_64");
    }

    Map<String, String> detailsInVm = _userVmDetailsDao.listDetailsKeyPairs(vm.getId());
    if (detailsInVm != null) {
        to.setDetails(detailsInVm);
    }

    // Set GPU details
    ServiceOfferingDetailsVO offeringDetail = null;
    if ((offeringDetail = _serviceOfferingDetailsDao.findDetail(offering.getId(), GPU.Keys.vgpuType.toString())) != null) {
        ServiceOfferingDetailsVO groupName = _serviceOfferingDetailsDao.findDetail(offering.getId(), GPU.Keys.pciDevice.toString());
        to.setGpuDevice(_resourceMgr.getGPUDevice(vm.getHostId(), groupName.getValue(), offeringDetail.getValue()));
    }

    // Workaround to make sure the TO has the UUID we need for Niciri integration
    VMInstanceVO vmInstance = _virtualMachineDao.findById(to.getId());
    // check if XStools/VMWare tools are present in the VM and dynamic scaling feature is enabled (per zone/global)
    Boolean isDynamicallyScalable = vmInstance.isDynamicallyScalable() && UserVmManager.EnableDynamicallyScaleVm.valueIn(vm.getDataCenterId());
    to.setEnableDynamicallyScaleVm(isDynamicallyScalable);
    to.setUuid(vmInstance.getUuid());

    to.setVmData(vmProfile.getVmData());
    to.setConfigDriveLabel(vmProfile.getConfigDriveLabel());
    to.setConfigDriveIsoRootFolder(vmProfile.getConfigDriveIsoRootFolder());
    to.setConfigDriveIsoFile(vmProfile.getConfigDriveIsoFile());

    return to;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:67,代码来源:HypervisorGuruBase.java

示例10: orderClusters

import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
@Override
public List<Long> orderClusters(VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException {
    VirtualMachine vm = vmProfile.getVirtualMachine();
    DataCenter dc = dcDao.findById(vm.getDataCenterId());

    //check if datacenter is in avoid set
    if (avoid.shouldAvoid(dc)) {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("DataCenter id = '" + dc.getId() + "' provided is in avoid set, DeploymentPlanner cannot allocate the VM, returning.");
        }
        return null;
    }

    List<Long> clusterList = new ArrayList<Long>();
    if (plan.getClusterId() != null) {
        Long clusterIdSpecified = plan.getClusterId();
        s_logger.debug("Searching resources only under specified Cluster: " + clusterIdSpecified);
        ClusterVO cluster = clusterDao.findById(plan.getClusterId());
        if (cluster != null) {
            if (avoid.shouldAvoid(cluster)) {
                s_logger.debug("The specified cluster is in avoid set, returning.");
            } else {
                clusterList.add(clusterIdSpecified);
                removeClustersCrossingThreshold(clusterList, avoid, vmProfile, plan);
            }
        } else {
            s_logger.debug("The specified cluster cannot be found, returning.");
            avoid.addCluster(plan.getClusterId());
            return null;
        }
    } else if (plan.getPodId() != null) {
        //consider clusters under this pod only
        Long podIdSpecified = plan.getPodId();
        s_logger.debug("Searching resources only under specified Pod: " + podIdSpecified);

        HostPodVO pod = podDao.findById(podIdSpecified);
        if (pod != null) {
            if (avoid.shouldAvoid(pod)) {
                s_logger.debug("The specified pod is in avoid set, returning.");
            } else {
                clusterList = scanClustersForDestinationInZoneOrPod(podIdSpecified, false, vmProfile, plan, avoid);
                if (clusterList == null) {
                    avoid.addPod(plan.getPodId());
                }
            }
        } else {
            s_logger.debug("The specified Pod cannot be found, returning.");
            avoid.addPod(plan.getPodId());
            return null;
        }
    } else {
        s_logger.debug("Searching all possible resources under this Zone: " + plan.getDataCenterId());

        boolean applyAllocationAtPods = Boolean.parseBoolean(configDao.getValue(Config.ApplyAllocationAlgorithmToPods.key()));
        if (applyAllocationAtPods) {
            //start scan at all pods under this zone.
            clusterList = scanPodsForDestination(vmProfile, plan, avoid);
        } else {
            //start scan at clusters under this zone.
            clusterList = scanClustersForDestinationInZoneOrPod(plan.getDataCenterId(), true, vmProfile, plan, avoid);
        }
    }

    if (clusterList != null && !clusterList.isEmpty()) {
        ServiceOffering offering = vmProfile.getServiceOffering();
        // In case of non-GPU VMs, protect GPU enabled Hosts and prefer VM deployment on non-GPU Hosts.
        if ((serviceOfferingDetailsDao.findDetail(offering.getId(), GPU.Keys.vgpuType.toString()) == null) && !(hostGpuGroupsDao.listHostIds().isEmpty())) {
            int requiredCpu = offering.getCpu() * offering.getSpeed();
            long requiredRam = offering.getRamSize() * 1024L * 1024L;
            reorderClustersBasedOnImplicitTags(clusterList, requiredCpu, requiredRam);
        }
    }
    return clusterList;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:75,代码来源:FirstFitPlanner.java

示例11: scanPodsForDestination

import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
private List<Long> scanPodsForDestination(VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid) {

        ServiceOffering offering = vmProfile.getServiceOffering();
        int requiredCpu = offering.getCpu() * offering.getSpeed();
        long requiredRam = offering.getRamSize() * 1024L * 1024L;
        //list pods under this zone by cpu and ram capacity
        List<Long> prioritizedPodIds = new ArrayList<Long>();
        Pair<List<Long>, Map<Long, Double>> podCapacityInfo = listPodsByCapacity(plan.getDataCenterId(), requiredCpu, requiredRam);
        List<Long> podsWithCapacity = podCapacityInfo.first();

        if (!podsWithCapacity.isEmpty()) {
            if (avoid.getPodsToAvoid() != null) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("Removing from the podId list these pods from avoid set: " + avoid.getPodsToAvoid());
                }
                podsWithCapacity.removeAll(avoid.getPodsToAvoid());
            }
            if (!isRootAdmin(vmProfile)) {
                List<Long> disabledPods = listDisabledPods(plan.getDataCenterId());
                if (!disabledPods.isEmpty()) {
                    if (s_logger.isDebugEnabled()) {
                        s_logger.debug("Removing from the podId list these pods that are disabled: " + disabledPods);
                    }
                    podsWithCapacity.removeAll(disabledPods);
                }
            }
        } else {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("No pods found having a host with enough capacity, returning.");
            }
            return null;
        }

        if (!podsWithCapacity.isEmpty()) {

            prioritizedPodIds = reorderPods(podCapacityInfo, vmProfile, plan);
            if (prioritizedPodIds == null || prioritizedPodIds.isEmpty()) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("No Pods found for destination, returning.");
                }
                return null;
            }

            List<Long> clusterList = new ArrayList<Long>();
            //loop over pods
            for (Long podId : prioritizedPodIds) {
                s_logger.debug("Checking resources under Pod: " + podId);
                List<Long> clustersUnderPod = scanClustersForDestinationInZoneOrPod(podId, false, vmProfile, plan, avoid);
                if (clustersUnderPod != null) {
                    clusterList.addAll(clustersUnderPod);
                }
            }
            return clusterList;
        } else {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("No Pods found after removing disabled pods and pods in avoid list, returning.");
            }
            return null;
        }
    }
 
开发者ID:apache,项目名称:cloudstack,代码行数:61,代码来源:FirstFitPlanner.java

示例12: removeClustersCrossingThreshold

import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
/**
 * This method should remove the clusters crossing capacity threshold to avoid further vm allocation on it.
 * @param clusterListForVmAllocation
 * @param avoid
 * @param vmProfile
 * @param plan
 */
protected void removeClustersCrossingThreshold(List<Long> clusterListForVmAllocation, ExcludeList avoid,
        VirtualMachineProfile vmProfile, DeploymentPlan plan) {

    // Check if cluster threshold for cpu/memory has to be checked or not. By default we
    // always check cluster threshold isn't crossed. However, the check may be skipped for
    // starting (not deploying) an instance.
    VirtualMachine vm = vmProfile.getVirtualMachine();
    Map<String, String> details = vmDetailsDao.listDetailsKeyPairs(vm.getId());
    Boolean isThresholdEnabled = ClusterThresholdEnabled.value();
    if (!(isThresholdEnabled || (details != null && details.containsKey("deployvm")))) {
        return;
    }

    List<Short> capacityList = getCapacitiesForCheckingThreshold();
    List<Long> clustersCrossingThreshold = new ArrayList<Long>();

    ServiceOffering offering = vmProfile.getServiceOffering();
    int cpu_requested = offering.getCpu() * offering.getSpeed();
    long ram_requested = offering.getRamSize() * 1024L * 1024L;

    // For each capacity get the cluster list crossing the threshold and
    // remove it from the clusterList that will be used for vm allocation.
    for (short capacity : capacityList) {

        if (clusterListForVmAllocation == null || clusterListForVmAllocation.size() == 0) {
            return;
        }

        if (capacity == Capacity.CAPACITY_TYPE_CPU) {
            clustersCrossingThreshold =
                    capacityDao.listClustersCrossingThreshold(capacity, plan.getDataCenterId(), ClusterCPUCapacityDisableThreshold.key(), cpu_requested);
        } else if (capacity == Capacity.CAPACITY_TYPE_MEMORY) {
            clustersCrossingThreshold =
                    capacityDao.listClustersCrossingThreshold(capacity, plan.getDataCenterId(), ClusterMemoryCapacityDisableThreshold.key(), ram_requested);
        }

        if (clustersCrossingThreshold != null && clustersCrossingThreshold.size() != 0) {
            // addToAvoid Set
            avoid.addClusterList(clustersCrossingThreshold);
            // Remove clusters crossing disabled threshold
            clusterListForVmAllocation.removeAll(clustersCrossingThreshold);

            s_logger.debug("Cannot allocate cluster list " + clustersCrossingThreshold.toString() + " for vm creation since their allocated percentage" +
                    " crosses the disable capacity threshold defined at each cluster/ at global value for capacity Type : " + capacity + ", skipping these clusters");
        }

    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:56,代码来源:FirstFitPlanner.java

示例13: scanClustersForDestinationInZoneOrPod

import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
private List<Long> scanClustersForDestinationInZoneOrPod(long id, boolean isZone, VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid) {

        VirtualMachine vm = vmProfile.getVirtualMachine();
        ServiceOffering offering = vmProfile.getServiceOffering();
        DataCenter dc = dcDao.findById(vm.getDataCenterId());
        int requiredCpu = offering.getCpu() * offering.getSpeed();
        long requiredRam = offering.getRamSize() * 1024L * 1024L;

        //list clusters under this zone by cpu and ram capacity
        Pair<List<Long>, Map<Long, Double>> clusterCapacityInfo = listClustersByCapacity(id, requiredCpu, requiredRam, avoid, isZone);
        List<Long> prioritizedClusterIds = clusterCapacityInfo.first();
        if (!prioritizedClusterIds.isEmpty()) {
            if (avoid.getClustersToAvoid() != null) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("Removing from the clusterId list these clusters from avoid set: " + avoid.getClustersToAvoid());
                }
                prioritizedClusterIds.removeAll(avoid.getClustersToAvoid());
            }

            if (!isRootAdmin(vmProfile)) {
                List<Long> disabledClusters = new ArrayList<Long>();
                if (isZone) {
                    disabledClusters = listDisabledClusters(plan.getDataCenterId(), null);
                } else {
                    disabledClusters = listDisabledClusters(plan.getDataCenterId(), id);
                }
                if (!disabledClusters.isEmpty()) {
                    if (s_logger.isDebugEnabled()) {
                        s_logger.debug("Removing from the clusterId list these clusters that are disabled/clusters under disabled pods: " + disabledClusters);
                    }
                    prioritizedClusterIds.removeAll(disabledClusters);
                }
            }

            removeClustersCrossingThreshold(prioritizedClusterIds, avoid, vmProfile, plan);
            String hostTagOnOffering = offering.getHostTag();
            if (hostTagOnOffering != null) {
                removeClustersWithoutMatchingTag(prioritizedClusterIds, hostTagOnOffering);
            }

        } else {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("No clusters found having a host with enough capacity, returning.");
            }
            return null;
        }
        if (!prioritizedClusterIds.isEmpty()) {
            List<Long> clusterList = reorderClusters(id, isZone, clusterCapacityInfo, vmProfile, plan);
            return clusterList; //return checkClustersforDestination(clusterList, vmProfile, plan, avoid, dc);
        } else {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("No clusters found after removing disabled clusters and clusters in avoid list, returning.");
            }
            return null;
        }
    }
 
开发者ID:apache,项目名称:cloudstack,代码行数:57,代码来源:FirstFitPlanner.java


注:本文中的com.cloud.offering.ServiceOffering.getSpeed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。