Libor Spevak has uploaded a new change for review. Change subject: userportal, webadmin: Guaranteed memory not propagated ......................................................................
userportal, webadmin: Guaranteed memory not propagated Physical Memory Guaranteed parameter (min. allocated memory field) not propagated to new VM Pool/new VM from VM Template problem fixed. Current code doesn't store min. allocated memory of the template to the database and computes it using cluster settings (max_vds_memory_over_commit). Now the template min. allocated memory parameter value takes preference over default expression. Change-Id: I5b82e01d78de1eca585d6e11d326b0f842db52ae Signed-off-by: Libor Spevak <[email protected]> --- M backend/manager/dbscripts/create_views.sql M backend/manager/dbscripts/vm_templates_sp.sql M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.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/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PoolModelBehaviorBase.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java 12 files changed, 59 insertions(+), 36 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/13/12413/1 diff --git a/backend/manager/dbscripts/create_views.sql b/backend/manager/dbscripts/create_views.sql index ec9d080..54a7a4a 100644 --- a/backend/manager/dbscripts/create_views.sql +++ b/backend/manager/dbscripts/create_views.sql @@ -376,7 +376,8 @@ vm_templates.dedicated_vm_for_vds, vm_templates.is_disabled, vm_templates.tunnel_migration, - vm_templates.vnc_keyboard_layout as vnc_keyboard_layout + vm_templates.vnc_keyboard_layout as vnc_keyboard_layout, + vm_templates.min_allocated_mem as min_allocated_mem FROM vm_static AS vm_templates INNER JOIN vds_groups ON vm_templates.vds_group_id = vds_groups.vds_group_id left outer JOIN diff --git a/backend/manager/dbscripts/vm_templates_sp.sql b/backend/manager/dbscripts/vm_templates_sp.sql index 05442af..47cdf0b 100644 --- a/backend/manager/dbscripts/vm_templates_sp.sql +++ b/backend/manager/dbscripts/vm_templates_sp.sql @@ -44,7 +44,8 @@ v_migration_support integer, v_dedicated_vm_for_vds UUID, v_tunnel_migration BOOLEAN, - v_vnc_keyboard_layout VARCHAR(16)) + v_vnc_keyboard_layout VARCHAR(16), + v_min_allocated_mem INTEGER) RETURNS VOID AS $procedure$ @@ -90,7 +91,8 @@ is_smartcard_enabled, is_delete_protected, tunnel_migration, - vnc_keyboard_layout) + vnc_keyboard_layout, + min_allocated_mem) VALUES( -- This field is meaningless for templates for the time being, however we want to keep it not null for VMs. -- Thus, since templates are top level elements they "point" to the 'Blank' template. @@ -133,7 +135,8 @@ v_is_smartcard_enabled, v_is_delete_protected, v_tunnel_migration, - v_vnc_keyboard_layout); + v_vnc_keyboard_layout, + v_min_allocated_mem INTEGER); -- 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) @@ -184,7 +187,8 @@ v_migration_support integer, v_dedicated_vm_for_vds uuid, v_tunnel_migration BOOLEAN, - v_vnc_keyboard_layout VARCHAR(16)) + v_vnc_keyboard_layout VARCHAR(16), + v_min_allocated_mem INTEGER) RETURNS VOID --The [vm_templates] table doesn't have a timestamp column. Optimistic concurrency logic cannot be generated @@ -206,7 +210,7 @@ kernel_url = v_kernel_url,kernel_params = v_kernel_params, _update_date = CURRENT_TIMESTAMP, quota_id = v_quota_id, migration_support = v_migration_support, dedicated_vm_for_vds = v_dedicated_vm_for_vds, is_smartcard_enabled = v_is_smartcard_enabled, is_delete_protected = v_is_delete_protected, is_disabled = v_is_disabled, tunnel_migration = v_tunnel_migration, - vnc_keyboard_layout = v_vnc_keyboard_layout + vnc_keyboard_layout = v_vnc_keyboard_layout, min_allocated_mem = v_min_allocated_mem WHERE vm_guid = v_vmt_guid AND entity_type = 'TEMPLATE'; END; $procedure$ 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 df21ed4..89bc8fe 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 @@ -26,6 +26,7 @@ import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VdcReturnValueBase; import org.ovirt.engine.core.common.businessentities.DiskImage; +import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.businessentities.StorageDomainStatus; import org.ovirt.engine.core.common.businessentities.StorageDomainType; import org.ovirt.engine.core.common.businessentities.VMStatus; @@ -34,7 +35,6 @@ import org.ovirt.engine.core.common.businessentities.VmTemplate; import org.ovirt.engine.core.common.businessentities.VmTemplateStatus; import org.ovirt.engine.core.common.businessentities.permissions; -import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.businessentities.network.VmInterfaceType; import org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface; import org.ovirt.engine.core.common.errors.VdcBLLException; @@ -301,7 +301,8 @@ getParameters().getMasterVm().isSmartcardEnabled(), getParameters().getMasterVm().isDeleteProtected(), getParameters().getMasterVm().getTunnelMigration(), - getParameters().getMasterVm().getVncKeyboardLayout())); + getParameters().getMasterVm().getVncKeyboardLayout(), + getParameters().getMasterVm().getMinAllocatedMem())); getVmTemplate().setAutoStartup(getParameters().getMasterVm().isAutoStartup()); getVmTemplate().setPriority(getParameters().getMasterVm().getPriority()); getVmTemplate().setDefaultDisplayType(getParameters().getMasterVm().getDefaultDisplayType()); 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 fdb9d33..312d631 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 @@ -192,6 +192,9 @@ message = "VALIDATION.VM.INVALID_KEYBOARD_LAYOUT") private String vncKeyboardLayout; + @EditableField + private int minAllocatedMem; + public VmBase(Guid id, Guid vdsGroupId, VmOsType os, @@ -221,7 +224,8 @@ boolean smartcardEnabled, boolean deleteProtected, Boolean tunnelMigration, - String vncKeyboardLayout) { + String vncKeyboardLayout, + int minAllocatedMem) { super(); this.id = id; this.vdsGroupId = vdsGroupId; @@ -252,6 +256,7 @@ this.deleteProtected = deleteProtected; this.tunnelMigration = tunnelMigration; this.vncKeyboardLayout = vncKeyboardLayout; + this.minAllocatedMem = minAllocatedMem; setQuotaId(quotaId); } @@ -836,4 +841,12 @@ this.name = value; } + public int getMinAllocatedMem() { + return minAllocatedMem; + } + + public void setMinAllocatedMem(int value) { + minAllocatedMem = value; + } + } 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 98cc4f3..95b9fb3 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 @@ -32,9 +32,6 @@ */ private int diskSize; - @EditableField - private int minAllocatedMem; - @EditableOnVmStatusField private String customProperties; @@ -86,7 +83,8 @@ vmStatic.isSmartcardEnabled(), vmStatic.isDeleteProtected(), vmStatic.getTunnelMigration(), - vmStatic.getVncKeyboardLayout()); + vmStatic.getVncKeyboardLayout(), + vmStatic.getMinAllocatedMem()); setName(vmStatic.getName()); vmtGuid = vmStatic.getVmtGuid(); setCustomProperties(vmStatic.getCustomProperties()); @@ -95,7 +93,6 @@ setDefaultDisplayType(vmStatic.getDefaultDisplayType()); setDedicatedVmForVds(vmStatic.getDedicatedVmForVds()); setMigrationSupport(vmStatic.getMigrationSupport()); - setMinAllocatedMem(vmStatic.getMinAllocatedMem()); } public String getCustomProperties() { @@ -134,6 +131,7 @@ return !isInitialized(); } + @Override @Size(min = 1, max = BusinessEntitiesDefinitions.VM_NAME_SIZE, groups = { Default.class, ImportClonedEntity.class }) @ValidI18NName(message = "ACTION_TYPE_FAILED_NAME_MAY_NOT_CONTAIN_SPECIAL_CHARS", groups = { CreateEntity.class, UpdateEntity.class, ImportClonedEntity.class }) @@ -155,17 +153,6 @@ public void setInitialized(boolean value) { initialized = value; - } - - public int getMinAllocatedMem() { - if (minAllocatedMem > 0) { - return minAllocatedMem; - } - return getMemSizeMb(); - } - - public void setMinAllocatedMem(int value) { - minAllocatedMem = value; } @Override 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 c9a36c6..98b2aaf 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 @@ -58,7 +58,8 @@ int num_of_sockets, int cpu_per_socket, VmOsType os, Guid vds_group_id, Guid vmt_guid, String domain, int num_of_monitors, int status, int usb_policy, String time_zone, boolean is_auto_suspend, int nice_level, boolean fail_back, BootSequence default_boot_sequence, VmType vm_type, - boolean smartcardEnabled, boolean deleteProtected, Boolean tunnelMigration, String vncKeyboardLayout) { + boolean smartcardEnabled, boolean deleteProtected, Boolean tunnelMigration, String vncKeyboardLayout, + int minAllocatedMem) { super(vmt_guid, vds_group_id, os, @@ -88,7 +89,8 @@ smartcardEnabled, deleteProtected, tunnelMigration, - vncKeyboardLayout); + vncKeyboardLayout, + minAllocatedMem); diskTemplateMap = new HashMap<Guid, DiskImage>(); diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java index cd157a5..7be0ba6 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java @@ -166,7 +166,8 @@ .addValue("migration_support", template.getMigrationSupport().getValue()) .addValue("dedicated_vm_for_vds", template.getDedicatedVmForVds()) .addValue("tunnel_migration", template.getTunnelMigration()) - .addValue("vnc_keyboard_layout", template.getVncKeyboardLayout()); + .addValue("vnc_keyboard_layout", template.getVncKeyboardLayout()) + .addValue("min_allocated_mem", template.getMinAllocatedMem()); } @Override @@ -233,6 +234,7 @@ entity.setDisabled(rs.getBoolean("is_disabled")); entity.setTunnelMigration((Boolean) rs.getObject("tunnel_migration")); entity.setVncKeyboardLayout(rs.getString("vnc_keyboard_layout")); + entity.setMinAllocatedMem(rs.getInt("min_allocated_mem")); return entity; } } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java index e6053ab..4db2b13 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java @@ -15,13 +15,13 @@ import org.ovirt.engine.core.common.businessentities.DisplayType; import org.ovirt.engine.core.common.businessentities.MigrationSupport; import org.ovirt.engine.core.common.businessentities.Quota; +import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.businessentities.UsbPolicy; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VmOsType; import org.ovirt.engine.core.common.businessentities.VmTemplate; import org.ovirt.engine.core.common.businessentities.VmTemplateStatus; -import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.interfaces.SearchType; import org.ovirt.engine.core.common.mode.ApplicationMode; import org.ovirt.engine.core.common.queries.SearchParameters; @@ -508,6 +508,7 @@ template.setDescription((String) model.getDescription().getEntity()); template.setDomain(model.getDomain().getIsAvailable() ? (String) model.getDomain().getSelectedItem() : ""); //$NON-NLS-1$ template.setMemSizeMb((Integer) model.getMemSize().getEntity()); + template.setMinAllocatedMem(((Integer) model.getMinAllocatedMemory().getEntity())); template.setVdsGroupId(((VDSGroup) model.getCluster().getSelectedItem()).getId()); template.setTimeZone((model.getTimeZone().getIsAvailable() && model.getTimeZone().getSelectedItem() != null) ? ((Map.Entry<String, String>) model.getTimeZone() .getSelectedItem()).getKey() diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java index a0cdcc3..06fe474 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java @@ -12,13 +12,13 @@ import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.DisplayType; import org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum; +import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.businessentities.StorageDomainStatus; import org.ovirt.engine.core.common.businessentities.StorageDomainType; import org.ovirt.engine.core.common.businessentities.StorageType; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VolumeType; -import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.businessentities.storage_pool; import org.ovirt.engine.core.compat.StringHelper; import org.ovirt.engine.ui.frontend.AsyncQuery; @@ -212,6 +212,7 @@ { // Update model state according to VM properties. getModel().getMemSize().setEntity(this.vm.getVmMemSizeMb()); + getModel().getMinAllocatedMemory().setEntity(this.vm.getMinAllocatedMem()); getModel().getOSType().setSelectedItem(this.vm.getVmOs()); getModel().getDomain().setSelectedItem(this.vm.getVmDomain()); getModel().getUsbPolicy().setSelectedItem(this.vm.getUsbPolicy()); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java index e2ac6d6..86cf4e6 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java @@ -4,12 +4,12 @@ import org.ovirt.engine.core.common.businessentities.DisplayType; import org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum; +import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.businessentities.StoragePoolStatus; import org.ovirt.engine.core.common.businessentities.StorageType; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VmTemplate; import org.ovirt.engine.core.common.businessentities.VmType; -import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.businessentities.storage_pool; import org.ovirt.engine.core.compat.NGuid; import org.ovirt.engine.core.compat.StringHelper; @@ -171,7 +171,13 @@ InitPriority(template.getPriority()); InitStorageDomains(); - UpdateMinAllocatedMemory(); + + // use min. allocated memory from the template, if specified + if (template.getMinAllocatedMem() == 0) { + UpdateMinAllocatedMemory(); + } else { + getModel().getMinAllocatedMemory().setEntity(template.getMinAllocatedMem()); + } } } @@ -209,8 +215,7 @@ public void UpdateMinAllocatedMemory() { VDSGroup cluster = (VDSGroup) getModel().getCluster().getSelectedItem(); - if (cluster == null) - { + if (cluster == null) { return; } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PoolModelBehaviorBase.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PoolModelBehaviorBase.java index f86d751..1eb0233 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PoolModelBehaviorBase.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PoolModelBehaviorBase.java @@ -195,7 +195,13 @@ InitPriority(vmBase.getPriority()); InitStorageDomains(); - UpdateMinAllocatedMemory(); + + // use min. allocated memory from the template, if specified + if (vmBase.getMinAllocatedMem() == 0) { + UpdateMinAllocatedMemory(); + } else { + getModel().getMinAllocatedMemory().setEntity(vmBase.getMinAllocatedMem()); + } } } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java index f54d00e..f29d717 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java @@ -12,12 +12,12 @@ import org.ovirt.engine.core.common.businessentities.BootSequence; import org.ovirt.engine.core.common.businessentities.DisplayType; import org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum; +import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.businessentities.UsbPolicy; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VmOsType; import org.ovirt.engine.core.common.businessentities.VmType; -import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.businessentities.storage_pool; import org.ovirt.engine.core.common.queries.VdcQueryType; import org.ovirt.engine.core.compat.Guid; -- To view, visit http://gerrit.ovirt.org/12413 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5b82e01d78de1eca585d6e11d326b0f842db52ae Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Libor Spevak <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
