Tal Nisan has uploaded a new change for review.

Change subject: core: Block live storage migration to domain of a different type
......................................................................

core: Block live storage migration to domain of a different type

This change fails live storage migration CDA part in case that the source
storage domain and the destination domain are not both either a file
type domain or a block domain

Change-Id: Iec4c34132a1a619527627cfa47fa99df3a023b62
Signed-off-by: Tal Nisan <tni...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/lsm/LiveMigrateVmDisksCommand.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/lsm/LiveMigrateVmDisksCommandTest.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StorageType.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.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
8 files changed, 60 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/62/23962/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/lsm/LiveMigrateVmDisksCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/lsm/LiveMigrateVmDisksCommand.java
index 8f19b22..e002625 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/lsm/LiveMigrateVmDisksCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/lsm/LiveMigrateVmDisksCommand.java
@@ -276,14 +276,35 @@
             
getReturnValue().setCanDoAction(isDiskNotShareable(parameters.getImageId())
                     && 
isDiskSnapshotNotPluggedToOtherVmsThatAreNotDown(parameters.getImageId())
                     && isTemplateInDestStorageDomain(parameters.getImageId(), 
parameters.getStorageDomainId())
-                    && validateSourceStorageDomain(parameters.getImageId())
-                    && validateDestStorage(parameters.getImageId(), 
parameters.getStorageDomainId()));
+                    && performStorageDomainsChecks(parameters));
 
             if (!getReturnValue().getCanDoAction()) {
                 return false;
             }
         }
 
+        return true;
+    }
+
+    private boolean performStorageDomainsChecks(LiveMigrateDiskParameters 
parameters) {
+        StorageDomain sourceDomain = 
getImageSourceDomain(parameters.getImageId());
+        StorageDomain destDomain = 
getStorageDomainById(parameters.getStorageDomainId(), getStoragePoolId());
+
+        return validateSourceStorageDomain(sourceDomain)
+                && validateDestStorage(destDomain)
+                && validateDestStorageAndSourceStorageOfSameTypes(destDomain, 
sourceDomain);
+    }
+
+    private StorageDomain getImageSourceDomain(Guid imageId) {
+        DiskImage diskImage = getDiskImageByImageId(imageId);
+        Guid domainId = diskImage.getStorageIds().get(0);
+        return getStorageDomainById(domainId, getStoragePoolId());
+    }
+
+    private boolean 
validateDestStorageAndSourceStorageOfSameTypes(StorageDomain destDomain, 
StorageDomain sourceDomain) {
+        if (destDomain.getStorageType().getStorageSubtype() != 
sourceDomain.getStorageType().getStorageSubtype()) {
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_DESTINATION_AND_SOURCE_STORAGE_SUB_TYPES_DIFFERENT);
+        }
         return true;
     }
 
@@ -325,22 +346,14 @@
         return true;
     }
 
