Federico Simoncelli has uploaded a new change for review.

Change subject: core: add alignment scan lost changes
......................................................................

core: add alignment scan lost changes

During the rebase of I4858b7bb few changes has been lost. This patch
reintroduces them.

Change-Id: Ie30552eb8967c5f9e4473fcbf15edd983f25da34
Signed-off-by: Federico Simoncelli <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommand.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommandTest.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BaseDisk.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskAlignment.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/GetDiskAlignmentVDSCommand.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
M packaging/dbscripts/upgrade/03_03_0320_base_disks_alignment.sql
10 files changed, 38 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/18/16418/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommand.java
index 9286ec6..ed2f709 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommand.java
@@ -75,7 +75,7 @@
 
     private String getDiskIsUsedByGetAlignment() {
         return new 
StringBuilder(VdcBllMessages.ACTION_TYPE_FAILED_DISK_IS_USED_BY_GET_ALIGNMENT.name())
-                .append(String.format("DiskAlias %1$s", getDiskAlias()))
+                .append(String.format("$DiskAlias %1$s", getDiskAlias()))
                 .toString();
     }
 
@@ -116,7 +116,7 @@
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_RUNNING);
         }
 
-        if (getVdsIdInPool() == null) {
+        if (getVdsIdInGroup() == null) {
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NO_VDS_IN_POOL);
         }
 
@@ -140,7 +140,7 @@
             DiskImage diskImage = (DiskImage) getDisk();
 
             GetDiskImageAlignmentVDSCommandParameters imageParameters =
-                    new 
GetDiskImageAlignmentVDSCommandParameters(getVdsIdInPool(), vmId);
+                    new 
GetDiskImageAlignmentVDSCommandParameters(getVdsIdInGroup(), vmId);
 
             imageParameters.setPoolId(getStoragePoolId());
             imageParameters.setDomainId(diskImage.getStorageIds().get(0));
@@ -152,7 +152,7 @@
             LunDisk lunDisk = (LunDisk) getDisk();
 
             GetDiskLunAlignmentVDSCommandParameters lunParameters =
-                    new 
GetDiskLunAlignmentVDSCommandParameters(getVdsIdInPool(), vmId);
+                    new 
GetDiskLunAlignmentVDSCommandParameters(getVdsIdInGroup(), vmId);
 
             lunParameters.setLunId(lunDisk.getLun().getLUN_id());
 
@@ -221,6 +221,7 @@
                 ((DiskImage) getDisk()).getVolumeFormat() != VolumeFormat.RAW);
     }
 
