Omer Frenkel has uploaded a new change for review. Change subject: core: add custom properties to templates ......................................................................
core: add custom properties to templates currently custom properties are vm only feature, so adding also to templates. Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1166632 Change-Id: I85f8fb998b5e081c10d93e5790963fb7b8bdf5fd Signed-off-by: Omer Frenkel <ofren...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmTemplateCommandTest.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/customprop/VmPropertiesUtils.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmBaseDaoDbFacade.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java M packaging/dbscripts/create_views.sql M packaging/dbscripts/vm_templates_sp.sql 12 files changed, 173 insertions(+), 82 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/23/35423/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java index ccd214c..8a1c35f 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java @@ -61,6 +61,7 @@ import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.common.locks.LockingGroup; import org.ovirt.engine.core.common.utils.Pair; +import org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils; import org.ovirt.engine.core.common.validation.group.CreateEntity; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.backendcompat.CommandExecutionStatus; @@ -117,6 +118,8 @@ parameters.setConsoleEnabled(false); } VmHandler.updateDefaultTimeZone(parameterMasterVm); + + separateCustomProperties(parameterMasterVm); } if (getVm() != null) { updateVmDevices(); @@ -131,6 +134,15 @@ setStoragePoolId(getVdsGroup().getStoragePoolId()); } updateDiskInfoDestinationMap(); + } + + protected void separateCustomProperties(VmStatic parameterMasterVm) { + if (getVdsGroup() != null) { + // Parses the custom properties field that was filled by frontend to + // predefined and user defined fields + VmPropertiesUtils.getInstance().separateCustomPropertiesToUserAndPredefined( + getVdsGroup().getcompatibility_version(), parameterMasterVm); + } } public AddVmTemplateCommand(T parameters) { @@ -361,6 +373,13 @@ // Disallow cross-DC template creation if (!getStoragePoolId().equals(getVdsGroup().getStoragePoolId())) { addCanDoActionMessage(VdcBllMessages.VDS_CLUSTER_ON_DIFFERENT_STORAGE_POOL); + return false; + } + + if (!VmPropertiesUtils.getInstance().validateVmProperties( + getVdsGroup().getcompatibility_version(), + getParameters().getMasterVm().getCustomProperties(), + getReturnValue().getCanDoActionMessages())) { return false; } @@ -609,7 +628,10 @@ getParameters().getMasterVm().isSpiceFileTransferEnabled(), getParameters().getMasterVm().isSpiceCopyPasteEnabled(), getParameters().getMasterVm().getCpuProfileId(), - getParameters().getMasterVm().getNumaTuneMode())); + getParameters().getMasterVm().getNumaTuneMode(), + getParameters().getMasterVm().getUserDefinedProperties(), + getParameters().getMasterVm().getPredefinedProperties(), + getParameters().getMasterVm().getCustomProperties())); DbFacade.getInstance().getVmTemplateDao().save(getVmTemplate()); getCompensationContext().snapshotNewEntity(getVmTemplate()); setActionReturnValue(getVmTemplate().getId()); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java index a91989d..33d8e0a 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java @@ -29,6 +29,7 @@ import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.common.locks.LockingGroup; import org.ovirt.engine.core.common.utils.Pair; +import org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils; import org.ovirt.engine.core.common.validation.group.UpdateEntity; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.dal.dbbroker.DbFacade; @@ -45,8 +46,15 @@ setVmTemplateId(getVmTemplate().getId()); setVdsGroupId(getVmTemplate().getVdsGroupId()); if (getVdsGroup() != null) { + mOldTemplate = DbFacade.getInstance().getVmTemplateDao().get(getVmTemplate().getId()); setStoragePoolId(getVdsGroup().getStoragePoolId() != null ? getVdsGroup().getStoragePoolId() : Guid.Empty); + getVmPropertiesUtils().separateCustomPropertiesToUserAndPredefined(getVdsGroup().getcompatibility_version(), + parameters.getVmTemplateData()); + if (mOldTemplate != null) { + getVmPropertiesUtils().separateCustomPropertiesToUserAndPredefined(getVdsGroup().getcompatibility_version(), + mOldTemplate); + } } VmHandler.updateDefaultTimeZone(parameters.getVmTemplateData()); } @@ -63,7 +71,7 @@ return failCanDoAction(VdcBllMessages.VMT_CANNOT_EDIT_BLANK_TEMPLATE); } boolean returnValue = false; - mOldTemplate = DbFacade.getInstance().getVmTemplateDao().get(getVmTemplate().getId()); + if (mOldTemplate == null) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST); } @@ -167,6 +175,13 @@ if (getParameters().getVmTemplateData().getMinAllocatedMem() > getParameters().getVmTemplateData().getMemSizeMb()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_MIN_MEMORY_CANNOT_EXCEED_MEMORY_SIZE); + } + + if (!getVmPropertiesUtils().validateVmProperties( + getVdsGroup().getcompatibility_version(), + getParameters().getVmTemplateData().getCustomProperties(), + getReturnValue().getCanDoActionMessages())) { + return false; } return returnValue; @@ -353,4 +368,8 @@ getVdsGroup().getcompatibility_version())); } + private VmPropertiesUtils getVmPropertiesUtils() { + return VmPropertiesUtils.getInstance(); + } + } diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmTemplateCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmTemplateCommandTest.java index 4283ba9..f769065 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmTemplateCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmTemplateCommandTest.java @@ -32,6 +32,7 @@ import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; +import org.ovirt.engine.core.common.businessentities.VmStatic; import org.ovirt.engine.core.common.config.ConfigValues; import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.common.osinfo.OsRepository; @@ -110,6 +111,10 @@ public VM getVm() { return vm; } + + @Override + public void separateCustomProperties(VmStatic parameterMasterVm) { + } }); doReturn(vmDao).when(cmd).getVmDAO(); doReturn(vdsGroupDao).when(cmd).getVdsGroupDAO(); diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java index ecdf995..658c93a 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java @@ -227,6 +227,25 @@ @EditableField private List<VmNumaNode> vNumaNodeList; + @CopyOnNewVersion + @EditableOnVmStatusField + @EditableOnTemplate + @OvfExportOnlyField(exportOption = ExportOption.EXPORT_NON_IGNORED_VALUES) + @Size(max = BusinessEntitiesDefinitions.GENERAL_MAX_SIZE) + private String userDefinedProperties; + + @CopyOnNewVersion + @EditableOnVmStatusField + @EditableOnTemplate + @OvfExportOnlyField(exportOption = ExportOption.EXPORT_NON_IGNORED_VALUES) + @Size(max = BusinessEntitiesDefinitions.GENERAL_MAX_SIZE) + private String predefinedProperties; + + @CopyOnNewVersion + @EditableOnVmStatusField + @EditableOnTemplate + private String customProperties; + public VmBase() { name = ""; interfaces = new ArrayList<VmNetworkInterface>(); @@ -249,6 +268,7 @@ spiceCopyPasteEnabled = true; setNumaTuneMode(NumaTuneMode.INTERLEAVE); vNumaNodeList = new ArrayList<VmNumaNode>(); + customProperties = ""; } @EditableField @@ -389,7 +409,10 @@ vmBase.isSpiceFileTransferEnabled(), vmBase.isSpiceCopyPasteEnabled(), vmBase.getCpuProfileId(), - vmBase.getNumaTuneMode()); + vmBase.getNumaTuneMode(), + vmBase.getUserDefinedProperties(), + vmBase.getPredefinedProperties(), + vmBase.getCustomProperties()); } public VmBase( @@ -441,7 +464,10 @@ boolean spiceFileTransferEnabled, boolean spiceCopyPasteEnabled, Guid cpuProfileId, - NumaTuneMode numaTuneMode) { + NumaTuneMode numaTuneMode, + String userDefinedProperties, + String predefinedProperties, + String customProperties) { this(); this.name = name; this.id = id; @@ -492,6 +518,9 @@ this.numaTuneMode = numaTuneMode; this.spiceCopyPasteEnabled = spiceCopyPasteEnabled; this.cpuProfileId = cpuProfileId; + this.userDefinedProperties = userDefinedProperties; + this.predefinedProperties = predefinedProperties; + this.customProperties = customProperties; } public long getDbGeneration() { @@ -835,6 +864,8 @@ result = prime * result + ((cpuProfileId == null) ? 0 : cpuProfileId.hashCode()); result = prime * result + ((numaTuneMode == null) ? 0 : numaTuneMode.getValue().hashCode()); result = prime * result + ((vNumaNodeList == null) ? 0 : vNumaNodeList.hashCode()); + result = prime * result + ((predefinedProperties == null) ? 0 : predefinedProperties.hashCode()); + result = prime * result + ((userDefinedProperties == null) ? 0 : userDefinedProperties.hashCode()); return result; } @@ -892,7 +923,9 @@ && spiceCopyPasteEnabled == other.spiceCopyPasteEnabled && ObjectUtils.objectsEqual(cpuProfileId, other.cpuProfileId) && ObjectUtils.objectsEqual(numaTuneMode.getValue(), other.numaTuneMode.getValue()) - && ObjectUtils.objectsEqual(vNumaNodeList, other.vNumaNodeList)); + && ObjectUtils.objectsEqual(vNumaNodeList, other.vNumaNodeList)) + && ObjectUtils.objectsEqual(predefinedProperties, other.predefinedProperties) + && ObjectUtils.objectsEqual(userDefinedProperties, other.userDefinedProperties); } public Guid getQuotaId() { @@ -1088,4 +1121,28 @@ this.vNumaNodeList = vNumaNodeList; } + public String getCustomProperties() { + return customProperties; + } + + public void setCustomProperties(String customProperties) { + this.customProperties = customProperties; + } + + public String getPredefinedProperties() { + return predefinedProperties; + } + + public void setPredefinedProperties(String predefinedProperties) { + this.predefinedProperties = predefinedProperties; + } + + public String getUserDefinedProperties() { + return userDefinedProperties; + } + + public void setUserDefinedProperties(String userDefinedProperties) { + this.userDefinedProperties = userDefinedProperties; + } + } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java index 5673851..2084627 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java @@ -22,23 +22,10 @@ private Guid originalTemplateGuid; - @EditableOnVmStatusField - @OvfExportOnlyField(exportOption = ExportOption.EXPORT_NON_IGNORED_VALUES) - @Size(max = BusinessEntitiesDefinitions.GENERAL_MAX_SIZE) - private String userDefinedProperties; - - @EditableOnVmStatusField - @OvfExportOnlyField(exportOption = ExportOption.EXPORT_NON_IGNORED_VALUES) - @Size(max = BusinessEntitiesDefinitions.GENERAL_MAX_SIZE) - private String predefinedProperties; - /** * Disk size in sectors of 512 bytes */ private int diskSize; - - @EditableOnVmStatusField - private String customProperties; @EditableField @OvfExportOnlyField(exportOption = ExportOption.EXPORT_NON_IGNORED_VALUES) @@ -64,13 +51,11 @@ setDefaultDisplayType(DisplayType.qxl); setVmType(VmType.Desktop); vmtGuid = Guid.Empty; - customProperties = ""; } public VmStatic(VmStatic vmStatic) { this((VmBase)vmStatic); vmtGuid = vmStatic.getVmtGuid(); - setCustomProperties(vmStatic.getCustomProperties()); setInitialized(vmStatic.isInitialized()); setUseLatestVersion(vmStatic.isUseLatestVersion()); setInstanceTypeId(vmStatic.getInstanceTypeId()); @@ -78,30 +63,6 @@ public VmStatic(VmBase vmBase) { super(vmBase); - } - - public String getCustomProperties() { - return customProperties; - } - - public void setCustomProperties(String customProperties) { - this.customProperties = customProperties; - } - - public String getPredefinedProperties() { - return predefinedProperties; - } - - public void setPredefinedProperties(String predefinedProperties) { - this.predefinedProperties = predefinedProperties; - } - - public String getUserDefinedProperties() { - return userDefinedProperties; - } - - public void setUserDefinedProperties(String userDefinedProperties) { - this.userDefinedProperties = userDefinedProperties; } public int getDiskSize() { @@ -160,8 +121,6 @@ result = prime * result + (initialized ? 1231 : 1237); result = prime * result + diskSize; result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); - result = prime * result + ((predefinedProperties == null) ? 0 : predefinedProperties.hashCode()); - result = prime * result + ((userDefinedProperties == null) ? 0 : userDefinedProperties.hashCode()); result = prime * result + ((vmtGuid == null) ? 0 : vmtGuid.hashCode()); result = prime * result + (useHostCpuFlags ? 1231 : 1237); result = prime * result + ((instanceTypeId == null) ? 0 : instanceTypeId.hashCode()); @@ -188,8 +147,6 @@ return (initialized == other.initialized && diskSize == other.diskSize && ObjectUtils.objectsEqual(getName(), other.getName()) - && ObjectUtils.objectsEqual(predefinedProperties, other.predefinedProperties) - && ObjectUtils.objectsEqual(userDefinedProperties, other.userDefinedProperties) && ObjectUtils.objectsEqual(vmtGuid, other.vmtGuid) && useHostCpuFlags == other.useHostCpuFlags && ObjectUtils.objectsEqual(instanceTypeId, other.instanceTypeId) diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java index c1ff012..c900b1b 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java @@ -78,7 +78,10 @@ Guid baseTemplateId, String templateVersionName, SerialNumberPolicy serialNumberPolicy, String customSerialNumber, boolean bootMenuEnabled, boolean spiceFIleTransferEnabled, boolean spiceCopyPasteEnabled, - Guid cpuProfileId, NumaTuneMode numaTuneMode) { + Guid cpuProfileId, NumaTuneMode numaTuneMode, + String userDefinedProperties, + String predefinedProperties, + String customProperties) { super(name, vmtGuid, vdsGroupId, @@ -127,7 +130,10 @@ spiceFIleTransferEnabled, spiceCopyPasteEnabled, cpuProfileId, - numaTuneMode); + numaTuneMode, + userDefinedProperties, + predefinedProperties, + customProperties); diskTemplateMap = new HashMap<Guid, DiskImage>(); diskImageMap = new HashMap<Guid, DiskImage>(); @@ -195,6 +201,9 @@ setSpiceFileTransferEnabled(template.isSpiceFileTransferEnabled()); setNumaTuneMode(template.getNumaTuneMode()); setSpiceCopyPasteEnabled(template.isSpiceCopyPasteEnabled()); + setUserDefinedProperties(template.getUserDefinedProperties()); + setPredefinedProperties(template.getPredefinedProperties()); + setCustomProperties(template.getCustomProperties()); } public ArchitectureType getClusterArch() { diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/customprop/VmPropertiesUtils.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/customprop/VmPropertiesUtils.java index 4c1ad82..743668b 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/customprop/VmPropertiesUtils.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/customprop/VmPropertiesUtils.java @@ -6,7 +6,7 @@ import java.util.Map.Entry; import java.util.Set; -import org.ovirt.engine.core.common.businessentities.VmStatic; +import org.ovirt.engine.core.common.businessentities.VmBase; import org.ovirt.engine.core.common.config.Config; import org.ovirt.engine.core.common.config.ConfigValues; import org.ovirt.engine.core.common.utils.exceptions.InitializationException; @@ -115,11 +115,11 @@ * * @return map containing the VM custom properties */ - public Map<String, String> getVMProperties(Version version, VmStatic vmStatic) { - separateCustomPropertiesToUserAndPredefined(version, vmStatic); + public Map<String, String> getVMProperties(Version version, VmBase vmBase) { + separateCustomPropertiesToUserAndPredefined(version, vmBase); Map<String, String> map = new HashMap<String, String>(); - getPredefinedProperties(version, vmStatic, map); - getUserDefinedProperties(version, vmStatic, map); + getPredefinedProperties(version, vmBase, map); + getUserDefinedProperties(version, vmBase, map); return map; } @@ -128,13 +128,13 @@ return allVmProperties; } - private void getPredefinedProperties(Version version, VmStatic vmStatic, Map<String, String> propertiesMap) { - String predefinedProperties = vmStatic.getPredefinedProperties(); + private void getPredefinedProperties(Version version, VmBase vmBase, Map<String, String> propertiesMap) { + String predefinedProperties = vmBase.getPredefinedProperties(); getVMProperties(version, propertiesMap, predefinedProperties); } - private void getUserDefinedProperties(Version version, VmStatic vmStatic, Map<String, String> propertiesMap) { - String UserDefinedProperties = vmStatic.getUserDefinedProperties(); + private void getUserDefinedProperties(Version version, VmBase vmBase, Map<String, String> propertiesMap) { + String UserDefinedProperties = vmBase.getUserDefinedProperties(); getVMProperties(version, propertiesMap, UserDefinedProperties); } @@ -200,11 +200,11 @@ return result.toString(); } - public void separateCustomPropertiesToUserAndPredefined(Version version, VmStatic vmStatic) { - String customProperties = vmStatic.getCustomProperties(); + public void separateCustomPropertiesToUserAndPredefined(Version version, VmBase vmBase) { + String customProperties = vmBase.getCustomProperties(); VMCustomProperties properties = parseProperties(version, customProperties); - vmStatic.setPredefinedProperties(properties.getPredefinedProperties()); - vmStatic.setUserDefinedProperties(properties.getUseDefinedProperties()); + vmBase.setPredefinedProperties(properties.getPredefinedProperties()); + vmBase.setUserDefinedProperties(properties.getUseDefinedProperties()); } /** diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmBaseDaoDbFacade.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmBaseDaoDbFacade.java index 2df4b43..226de63 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmBaseDaoDbFacade.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmBaseDaoDbFacade.java @@ -13,6 +13,7 @@ import org.ovirt.engine.core.common.businessentities.UsbPolicy; import org.ovirt.engine.core.common.businessentities.VmBase; import org.ovirt.engine.core.common.businessentities.VmType; +import org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.dal.dbbroker.DbFacadeUtils; import org.springframework.jdbc.core.RowMapper; @@ -70,7 +71,9 @@ .addValue("is_spice_file_transfer_enabled", entity.isSpiceFileTransferEnabled()) .addValue("is_spice_copy_paste_enabled", entity.isSpiceCopyPasteEnabled()) .addValue("cpu_profile_id", entity.getCpuProfileId()) - .addValue("numatune_mode", entity.getNumaTuneMode().getValue()); + .addValue("numatune_mode", entity.getNumaTuneMode().getValue()) + .addValue("predefined_properties", entity.getPredefinedProperties()) + .addValue("userdefined_properties", entity.getUserDefinedProperties()); } /** @@ -125,6 +128,12 @@ entity.setQuotaId(getGuid(rs, "quota_id")); entity.setCpuProfileId(getGuid(rs, "cpu_profile_id")); entity.setNumaTuneMode(NumaTuneMode.forValue(rs.getString("numatune_mode"))); + String predefinedProperties = rs.getString("predefined_properties"); + String userDefinedProperties = rs.getString("userdefined_properties"); + entity.setPredefinedProperties(predefinedProperties); + entity.setUserDefinedProperties(userDefinedProperties); + entity.setCustomProperties(VmPropertiesUtils.getInstance().customProperties(predefinedProperties, + userDefinedProperties)); } } } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java index 355b51b..7f0492e 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java @@ -7,7 +7,6 @@ import org.apache.commons.lang.NotImplementedException; import org.apache.commons.lang.StringUtils; import org.ovirt.engine.core.common.businessentities.VmStatic; -import org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils; import org.ovirt.engine.core.compat.Guid; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; @@ -32,9 +31,6 @@ .addValue("vm_name", vm.getName()) .addValue("vmt_guid", vm.getVmtGuid()) .addValue("is_initialized", vm.isInitialized()) - .addValue("predefined_properties", vm.getPredefinedProperties()) - .addValue("userdefined_properties", - vm.getUserDefinedProperties()) .addValue("cpu_pinning", vm.getCpuPinning()) .addValue("host_cpu_flags", vm.isUseHostCpuFlags()) .addValue("instance_type_id", vm.getInstanceTypeId()) @@ -172,12 +168,6 @@ entity.setName(rs.getString("vm_name")); entity.setVmtGuid(getGuidDefaultEmpty(rs, "vmt_guid")); entity.setInitialized(rs.getBoolean("is_initialized")); - String predefinedProperties = rs.getString("predefined_properties"); - String userDefinedProperties = rs.getString("userdefined_properties"); - entity.setPredefinedProperties(predefinedProperties); - entity.setUserDefinedProperties(userDefinedProperties); - entity.setCustomProperties(VmPropertiesUtils.getInstance().customProperties(predefinedProperties, - userDefinedProperties)); entity.setCpuPinning(rs.getString("cpu_pinning")); entity.setUseHostCpuFlags(rs.getBoolean("host_cpu_flags")); entity.setInstanceTypeId(Guid.createGuidFromString(rs.getString("instance_type_id"))); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java index df3a81a..483e21c 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java @@ -222,6 +222,9 @@ vm.setSpiceFileTransferEnabled(instance.isSpiceFileTransferEnabled()); vm.setSpiceCopyPasteEnabled(instance.isSpiceCopyPasteEnabled()); vm.setCpuProfileId(instance.getCpuProfileId()); + vm.setPredefinedProperties(instance.getPredefinedProperties()); + vm.setUserDefinedProperties(instance.getUserDefinedProperties()); + vm.setCustomProperties(instance.getCustomProperties()); return vm; } @@ -447,6 +450,9 @@ obj.setSpiceFileTransferEnabled(instance.isSpiceFileTransferEnabled()); obj.setSpiceCopyPasteEnabled(instance.isSpiceCopyPasteEnabled()); obj.setCpuProfileId(instance.getCpuProfileId()); + obj.setPredefinedProperties(instance.getPredefinedProperties()); + obj.setUserDefinedProperties(instance.getUserDefinedProperties()); + obj.setCustomProperties(instance.getCustomProperties()); return obj; } @@ -490,6 +496,9 @@ obj.setSpiceFileTransferEnabled(instance.isSpiceFileTransferEnabled()); obj.setSpiceCopyPasteEnabled(instance.isSpiceCopyPasteEnabled()); obj.setCpuProfileId(instance.getCpuProfileId()); + obj.setPredefinedProperties(instance.getPredefinedProperties()); + obj.setUserDefinedProperties(instance.getUserDefinedProperties()); + obj.setCustomProperties(instance.getCustomProperties()); return obj; } diff --git a/packaging/dbscripts/create_views.sql b/packaging/dbscripts/create_views.sql index 8eca807..797a0db 100644 --- a/packaging/dbscripts/create_views.sql +++ b/packaging/dbscripts/create_views.sql @@ -451,7 +451,9 @@ vm_templates.is_spice_file_transfer_enabled as is_spice_file_transfer_enabled, vm_templates.is_spice_copy_paste_enabled as is_spice_copy_paste_enabled, vm_templates.cpu_profile_id as cpu_profile_id, - vm_templates.numatune_mode as numatune_mode + vm_templates.numatune_mode as numatune_mode, + vm_templates.predefined_properties as predefined_properties, + vm_templates.userdefined_properties as userdefined_properties FROM vm_static AS vm_templates LEFT OUTER JOIN vds_groups ON vm_templates.vds_group_id = vds_groups.vds_group_id left outer JOIN @@ -490,7 +492,9 @@ vm_templates.serial_number_policy as serial_number_policy, vm_templates.custom_serial_number as custom_serial_number, vm_templates.is_boot_menu_enabled as is_boot_menu_enabled, vm_templates.is_spice_file_transfer_enabled as is_spice_file_transfer_enabled, vm_templates.is_spice_copy_paste_enabled as is_spice_copy_paste_enabled, - vm_templates.cpu_profile_id as cpu_profile_id, vm_templates.numatune_mode as numatune_mode + vm_templates.cpu_profile_id as cpu_profile_id, vm_templates.numatune_mode as numatune_mode, + vm_templates.predefined_properties as predefined_properties, vm_templates.userdefined_properties as userdefined_properties + FROM vm_static AS vm_templates LEFT OUTER JOIN vds_groups ON vm_templates.vds_group_id = vds_groups.vds_group_id LEFT OUTER JOIN storage_pool ON storage_pool.id = vds_groups.storage_pool_id INNER JOIN @@ -521,7 +525,8 @@ vm_templates_1.is_spice_file_transfer_enabled as is_spice_file_transfer_enabled, vm_templates_1.is_spice_copy_paste_enabled as is_spice_copy_paste_enabled, vm_templates_1.cpu_profile_id as cpu_profile_id, - vm_templates_1.numatune_mode as numatune_mode + vm_templates_1.numatune_mode as numatune_mode, + vm_templates_1.predefined_properties as predefined_properties, vm_templates_1.userdefined_properties as userdefined_properties FROM vm_static AS vm_templates_1 LEFT OUTER JOIN vds_groups AS vds_groups_1 ON vm_templates_1.vds_group_id = vds_groups_1.vds_group_id LEFT OUTER JOIN storage_pool AS storage_pool_1 ON storage_pool_1.id = vds_groups_1.storage_pool_id INNER JOIN diff --git a/packaging/dbscripts/vm_templates_sp.sql b/packaging/dbscripts/vm_templates_sp.sql index ff34b18..d92d296 100644 --- a/packaging/dbscripts/vm_templates_sp.sql +++ b/packaging/dbscripts/vm_templates_sp.sql @@ -60,7 +60,9 @@ v_is_spice_file_transfer_enabled BOOLEAN, v_is_spice_copy_paste_enabled BOOLEAN, v_cpu_profile_id UUID, - v_numatune_mode VARCHAR(20)) + v_numatune_mode VARCHAR(20), + v_predefined_properties VARCHAR(4000), + v_userdefined_properties VARCHAR(4000)) RETURNS VOID AS $procedure$ @@ -134,7 +136,9 @@ is_spice_file_transfer_enabled, is_spice_copy_paste_enabled, cpu_profile_id, - numatune_mode) + numatune_mode, + predefined_properties, + userdefined_properties) VALUES( v_child_count, v_creation_date, @@ -190,7 +194,9 @@ v_is_spice_file_transfer_enabled, v_is_spice_copy_paste_enabled, v_cpu_profile_id, - v_numatune_mode); + v_numatune_mode, + v_predefined_properties, + v_userdefined_properties); -- perform deletion from vm_ovf_generations to ensure that no record exists when performing insert to avoid PK violation. DELETE FROM vm_ovf_generations gen WHERE gen.vm_guid = v_vmt_guid; INSERT INTO vm_ovf_generations(vm_guid, storage_pool_id) @@ -256,7 +262,9 @@ v_is_spice_file_transfer_enabled BOOLEAN, v_is_spice_copy_paste_enabled BOOLEAN, v_cpu_profile_id UUID, - v_numatune_mode VARCHAR(20)) + v_numatune_mode VARCHAR(20), + v_predefined_properties VARCHAR(4000), +v_userdefined_properties VARCHAR(4000)) RETURNS VOID --The [vm_templates] table doesn't have a timestamp column. Optimistic concurrency logic cannot be generated @@ -285,7 +293,8 @@ serial_number_policy = v_serial_number_policy, custom_serial_number = v_custom_serial_number, is_boot_menu_enabled = v_is_boot_menu_enabled, is_spice_file_transfer_enabled = v_is_spice_file_transfer_enabled, is_spice_copy_paste_enabled = v_is_spice_copy_paste_enabled, cpu_profile_id = v_cpu_profile_id, - numatune_mode = v_numatune_mode + numatune_mode = v_numatune_mode, + predefined_properties = v_predefined_properties,userdefined_properties = v_userdefined_properties WHERE vm_guid = v_vmt_guid AND entity_type = v_template_type; -- To view, visit http://gerrit.ovirt.org/35423 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I85f8fb998b5e081c10d93e5790963fb7b8bdf5fd Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Omer Frenkel <ofren...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches