Tal Nisan has uploaded a new change for review.

Change subject: core: Check if data center version supports import data domain 
upon attach
......................................................................

core: Check if data center version supports import data domain upon attach

When we are selecting a data center that does not support import of data
domains, make those options unselectable

Change-Id: I05b6a8fe737691655dedbfbbb8d1f0ee4a592668
Bug-Url: https://bugzilla.redhat.com/1176436
Signed-off-by: Tal Nisan <tni...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AttachStorageDomainToPoolCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
3 files changed, 44 insertions(+), 37 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/63/36363/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AttachStorageDomainToPoolCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AttachStorageDomainToPoolCommand.java
index d12a4fe..06d55f6 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AttachStorageDomainToPoolCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AttachStorageDomainToPoolCommand.java
@@ -227,49 +227,54 @@
     }
 
     protected List<OvfEntityData> getEntitiesFromStorageOvfDisk() {
-        // Initialize a new ArrayList with all the ovfDisks in the specified 
Storage Domain,
-        // so the entities can be removed from the list every time we register 
the latest OVF disk and we can keep the
-        // ovfDisks cache list updated.
-        List<DiskImage> ovfStoreDiskImages = new ArrayList(getAllOVFDisks());
-        if (!ovfStoreDiskImages.isEmpty()) {
-            while (!ovfStoreDiskImages.isEmpty()) {
-                Pair<DiskImage, Long> ovfDiskAndSize = 
getLatestOVFDisk(ovfStoreDiskImages);
-                DiskImage ovfDisk = ovfDiskAndSize.getFirst();
-                if (ovfDisk != null) {
-                    try {
-                        VdcReturnValueBase vdcReturnValue = 
runInternalAction(VdcActionType.RetrieveImageData,
-                                new 
RetrieveImageDataParameters(getParameters().getStoragePoolId(),
-                                        getParameters().getStorageDomainId(),
-                                        ovfDisk.getId(),
-                                        ovfDisk.getImage().getId(),
-                                        ovfDiskAndSize.getSecond()), 
cloneContextAndDetachFromParent());
+        if 
(FeatureSupported.importDataStorageDomain(getStoragePool().getcompatibility_version()))
 {
+            // Initialize a new ArrayList with all the ovfDisks in the 
specified Storage Domain,
+            // so the entities can be removed from the list every time we 
register the latest OVF disk and we can keep the
+            // ovfDisks cache list updated.
+            List<DiskImage> ovfStoreDiskImages = new 
ArrayList(getAllOVFDisks());
+            if (!ovfStoreDiskImages.isEmpty()) {
+                while (!ovfStoreDiskImages.isEmpty()) {
+                    Pair<DiskImage, Long> ovfDiskAndSize = 
getLatestOVFDisk(ovfStoreDiskImages);
+                    DiskImage ovfDisk = ovfDiskAndSize.getFirst();
+                    if (ovfDisk != null) {
+                        try {
+                            VdcReturnValueBase vdcReturnValue = 
runInternalAction(VdcActionType.RetrieveImageData,
+                                    new 
RetrieveImageDataParameters(getParameters().getStoragePoolId(),
+                                            
getParameters().getStorageDomainId(),
+                                            ovfDisk.getId(),
+                                            ovfDisk.getImage().getId(),
+                                            ovfDiskAndSize.getSecond()), 
cloneContextAndDetachFromParent());
 
-                        
getReturnValue().getVdsmTaskIdList().addAll(vdcReturnValue.getInternalVdsmTaskIdList());
-                        if (vdcReturnValue.getSucceeded()) {
-                            return OvfUtils.getOvfEntities((byte[]) 
vdcReturnValue.getActionReturnValue(),
-                                    getParameters().getStorageDomainId());
-                        } else {
-                            log.error("Image data could not be retrieved for 
disk id '{}' in storage domain id '{}'",
+                            
getReturnValue().getVdsmTaskIdList().addAll(vdcReturnValue.getInternalVdsmTaskIdList());
+                            if (vdcReturnValue.getSucceeded()) {
+                                return OvfUtils.getOvfEntities((byte[]) 
vdcReturnValue.getActionReturnValue(),
+                                        getParameters().getStorageDomainId());
+                            } else {
+                                log.error("Image data could not be retrieved 
for disk id '{}' in storage domain id '{}'",
+                                        ovfDisk.getId(),
+                                        getParameters().getStorageDomainId());
+                            }
+                        } catch (RuntimeException e) {
+                            // We are catching RuntimeException, since the 
call for OvfUtils.getOvfEntities will throw
+                            // a RuntimeException if there is a problem to 
untar the file.
+                            log.error("Image data could not be retrieved for 
disk id '{}' in storage domain id '{}': {}",
                                     ovfDisk.getId(),
-                                    getParameters().getStorageDomainId());
+                                    getParameters().getStorageDomainId(),
+                                    e.getMessage());
+                            log.debug("Exception", e);
                         }
-                    } catch (RuntimeException e) {
-                        // We are catching RuntimeException, since the call 
for OvfUtils.getOvfEntities will throw
-                        // a RuntimeException if there is a problem to untar 
the file.
-                        log.error("Image data could not be retrieved for disk 
id '{}' in storage domain id '{}': {}",
-                                ovfDisk.getId(),
-                                getParameters().getStorageDomainId(),
-                                e.getMessage());
-                        log.debug("Exception", e);
+                        ovfStoreDiskImages.remove(ovfDisk);
                     }
-                    ovfStoreDiskImages.remove(ovfDisk);
                 }
+                AuditLogDirector.log(this, 
AuditLogType.RETRIEVE_OVF_STORE_FAILED);
+            } else {
+                log.warn("There are no OVF_STORE disks on storage domain id 
{}",
+                        getParameters().getStorageDomainId());
+                AuditLogDirector.log(this, 
AuditLogType.OVF_STORE_DOES_NOT_EXISTS);
             }
-            AuditLogDirector.log(this, AuditLogType.RETRIEVE_OVF_STORE_FAILED);
-        } else {
-            log.warn("There are no OVF_STORE disks on storage domain id {}",
-                    getParameters().getStorageDomainId());
-            AuditLogDirector.log(this, AuditLogType.OVF_STORE_DOES_NOT_EXISTS);
+        }
+        else {
+            AuditLogDirector.log(this, 
AuditLogType.RETRIEVE_UNREGISTERED_ENTITIES_NOT_SUPPORTED_IN_DC_VERSION);
         }
         return Collections.emptyList();
     }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
index 4f16336..62f0ecf 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
@@ -862,6 +862,7 @@
     UPDATE_FOR_OVF_STORES_FAILED(1016, AuditLogSeverity.WARNING),
     RETRIEVE_OVF_STORE_FAILED(1017, AuditLogSeverity.WARNING),
     OVF_STORE_DOES_NOT_EXISTS(1018, AuditLogSeverity.WARNING),
+    RETRIEVE_UNREGISTERED_ENTITIES_NOT_SUPPORTED_IN_DC_VERSION(1019, 
AuditLogSeverity.WARNING),
 
     // Authentication
     USER_ACCOUNT_DISABLED_OR_LOCKED(160, AuditLogSeverity.ERROR,
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
index d7ef8a6..164e3f3 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -658,6 +658,7 @@
 UPDATE_OVF_FOR_STORAGE_POOL_FAILED=Failed to update VMs/Templates OVF data in 
Data Center ${StoragePoolName}.
 RETRIEVE_OVF_STORE_FAILED=Failed to retrieve VMs and Templates from the OVF 
disk of Storage Domain ${StorageDomainName}.
 OVF_STORE_DOES_NOT_EXISTS=The Storage Domain does not contain any OVF_STORE 
disks. Usually the Storage Domain does not contain OVF_STORE disks when the 
Storage Domain has been previously managed with a Data Center version lower 
then 3.5.
+RETRIEVE_UNREGISTERED_ENTITIES_NOT_SUPPORTED_IN_DC_VERSION=Skipping retrieval 
attempt of VMs and Templates from the OVF disk of Storage Domain 
${StorageDomainName} since it is not supported by the Data Center version.
 UPDATE_OVF_FOR_STORAGE_DOMAIN_FAILED=Failed to update VMs/Templates OVF data 
for Storage Domain ${StorageDomainName} in Data Center ${StoragePoolName}.
 CREATE_OVF_STORE_FOR_STORAGE_DOMAIN_FAILED=Failed to create OVF store disk for 
Storage Domain ${StorageDomainName}.\n The Disk with the id ${DiskId} might be 
removed manually for automatic attempt to create new one. \n OVF updates won't 
be attempted on the created disk.
 CREATE_OVF_STORE_FOR_STORAGE_DOMAIN_INITIATE_FAILED=Failed to create OVF store 
disk for Storage Domain ${StorageDomainName}. \n OVF data won't be updated 
meanwhile for that domain.


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I05b6a8fe737691655dedbfbbb8d1f0ee4a592668
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
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