-    private boolean validateSourceStorageDomain(Guid imageId) {
-        DiskImage diskImage = getDiskImageByImageId(imageId);
-        Guid domainId = diskImage.getStorageIds().get(0);
-        StorageDomainValidator validator = getValidator(domainId, 
getStoragePoolId());
-
+    private boolean validateSourceStorageDomain(StorageDomain sourceDomain) {
+        StorageDomainValidator validator = new 
StorageDomainValidator(sourceDomain);
         return validate(validator.isDomainExistAndActive());
     }
 
-    private boolean validateDestStorage(Guid imageId, Guid destDomainId) {
-        StorageDomainValidator validator = getValidator(destDomainId, 
getStoragePoolId());
-
+    private boolean validateDestStorage(StorageDomain destDomain) {
+        StorageDomainValidator validator = new 
StorageDomainValidator(destDomain);
         return validate(validator.isDomainExistAndActive()) && 
validate(validator.domainIsValidDestination());
-    }
-
-    private StorageDomainValidator getValidator(Guid domainId, Guid 
storagePoolId) {
-        return new StorageDomainValidator(getStorageDomainById(domainId, 
storagePoolId));
     }
 
     protected boolean isValidSpaceRequirements() {
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/lsm/LiveMigrateVmDisksCommandTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/lsm/LiveMigrateVmDisksCommandTest.java
index f685f64..ef13322 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/lsm/LiveMigrateVmDisksCommandTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/lsm/LiveMigrateVmDisksCommandTest.java
@@ -34,6 +34,7 @@
 import org.ovirt.engine.core.common.businessentities.StorageDomainStatus;
 import org.ovirt.engine.core.common.businessentities.StorageDomainType;
 import org.ovirt.engine.core.common.businessentities.StoragePool;
+import org.ovirt.engine.core.common.businessentities.StorageType;
 import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.businessentities.VMStatus;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
@@ -187,6 +188,27 @@
     }
 
     @Test
+    public void 
canDoActionInvalidDestinationAndSourceDomainOfDifferentStorageSubtypes() {
+        createParameters();
+
+        StorageDomain srcStorageDomain = initStorageDomain(srcStorageId);
+        srcStorageDomain.setStatus(StorageDomainStatus.Active);
+        srcStorageDomain.setStorageType(StorageType.ISCSI);
+
+        StorageDomain dstStorageDomain = initStorageDomain(dstStorageId);
+        dstStorageDomain.setStatus(StorageDomainStatus.Active);
+        srcStorageDomain.setStorageType(StorageType.NFS);
+
+        initDiskImage(diskImageGroupId, diskImageId);
+        initVm(VMStatus.Up, Guid.newGuid(), diskImageGroupId);
+
+        assertFalse(command.canDoAction());
+        assertTrue(command.getReturnValue()
+                .getCanDoActionMessages()
+                
.contains(VdcBllMessages.ACTION_TYPE_FAILED_DESTINATION_AND_SOURCE_STORAGE_SUB_TYPES_DIFFERENT.toString()));
+    }
+
+    @Test
     public void canDoActionVmRunningStateless() {
         createParameters();
         initDiskImage(diskImageGroupId, diskImageId);
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StorageType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StorageType.java
index bbca547..549d375 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StorageType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StorageType.java
@@ -36,6 +36,10 @@
         return this.value;
     }
 
+    public Subtype getStorageSubtype() {
+        return subtype;
+    }
+
     public boolean isConcreteStorageType() {
         return subtype != Subtype.NONE;
     }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
index 8d5cbc4..467517b 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
@@ -624,6 +624,7 @@
     ACTION_TYPE_FAILED_DISK_IS_USED_FOR_CREATE_VM(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_DISK_IS_BEING_REMOVED(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_DISK_IS_BEING_MIGRATED(ErrorType.CONFLICT),
+    
ACTION_TYPE_FAILED_DESTINATION_AND_SOURCE_STORAGE_SUB_TYPES_DIFFERENT(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_TEMPLATE_IS_BEING_EXPORTED(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_VM_IS_BEING_MIGRATED(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_VM_IS_BEING_IMPORTED(ErrorType.CONFLICT),
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 4d0f17d..b011ff4 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -637,6 +637,7 @@
 ACTION_TYPE_FAILED_DISK_IS_USED_FOR_CREATE_VM=Cannot ${action} ${type}. This 
disk is currently in use to create VM ${VmName}.
 ACTION_TYPE_FAILED_DISK_IS_BEING_REMOVED=Cannot ${action} ${type}. Disk 
${DiskName} is being removed.
 ACTION_TYPE_FAILED_DISK_IS_BEING_MIGRATED=Cannot ${action} ${type}. Disk 
${DiskName} is being moved or copied.
+ACTION_TYPE_FAILED_DESTINATION_AND_SOURCE_STORAGE_SUB_TYPES_DIFFERENT=Cannot 
${action} ${type}. Source and target domains must both be either file domains 
or block domains.
 ACTION_TYPE_FAILED_TEMPLATE_IS_BEING_EXPORTED=Cannot ${action} ${type}. 
Template ${TemplateName} is being exported.
 ACTION_TYPE_FAILED_VM_IS_BEING_IMPORTED=Cannot ${action} ${type}. VM ${VmName} 
is being imported.
 ACTION_TYPE_FAILED_VM_IS_BEING_MIGRATED=Cannot ${action} ${type}. VM ${VmName} 
is being migrated.
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
index e9e9d61..8ed708b 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
@@ -1738,6 +1738,9 @@
     @DefaultStringValue("Cannot ${action} ${type}. Disk ${DiskName} is being 
moved or copied.")
     String ACTION_TYPE_FAILED_DISK_IS_BEING_MIGRATED();
 
+    @DefaultStringValue("Cannot ${action} ${type}. Source and target domains 
must both be either file domains or block domains.")
+    String 
ACTION_TYPE_FAILED_DESTINATION_AND_SOURCE_STORAGE_SUB_TYPES_DIFFERENT();
+
     @DefaultStringValue("Cannot ${action} ${type}. Template ${TemplateName} is 
being exported.")
     String ACTION_TYPE_FAILED_TEMPLATE_IS_BEING_EXPORTED();
 
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 da46dfc..b59c370 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
@@ -617,6 +617,7 @@
 ACTION_TYPE_FAILED_DISK_IS_USED_FOR_CREATE_VM=Cannot ${action} ${type}. This 
disk is currently in use to create VM ${VmName}.
 ACTION_TYPE_FAILED_DISK_IS_BEING_REMOVED=Cannot ${action} ${type}. Disk 
${DiskName} is being removed.
 ACTION_TYPE_FAILED_DISK_IS_BEING_MIGRATED=Cannot ${action} ${type}. Disk 
${DiskName} is being moved or copied.
+ACTION_TYPE_FAILED_DESTINATION_AND_SOURCE_STORAGE_SUB_TYPES_DIFFERENT=Cannot 
${action} ${type}. Source and target domains must both be either file domains 
or block domains.
 ACTION_TYPE_FAILED_TEMPLATE_IS_BEING_EXPORTED=Cannot ${action} ${type}. 
Template ${TemplateName} is being exported.
 ACTION_TYPE_FAILED_VM_IS_BEING_IMPORTED=Cannot ${action} ${type}. VM ${VmName} 
is being imported.
 ACTION_TYPE_FAILED_VM_IS_BEING_MIGRATED=Cannot ${action} ${type}. VM ${VmName} 
is being migrated.
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 58e6e06..467594a 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
@@ -638,6 +638,7 @@
 ACTION_TYPE_FAILED_DISK_IS_USED_FOR_CREATE_VM=Cannot ${action} ${type}. This 
disk is currently in use to create VM ${VmName}.
 ACTION_TYPE_FAILED_DISK_IS_BEING_REMOVED=Cannot ${action} ${type}. Disk 
${DiskName} is being removed.
 ACTION_TYPE_FAILED_DISK_IS_BEING_MIGRATED=Cannot ${action} ${type}. Disk 
${DiskName} is being moved or copied.
+ACTION_TYPE_FAILED_DESTINATION_AND_SOURCE_STORAGE_SUB_TYPES_DIFFERENT=Cannot 
${action} ${type}. Source and target domains must both be either file domains 
or block domains.
 ACTION_TYPE_FAILED_TEMPLATE_IS_BEING_EXPORTED=Cannot ${action} ${type}. 
Template ${TemplateName} is being exported.
 ACTION_TYPE_FAILED_VM_IS_BEING_IMPORTED=Cannot ${action} ${type}. VM ${VmName} 
is being imported.
 ACTION_TYPE_FAILED_VM_IS_BEING_MIGRATED=Cannot ${action} ${type}. VM ${VmName} 
is being migrated.


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iec4c34132a1a619527627cfa47fa99df3a023b62
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Tal Nisan <tni...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to