@Override public List<ServiceOfferingVO> createSystemServiceOfferings(String name, String uniqueName, int cpuCount, int ramSize, int cpuSpeed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, String displayText, ProvisioningType provisioningType, boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vmType, boolean defaultUse) { List<ServiceOfferingVO> list = new ArrayList<ServiceOfferingVO>(); ServiceOfferingVO offering = new ServiceOfferingVO(name, cpuCount, ramSize, cpuSpeed, rateMbps, multicastRateMbps, offerHA, displayText, provisioningType, false, recreatable, tags, systemUse, vmType, defaultUse); offering.setUniqueName(uniqueName); offering = persistSystemServiceOffering(offering); if (offering != null) { list.add(offering); } boolean useLocal = true; if (offering.isUseLocalStorage()) { // if 1st one is already local then 2nd needs to be shared useLocal = false; } offering = new ServiceOfferingVO(name + (useLocal ? " - Local Storage" : ""), cpuCount, ramSize, cpuSpeed, rateMbps, multicastRateMbps, offerHA, displayText, provisioningType, useLocal, recreatable, tags, systemUse, vmType, defaultUse); offering.setUniqueName(uniqueName + (useLocal ? "-Local" : "")); offering = persistSystemServiceOffering(offering); if (offering != null) { list.add(offering); } return list; }
if (vmOffering.isUseLocalStorage()) { if (s_logger.isDebugEnabled()){ s_logger.debug("Skipping HA on vm " + vm + ", because it uses local storage. Its fate is tied to the host.");
if (currentServiceOffering.isUseLocalStorage() != newServiceOffering.isUseLocalStorage()) { throw new InvalidParameterValueException("Unable to upgrade virtual machine " + vmInstance.toString() + ", cannot switch between local storage and shared storage service offerings. Current offering " + "useLocalStorage=" + currentServiceOffering.isUseLocalStorage() + ", target offering useLocalStorage=" + newServiceOffering.isUseLocalStorage());
if (currentServiceOffering.isUseLocalStorage() != newServiceOffering.isUseLocalStorage()) { throw new InvalidParameterValueException("Can't upgrade, due to new local storage status : " + newServiceOffering.isUseLocalStorage() + " is different from " + "curruent local storage status: " + currentServiceOffering.isUseLocalStorage());
@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()); } }
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("useLocalStorage", SearchCriteria.Op.EQ, currentVmOffering.isUseLocalStorage());