Hello Xiaolei Shi,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/33182

to review the following change.

Change subject: core: move vm numa fields to VmBase
......................................................................

core: move vm numa fields to VmBase

Move vm numa related fields to VmBase entity since the fields will also
be called in VmTemplate.

Change-Id: Icc69f8167b8468becef728617ec850dc9034d88f
Bug-Url: https://bugzilla.redhat.com/1069303
Signed-off-by: Bruce Shi <xiao-lei....@hp.com>
Signed-off-by: Gilad Chaplik <gchap...@redhat.com>
---
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/NumaTuneMode.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/VmBaseDaoDbFacade.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java
M packaging/dbscripts/create_views.sql
M packaging/dbscripts/vm_templates_sp.sql
9 files changed, 62 insertions(+), 55 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/82/33182/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 9aca45c..ccb80a6 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
@@ -578,7 +578,8 @@
                         getParameters().getMasterVm().isBootMenuEnabled(),
                         
getParameters().getMasterVm().isSpiceFileTransferEnabled(),
                         
getParameters().getMasterVm().isSpiceCopyPasteEnabled(),
-                        getParameters().getMasterVm().getCpuProfileId()));
+                        getParameters().getMasterVm().getCpuProfileId(),
+                        getParameters().getMasterVm().getNumaTuneMode()));
         DbFacade.getInstance().getVmTemplateDao().save(getVmTemplate());
         getCompensationContext().snapshotNewEntity(getVmTemplate());
         setActionReturnValue(getVmTemplate().getId());
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NumaTuneMode.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NumaTuneMode.java
index eb4e66e..dd74810 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NumaTuneMode.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NumaTuneMode.java
@@ -38,10 +38,6 @@
         value = name().toLowerCase();
     }
 
-    private NumaTuneMode(String value) {
-        this.value = value;
-    }
-
     public String getValue() {
         return value;
     }
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 1a1a621..cc7710d 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
@@ -221,6 +221,12 @@
     @Min(value = 0, message = "VALIDATION.VM.MIGRATION_DOWNTIME_RANGE")
     private Integer migrationDowntime;
 
+    @EditableField
+    private NumaTuneMode numaTuneMode;
+
+    @EditableField
+    private List<VmNumaNode> vNumaNodeList;
+
     public VmBase() {
         name = "";
         interfaces = new ArrayList<VmNetworkInterface>();
@@ -241,6 +247,8 @@
         singleQxlPci = true;
         spiceFileTransferEnabled = true;
         spiceCopyPasteEnabled = true;
+        setNumaTuneMode(NumaTuneMode.INTERLEAVE);
+        vNumaNodeList = new ArrayList<VmNumaNode>();
     }
 
     @EditableField
@@ -379,7 +387,8 @@
                 vmBase.isBootMenuEnabled(),
                 vmBase.isSpiceFileTransferEnabled(),
                 vmBase.isSpiceCopyPasteEnabled(),
-                vmBase.getCpuProfileId());
+                vmBase.getCpuProfileId(),
+                vmBase.getNumaTuneMode());
     }
 
     public VmBase(
@@ -430,7 +439,8 @@
             boolean bootMenuEnabled,
             boolean spiceFileTransferEnabled,
             boolean spiceCopyPasteEnabled,
-            Guid cpuProfileId) {
+            Guid cpuProfileId,
+            NumaTuneMode numaTuneMode) {
         this();
         this.name = name;
         this.id = id;
@@ -478,6 +488,7 @@
         this.customSerialNumber = customSerialNumber;
         this.bootMenuEnabled = bootMenuEnabled;
         this.spiceFileTransferEnabled = spiceFileTransferEnabled;
+        this.numaTuneMode = numaTuneMode;
         this.spiceCopyPasteEnabled = spiceCopyPasteEnabled;
         this.cpuProfileId = cpuProfileId;
     }
@@ -821,6 +832,8 @@
         result = prime * result + (spiceFileTransferEnabled ? 1231 : 1237);
         result = prime * result + (spiceCopyPasteEnabled ? 1231 : 1237);
         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());
         return result;
     }
 
@@ -870,13 +883,15 @@
                 && ObjectUtils.objectsEqual(vncKeyboardLayout, 
other.vncKeyboardLayout)
                 && ObjectUtils.objectsEqual(createdByUserId, 
other.createdByUserId)
                 && cpuShares == other.cpuShares
-                && ObjectUtils.objectsEqual(migrationDowntime, 
other.migrationDowntime))
+                && ObjectUtils.objectsEqual(migrationDowntime, 
other.migrationDowntime)
                 && serialNumberPolicy == other.serialNumberPolicy
                 && ObjectUtils.objectsEqual(customSerialNumber, 
other.customSerialNumber)
                 && bootMenuEnabled == other.bootMenuEnabled
                 && spiceFileTransferEnabled == other.spiceFileTransferEnabled
                 && spiceCopyPasteEnabled == other.spiceCopyPasteEnabled
-                && ObjectUtils.objectsEqual(cpuProfileId, other.cpuProfileId);
+                && ObjectUtils.objectsEqual(cpuProfileId, other.cpuProfileId)
+                && ObjectUtils.objectsEqual(numaTuneMode.getValue(), 
other.numaTuneMode.getValue())
+                && ObjectUtils.objectsEqual(vNumaNodeList, 
other.vNumaNodeList));
     }
 
     public Guid getQuotaId() {
@@ -1055,4 +1070,21 @@
     public void setCpuProfileId(Guid cpuProfileId) {
         this.cpuProfileId = cpuProfileId;
     }
+
+    public NumaTuneMode getNumaTuneMode() {
+        return numaTuneMode;
+    }
+
+    public void setNumaTuneMode(NumaTuneMode numaTuneMode) {
+        this.numaTuneMode = numaTuneMode;
+    }
+
+    public List<VmNumaNode> getvNumaNodeList() {
+        return vNumaNodeList;
+    }
+
+    public void setvNumaNodeList(List<VmNumaNode> vNumaNodeList) {
+        this.vNumaNodeList = vNumaNodeList;
+    }
+
 }
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 658f648..5673851 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
@@ -1,8 +1,5 @@
 package org.ovirt.engine.core.common.businessentities;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import javax.validation.constraints.Size;
 import javax.validation.groups.Default;
 
@@ -58,10 +55,6 @@
     @EditableField
     private boolean useLatestVersion;
 
-    private NumaTuneMode numaTuneMode;
-
-    private List<VmNumaNode> vNumaNodeList;
-
     public VmStatic() {
         setNumOfMonitors(1);
         initialized = false;
@@ -71,8 +64,6 @@
         setDefaultDisplayType(DisplayType.qxl);
         setVmType(VmType.Desktop);
         vmtGuid = Guid.Empty;
-        setNumaTuneMode(NumaTuneMode.PREFERRED);
-        vNumaNodeList = new ArrayList<VmNumaNode>();
         customProperties = "";
     }
 
@@ -178,8 +169,6 @@
         result = prime * result + ((originalTemplateGuid == null) ? 0 : 
originalTemplateGuid.hashCode());
         result = prime * result + ((originalTemplateName == null) ? 0 : 
originalTemplateName.hashCode());
         result = prime * result + (useLatestVersion ? 1249 : 1259);
-        result = prime * result + ((numaTuneMode == null) ? 0 : 
numaTuneMode.getValue().hashCode());
-        result = prime * result + ((vNumaNodeList == null) ? 0 : 
vNumaNodeList.hashCode());
 
         return result;
     }
@@ -208,8 +197,6 @@
                 && ObjectUtils.objectsEqual(originalTemplateGuid, 
other.originalTemplateGuid)
                 && ObjectUtils.objectsEqual(originalTemplateName, 
other.originalTemplateName)
                 && useLatestVersion == other.useLatestVersion
-                && ObjectUtils.objectsEqual(numaTuneMode.getValue(), 
other.numaTuneMode.getValue())
-                && ObjectUtils.objectsEqual(vNumaNodeList, other.vNumaNodeList)
          );
     }
 
@@ -267,22 +254,6 @@
 
     public void setUseLatestVersion(boolean useLatestVersion) {
         this.useLatestVersion = useLatestVersion;
-    }
-
-    public NumaTuneMode getNumaTuneMode() {
-        return numaTuneMode;
-    }
-
-    public void setNumaTuneMode(NumaTuneMode numaTuneMode) {
-        this.numaTuneMode = numaTuneMode;
-    }
-
-    public List<VmNumaNode> getvNumaNodeList() {
-        return vNumaNodeList;
-    }
-
-    public void setvNumaNodeList(List<VmNumaNode> vNumaNodeList) {
-        this.vNumaNodeList = vNumaNodeList;
     }
 
 }
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 d226fe4..c1ff012 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,7 @@
             Guid baseTemplateId, String templateVersionName,
             SerialNumberPolicy serialNumberPolicy, String customSerialNumber,
             boolean bootMenuEnabled, boolean spiceFIleTransferEnabled, boolean 
spiceCopyPasteEnabled,
-            Guid cpuProfileId) {
+            Guid cpuProfileId, NumaTuneMode numaTuneMode) {
         super(name,
                 vmtGuid,
                 vdsGroupId,
@@ -126,7 +126,8 @@
                 bootMenuEnabled,
                 spiceFIleTransferEnabled,
                 spiceCopyPasteEnabled,
-                cpuProfileId);
+                cpuProfileId,
+                numaTuneMode);
 
         diskTemplateMap = new HashMap<Guid, DiskImage>();
         diskImageMap = new HashMap<Guid, DiskImage>();
@@ -192,6 +193,7 @@
         setCustomSerialNumber(template.getCustomSerialNumber());
         setBootMenuEnabled(template.isBootMenuEnabled());
         setSpiceFileTransferEnabled(template.isSpiceFileTransferEnabled());
+        setNumaTuneMode(template.getNumaTuneMode());
         setSpiceCopyPasteEnabled(template.isSpiceCopyPasteEnabled());
     }
 
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 c141e1c..2df4b43 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
@@ -6,6 +6,7 @@
 import org.ovirt.engine.core.common.businessentities.BootSequence;
 import org.ovirt.engine.core.common.businessentities.DisplayType;
 import org.ovirt.engine.core.common.businessentities.MigrationSupport;
+import org.ovirt.engine.core.common.businessentities.NumaTuneMode;
 import org.ovirt.engine.core.common.businessentities.OriginType;
 import org.ovirt.engine.core.common.businessentities.SerialNumberPolicy;
 import org.ovirt.engine.core.common.businessentities.SsoMethod;
