@Override public boolean isDynamic(long serviceOfferingId) { ServiceOfferingVO offering = super.findById(serviceOfferingId); return offering.getCpu() == null || offering.getSpeed() == null || offering.getRamSize() == null; }
@Override public void generateUsageEvent(VirtualMachine vm, boolean isDisplay, String eventType){ ServiceOfferingVO serviceOffering = _offeringDao.findById(vm.getId(), vm.getServiceOfferingId()); if (!serviceOffering.isDynamic()) { UsageEventUtils.publishUsageEvent(eventType, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getHostName(), serviceOffering.getId(), vm.getTemplateId(), vm.getHypervisorType().toString(), VirtualMachine.class.getName(), vm.getUuid(), isDisplay); } else { Map<String, String> customParameters = new HashMap<String, String>(); customParameters.put(UsageEventVO.DynamicParameters.cpuNumber.name(), serviceOffering.getCpu().toString()); customParameters.put(UsageEventVO.DynamicParameters.cpuSpeed.name(), serviceOffering.getSpeed().toString()); customParameters.put(UsageEventVO.DynamicParameters.memory.name(), serviceOffering.getRamSize().toString()); UsageEventUtils.publishUsageEvent(eventType, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getHostName(), serviceOffering.getId(), vm.getTemplateId(), vm.getHypervisorType().toString(), VirtualMachine.class.getName(), vm.getUuid(), customParameters, isDisplay); } }
if (serviceOffering.getSpeed() == null) { String cpuSpeed = customParameters.get(UsageEventVO.DynamicParameters.cpuSpeed.name()); if ((cpuSpeed == null) || (NumbersUtil.parseInt(cpuSpeed, -1) <= 0)) {
hypervisorType.name(), guestOSCategory.getName(), offering.getCpu(), offering.getSpeed(), offering.getRamSize(), diskSize, computeTags, rootDiskTags, networkNicMap, plan, extraDhcpOptionMap); } else { _orchSrvc.createVirtualMachine(vm.getUuid(), Long.toString(owner.getAccountId()), Long.toString(template.getId()), hostName, displayName, hypervisorType.name(), offering.getCpu(), offering.getSpeed(), offering.getRamSize(), diskSize, computeTags, rootDiskTags, networkNicMap, plan, rootDiskSize, extraDhcpOptionMap, dataDiskTemplateToDiskOfferingMap);
float cpuOvercommitRatio = Float.parseFloat(_clusterDetailsDao.findDetail(clusterIdFinal, "cpuOvercommitRatio").getValue()); float memoryOvercommitRatio = Float.parseFloat(_clusterDetailsDao.findDetail(clusterIdFinal, "memoryOvercommitRatio").getValue()); int vmCPU = svo.getCpu() * svo.getSpeed(); long vmMem = svo.getRamSize() * 1024L * 1024L; long actualTotalMem = capacityMemory.getTotalCapacity();
final int cpu = svo.getCpu() * svo.getSpeed(); final long ram = svo.getRamSize() * 1024L * 1024L;
@Override @DB public ServiceOfferingVO persistSystemServiceOffering(ServiceOfferingVO offering) { assert offering.getUniqueName() != null : "how are you going to find this later if you don't set it?"; ServiceOfferingVO vo = findByName(offering.getUniqueName()); if (vo != null) { // check invalid CPU speed in system service offering, set it to default value of 500 Mhz if 0 CPU speed is found if (vo.getSpeed() <= 0) { vo.setSpeed(500); update(vo.getId(), vo); } if (!vo.getUniqueName().endsWith("-Local")) { if (vo.isUseLocalStorage()) { vo.setUniqueName(vo.getUniqueName() + "-Local"); vo.setName(vo.getName() + " - Local Storage"); update(vo.getId(), vo); } } return vo; } try { return persist(offering); } catch (EntityExistsException e) { // Assume it's conflict on unique name return findByName(offering.getUniqueName()); } }
int newCpu = newServiceOffering.getCpu(); int newMemory = newServiceOffering.getRamSize(); int newSpeed = newServiceOffering.getSpeed(); int currentCpu = currentServiceOffering.getCpu(); int currentMemory = currentServiceOffering.getRamSize(); int currentSpeed = currentServiceOffering.getSpeed(); int memoryDiff = newMemory - currentMemory; int cpuDiff = newCpu * newSpeed - currentCpu * currentSpeed;
public ServiceOfferingVO(ServiceOfferingVO offering) { super(offering.getId(), offering.getName(), offering.getDisplayText(), offering.getProvisioningType(), false, offering.getTags(), offering.isRecreatable(), offering.isUseLocalStorage(), offering.isSystemUse(), true, offering.isCustomizedIops()== null ? false:offering.isCustomizedIops(), offering.getDomainId(), offering.getMinIops(), offering.getMaxIops()); cpu = offering.getCpu(); ramSize = offering.getRamSize(); speed = offering.getSpeed(); rateMbps = offering.getRateMbps(); multicastRateMbps = offering.getMulticastRateMbps(); offerHA = offering.isOfferHA(); limitCpuUse = offering.getLimitCpuUse(); volatileVm = offering.isVolatileVm(); hostTag = offering.getHostTag(); vmType = offering.getSystemVmType(); }
sc.addAnd("speed", Op.GTEQ, currentVmOffering.getSpeed()); sc.addAnd("ramSize", Op.GTEQ, currentVmOffering.getRamSize());
public ServiceOfferingDaoImpl() { super(); UniqueNameSearch = createSearchBuilder(); UniqueNameSearch.and("name", UniqueNameSearch.entity().getUniqueName(), SearchCriteria.Op.EQ); UniqueNameSearch.and("system", UniqueNameSearch.entity().isSystemUse(), SearchCriteria.Op.EQ); UniqueNameSearch.done(); ServiceOfferingsByDomainIdSearch = createSearchBuilder(); ServiceOfferingsByDomainIdSearch.and("domainId", ServiceOfferingsByDomainIdSearch.entity().getDomainId(), SearchCriteria.Op.EQ); ServiceOfferingsByDomainIdSearch.done(); SystemServiceOffering = createSearchBuilder(); SystemServiceOffering.and("domainId", SystemServiceOffering.entity().getDomainId(), SearchCriteria.Op.EQ); SystemServiceOffering.and("system", SystemServiceOffering.entity().isSystemUse(), SearchCriteria.Op.EQ); SystemServiceOffering.and("vm_type", SystemServiceOffering.entity().getSpeed(), SearchCriteria.Op.EQ); SystemServiceOffering.and("removed", SystemServiceOffering.entity().getRemoved(), SearchCriteria.Op.NULL); SystemServiceOffering.done(); PublicServiceOfferingSearch = createSearchBuilder(); PublicServiceOfferingSearch.and("domainId", PublicServiceOfferingSearch.entity().getDomainId(), SearchCriteria.Op.NULL); PublicServiceOfferingSearch.and("system", PublicServiceOfferingSearch.entity().isSystemUse(), SearchCriteria.Op.EQ); PublicServiceOfferingSearch.and("removed", PublicServiceOfferingSearch.entity().getRemoved(), SearchCriteria.Op.NULL); PublicServiceOfferingSearch.done(); ServiceOfferingsByKeywordSearch = createSearchBuilder(); ServiceOfferingsByKeywordSearch.or("name", ServiceOfferingsByKeywordSearch.entity().getName(), SearchCriteria.Op.EQ); ServiceOfferingsByKeywordSearch.or("displayText", ServiceOfferingsByKeywordSearch.entity().getDisplayText(), SearchCriteria.Op.EQ); ServiceOfferingsByKeywordSearch.done(); }