+    @Override
     public Guid getStoragePoolId() {
         if (storagePoolId == null && getVm() != null) {
             storagePoolId = getVm().getStoragePoolId();
@@ -228,16 +229,9 @@
         return storagePoolId;
     }
 
-    public Guid getVdsGroupId() {
-        if (vdsGroupId == null && getVm() != null) {
-            vdsGroupId = getVm().getVdsGroupId();
-        }
-        return vdsGroupId;
-    }
-
-    protected Guid getVdsIdInPool() {
-        if (vdsInPool == null && getVdsGroupId() != null) {
-            List<VDS> vdsInPoolList = 
getVdsDAO().getAllForVdsGroupWithStatus(getVdsGroupId(), VDSStatus.Up);
+    protected Guid getVdsIdInGroup() {
+        if (vdsInPool == null && getVdsGroup() != null) {
+            List<VDS> vdsInPoolList = 
getVdsDAO().getAllForVdsGroupWithStatus(getVdsGroup().getId(), VDSStatus.Up);
             if (!vdsInPoolList.isEmpty()) {
                 vdsInPool = vdsInPoolList.get(0).getId();
             }
@@ -261,6 +255,7 @@
         return getDbFacade().getStoragePoolDao();
     }
 
+    @Override
     public VM getVm() {
         if (diskVm == null && getDisk() != null) {
             for (VM vm : getVmDAO().getVmsListForDisk(getDisk().getId())) {
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommandTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommandTest.java
index ee8d24b..f4dbb8c 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommandTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommandTest.java
@@ -19,6 +19,7 @@
 import org.ovirt.engine.core.common.businessentities.StoragePool;
 import org.ovirt.engine.core.common.businessentities.StoragePoolStatus;
 import org.ovirt.engine.core.common.businessentities.VDS;
+import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.businessentities.VmDevice;
@@ -29,6 +30,7 @@
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.dao.StoragePoolDAO;
 import org.ovirt.engine.core.dao.VdsDAO;
+import org.ovirt.engine.core.dao.VdsGroupDAO;
 import org.ovirt.engine.core.dao.VmDAO;
 import org.ovirt.engine.core.dao.VmDeviceDAO;
 import org.ovirt.engine.core.utils.ejb.BeanType;
@@ -56,6 +58,9 @@
     @Mock
     private VmDeviceDAO vmDeviceDao;
 
+    @Mock
+    private VdsGroupDAO vdsGroupDao;
+
     private GetDiskAlignmentCommand<GetDiskAlignmentParameters> cmd;
 
     private Guid vmId, diskId, poolId, groupId, vdsId;
@@ -64,6 +69,7 @@
     private VDS vds;
     private VmDevice vmDevice;
     private StoragePool storagePool;
+    private VDSGroup vdsGroup;
 
     @Before
     public void setUp() {
@@ -88,6 +94,9 @@
         vmDevice = new VmDevice();
         vmDevice.setId(vmDeviceId);
 
+        vdsGroup = new VDSGroup();
+        vdsGroup.setId(groupId);
+
         vds = new VDS();
         vds.setId(vdsId);
 
@@ -96,17 +105,17 @@
 
         
when(vmDao.getVmsListForDisk(diskId)).thenReturn(Collections.singletonList(vm));
         when(vmDeviceDao.get(vmDeviceId)).thenReturn(vmDevice);
-        when(vdsDao.getAllForVdsGroupWithStatus(groupId, VDSStatus.Up))
-                .thenReturn(Collections.singletonList(vds));
+        when(vdsDao.getAllForVdsGroupWithStatus(groupId, 
VDSStatus.Up)).thenReturn(Collections.singletonList(vds));
         when(spDao.get(poolId)).thenReturn(storagePool);
+        when(vdsGroupDao.get(groupId)).thenReturn(vdsGroup);
 
-        cmd = spy(new GetDiskAlignmentCommand<GetDiskAlignmentParameters>(
-                new GetDiskAlignmentParameters(diskId)));
+        cmd = spy(new GetDiskAlignmentCommand<GetDiskAlignmentParameters>(new 
GetDiskAlignmentParameters(diskId)));
 
         doReturn(disk).when(cmd).getDisk();
         doReturn(vdsDao).when(cmd).getVdsDAO();
         doReturn(vmDao).when(cmd).getVmDAO();
         doReturn(spDao).when(cmd).getStoragePoolDao();
+        doReturn(vdsGroupDao).when(cmd).getVdsGroupDAO();
     }
 
     /* Tests for canDoAction() flow */
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BaseDisk.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BaseDisk.java
index fee5417..b482658 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BaseDisk.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BaseDisk.java
@@ -75,7 +75,7 @@
 
     private ScsiGenericIO sgio;
 
-    private DiskAlignment alignment;
+    private DiskAlignment alignment = DiskAlignment.Unknown;
 
     private Date lastAlignmentScan;
 
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskAlignment.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskAlignment.java
index 0e8f8b7..c8095e3 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskAlignment.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskAlignment.java
@@ -10,7 +10,7 @@
     Misaligned(2),
     Aligned(3);
 
-    private int intValue;
+    private int value;
     private static final Map<Integer, DiskAlignment> mappings;
 
     static {
@@ -22,11 +22,11 @@
     }
 
     private DiskAlignment(int value) {
-        intValue = value;
+        this.value = value;
     }
 
     public int getValue() {
-        return intValue;
+        return value;
     }
 
     public static DiskAlignment forValue(int value) {
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
index cf500c1..df6d106 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -807,7 +807,7 @@
 ACTION_TYPE_FAILED_SHAREABLE_DISK_NOT_SUPPORTED=Cannot ${action} a shareable 
${type} (${diskAliases}). This operation is not supported.
 ACTION_TYPE_FAILED_DISK_NOT_EXIST=Cannot ${action} ${type}. The specified disk 
does not exist.
 ACTION_TYPE_FAILED_NO_DISKS_SPECIFIED=Cannot ${action} ${type}. No disks have 
been specified.
-ACTION_TYPE_FAILED_DISK_IS_NOT_VM_DISK=Cannot ${action} ${type}. The following 
disks are not attached to any VM: ${diskAliases}.
+ACTION_TYPE_FAILED_DISK_IS_NOT_VM_DISK=Cannot ${action} ${type}. The following 
disk(s) are not attached to any VM: ${diskAliases}.
 ACTION_TYPE_FAILED_DISK_IS_NOT_TEMPLATE_DISK=Cannot ${action} ${type}. The 
selected disk is not a template disk. Only template disks can be copied.
 ACTION_TYPE_FAILED_SOURCE_AND_TARGET_SAME=Cannot ${action} ${type}. The source 
and target storage domains are the same.
 ACTION_TYPE_FAILED_CANNOT_MOVE_TEMPLATE_DISK=Cannot ${action} ${type}. 
Template disks cannot be moved.
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties
 
b/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties
index a29fe02..95e4bda 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties
@@ -97,7 +97,7 @@
 job.UpdateGlusterHook=Updating Gluster Hook ${GlusterHookName} on conflicting 
servers in Cluster ${Cluster}
 job.AddGlusterHook=Adding Gluster Hook ${GlusterHookName} on conflicting 
servers in Cluster ${Cluster}
 job.RemoveGlusterHook=Removing Gluster Hook ${GlusterHookName} from all 
servers in Cluster ${Cluster}
-job.GetDiskAlignment=Scanning Block Alignment on Disk ${DiskAlias}
+job.GetDiskAlignment=Scanning Alignment on Disk ${DiskAlias}
 
 # Step types
 step.VALIDATING=Validating
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/GetDiskAlignmentVDSCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/GetDiskAlignmentVDSCommand.java
index 73e6e75..4988fc5 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/GetDiskAlignmentVDSCommand.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/GetDiskAlignmentVDSCommand.java
@@ -11,6 +11,13 @@
 
     @Override
     protected void ExecuteVdsBrokerCommand() {
+        log.info("-- GetDiskAlignmentVDSCommand::ExecuteVdsBrokerCommand: 
calling 'getDiskAlignment' ");
+        log.infoFormat("-- getDiskAlignment parameters:" + "\r\n"
+                + "                vmId={0}" + "\r\n"
+                + "                driveSpecs={1}" + "\r\n",
+                getParameters().getVmId().toString(),
+                getParameters().getDriveSpecs().toString());
+
         diskAlignment = 
getBroker().getDiskAlignment(getParameters().getVmId().toString(), 
getParameters().getDriveSpecs());
         ProceedProxyReturnValue();
 
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index 853bd17..cdf4eec 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -795,7 +795,7 @@
 ACTION_TYPE_FAILED_SHAREABLE_DISK_NOT_SUPPORTED=Cannot ${action} a shareable 
${type}. This operation is not supported.
 ACTION_TYPE_FAILED_DISK_NOT_EXIST=Cannot ${action} ${type}. The specified disk 
does not exist.
 ACTION_TYPE_FAILED_NO_DISKS_SPECIFIED=Cannot ${action} ${type}. No disks have 
been specified.
-ACTION_TYPE_FAILED_DISK_IS_NOT_VM_DISK=Cannot ${action} ${type}. The following 
disks are not attached to any VM: ${diskAliases}.
+ACTION_TYPE_FAILED_DISK_IS_NOT_VM_DISK=Cannot ${action} ${type}. The following 
disk(s) are not attached to any VM: ${diskAliases}.
 ACTION_TYPE_FAILED_DISK_IS_NOT_TEMPLATE_DISK=Cannot ${action} ${type}. The 
selected disk is not a template disk. Only template disks can be copied.
 ACTION_TYPE_FAILED_SOURCE_AND_TARGET_SAME=Cannot ${action} ${type}. The source 
and target storage domains are the same.
 ACTION_TYPE_FAILED_CANNOT_MOVE_TEMPLATE_DISK=Cannot ${action} ${type}. 
Template disks cannot be moved.
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index 37effc6..6f2731e 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -806,7 +806,7 @@
 ACTION_TYPE_FAILED_SHAREABLE_DISK_NOT_SUPPORTED=Cannot ${action} a shareable 
${type} (${diskAliases}). This operation is not supported.
 ACTION_TYPE_FAILED_DISK_NOT_EXIST=Cannot ${action} ${type}. The specified disk 
does not exist.
 ACTION_TYPE_FAILED_NO_DISKS_SPECIFIED=Cannot ${action} ${type}. No disks have 
been specified.
-ACTION_TYPE_FAILED_DISK_IS_NOT_VM_DISK=Cannot ${action} ${type}. The following 
disks are not attached to any VM: ${diskAliases}.
+ACTION_TYPE_FAILED_DISK_IS_NOT_VM_DISK=Cannot ${action} ${type}. The following 
disk(s) are not attached to any VM: ${diskAliases}.
 ACTION_TYPE_FAILED_DISK_IS_NOT_TEMPLATE_DISK=Cannot ${action} ${type}. The 
selected disk is not a template disk. Only template disks can be copied.
 ACTION_TYPE_FAILED_SOURCE_AND_TARGET_SAME=Cannot ${action} ${type}. The source 
and target storage domains are the same.
 ACTION_TYPE_FAILED_CANNOT_MOVE_TEMPLATE_DISK=Cannot ${action} ${type}. 
Template disks cannot be moved.
diff --git a/packaging/dbscripts/upgrade/03_03_0320_base_disks_alignment.sql 
b/packaging/dbscripts/upgrade/03_03_0320_base_disks_alignment.sql
index 07a63be..14c2436 100644
--- a/packaging/dbscripts/upgrade/03_03_0320_base_disks_alignment.sql
+++ b/packaging/dbscripts/upgrade/03_03_0320_base_disks_alignment.sql
@@ -1,3 +1,3 @@
-select fn_db_add_column('base_disks', 'alignment', 'smallint default 0');
+select fn_db_add_column('base_disks', 'alignment', 'smallint not null default 
0');
 select fn_db_add_column('base_disks', 'last_alignment_scan', 'timestamp with 
time zone');
 insert into action_version_map values (232, '3.3', '*');


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie30552eb8967c5f9e4473fcbf15edd983f25da34
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to