@@ -68,7 +69,8 @@
                 .addValue("is_boot_menu_enabled", entity.isBootMenuEnabled())
                 .addValue("is_spice_file_transfer_enabled", 
entity.isSpiceFileTransferEnabled())
                 .addValue("is_spice_copy_paste_enabled", 
entity.isSpiceCopyPasteEnabled())
-                .addValue("cpu_profile_id", entity.getCpuProfileId());
+                .addValue("cpu_profile_id", entity.getCpuProfileId())
+                .addValue("numatune_mode", 
entity.getNumaTuneMode().getValue());
     }
 
     /**
@@ -122,6 +124,7 @@
             entity.setMinAllocatedMem(rs.getInt("min_allocated_mem"));
             entity.setQuotaId(getGuid(rs, "quota_id"));
             entity.setCpuProfileId(getGuid(rs, "cpu_profile_id"));
+            
entity.setNumaTuneMode(NumaTuneMode.forValue(rs.getString("numatune_mode")));
         }
     }
 }
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 7a5c6fa..355b51b 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
@@ -6,7 +6,6 @@
 
 import org.apache.commons.lang.NotImplementedException;
 import org.apache.commons.lang.StringUtils;
-import org.ovirt.engine.core.common.businessentities.NumaTuneMode;
 import org.ovirt.engine.core.common.businessentities.VmStatic;
 import org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils;
 import org.ovirt.engine.core.compat.Guid;
@@ -43,10 +42,7 @@
                 .addValue("original_template_name", 
vm.getOriginalTemplateName())
                 .addValue("original_template_id", vm.getOriginalTemplateGuid())
                 .addValue("template_version_number", vm.isUseLatestVersion() ?
-                        USE_LATEST_VERSION_NUMBER_INDICATOR : 
DONT_USE_LATEST_VERSION_NUMBER_INDICATOR)
-                .addValue("numatune_mode",
-                        vm.getNumaTuneMode() == null ? 
NumaTuneMode.PREFERRED.getValue() : vm.getNumaTuneMode()
-                                .getValue());
+                        USE_LATEST_VERSION_NUMBER_INDICATOR : 
DONT_USE_LATEST_VERSION_NUMBER_INDICATOR);
     }
 
     @Override
@@ -190,7 +186,6 @@
             entity.setOriginalTemplateGuid(getGuid(rs, 
"original_template_id"));
             // if template_version_number is null it means use latest version
             entity.setUseLatestVersion(rs.getObject("template_version_number") 
== USE_LATEST_VERSION_NUMBER_INDICATOR);
-            
entity.setNumaTuneMode(NumaTuneMode.forValue(rs.getString("numatune_mode")));
 
             return entity;
         }
diff --git a/packaging/dbscripts/create_views.sql 
b/packaging/dbscripts/create_views.sql
index b06b650..9074c4c 100644
--- a/packaging/dbscripts/create_views.sql
+++ b/packaging/dbscripts/create_views.sql
@@ -446,7 +446,8 @@
        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.cpu_profile_id as cpu_profile_id,
+       vm_templates.numatune_mode as numatune_mode
 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
@@ -485,7 +486,7 @@
                     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.cpu_profile_id as cpu_profile_id, 
vm_templates.numatune_mode as numatune_mode
 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
@@ -515,7 +516,8 @@
                       vm_templates_1.is_boot_menu_enabled as 
is_boot_menu_enabled,
                       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.cpu_profile_id as cpu_profile_id,
+                      vm_templates_1.numatune_mode as numatune_mode
 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 7f81570..ff34b18 100644
--- a/packaging/dbscripts/vm_templates_sp.sql
+++ b/packaging/dbscripts/vm_templates_sp.sql
@@ -59,7 +59,8 @@
  v_is_boot_menu_enabled BOOLEAN,
  v_is_spice_file_transfer_enabled BOOLEAN,
  v_is_spice_copy_paste_enabled BOOLEAN,
- v_cpu_profile_id UUID)
+ v_cpu_profile_id UUID,
+ v_numatune_mode VARCHAR(20))
 
 RETURNS VOID
    AS $procedure$
@@ -132,7 +133,8 @@
     is_boot_menu_enabled,
     is_spice_file_transfer_enabled,
     is_spice_copy_paste_enabled,
-    cpu_profile_id)
+    cpu_profile_id,
+    numatune_mode)
 VALUES(
     v_child_count,
     v_creation_date,
@@ -187,7 +189,8 @@
     v_is_boot_menu_enabled,
     v_is_spice_file_transfer_enabled,
     v_is_spice_copy_paste_enabled,
-    v_cpu_profile_id);
+    v_cpu_profile_id,
+    v_numatune_mode);
 -- 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)
@@ -252,7 +255,8 @@
  v_is_boot_menu_enabled BOOLEAN,
  v_is_spice_file_transfer_enabled BOOLEAN,
  v_is_spice_copy_paste_enabled BOOLEAN,
- v_cpu_profile_id UUID)
+ v_cpu_profile_id UUID,
+ v_numatune_mode VARCHAR(20))
 RETURNS VOID
 
        --The [vm_templates] table doesn't have a timestamp column. Optimistic 
concurrency logic cannot be generated
@@ -280,7 +284,8 @@
       template_version_name = v_template_version_name,
       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
+      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
       WHERE vm_guid = v_vmt_guid
       AND   entity_type = v_template_type;
 


-- 
To view, visit http://gerrit.ovirt.org/33182
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc69f8167b8468becef728617ec850dc9034d88f
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Gilad Chaplik <gchap...@redhat.com>
Gerrit-Reviewer: Xiaolei Shi <xiao-lei....@hp.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to