Maor Lipchuk has uploaded a new change for review.

Change subject: core: Update Cinder maximum volume validation.
......................................................................

core: Update Cinder maximum volume validation.

Change disks validator to use the new private class to validate
if the maximum number of disks in Cinder exceeded.

Change-Id: If8c3901db7eaf4c9361571fc14ac4b11218a9ff4
Bug-Url: https://bugzilla.redhat.com/1185826
Signed-off-by: Maor Lipchuk <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/storage/CinderDisksValidator.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
5 files changed, 16 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/34/41134/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/storage/CinderDisksValidator.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/storage/CinderDisksValidator.java
index b511ef5..05ba5f3 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/storage/CinderDisksValidator.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/storage/CinderDisksValidator.java
@@ -56,16 +56,21 @@
         return validate(new Callable<ValidationResult>() {
             @Override
             public ValidationResult call() {
-                int diskIndex = 0;
-                for (CinderDisk disk : cinderDisks) {
-                    OpenStackVolumeProviderProxy proxy = 
diskProxyMap.get(disk.getId());
-                    Limits limits = proxy.getLimits();
-                    if (limits.getAbsolute().getTotalVolumesUsed() + diskIndex 
>= limits.getAbsolute().getMaxTotalVolumes()) {
+                Map<Guid, CinderStorageRelatedDisksAndProxy> 
relatedCinderDisksByStorageMap =
+                        getRelatedCinderDisksToStorageDomainMap();
+                Collection<CinderStorageRelatedDisksAndProxy> 
relatedCinderDisksByStorageCollection =
+                        relatedCinderDisksByStorageMap.values();
+                for (CinderStorageRelatedDisksAndProxy 
relatedCinderDisksByStorage : relatedCinderDisksByStorageCollection) {
+                    Limits limits = 
relatedCinderDisksByStorage.getProxy().getLimits();
+                    int numOfDisks = 
relatedCinderDisksByStorage.getCinderDisks().size();
+                    if (isLimitExceeded(limits, CinderVolumeType.Volume, 
numOfDisks)) {
+                        String storageName =
+                                
getStorageDomainDao().get(relatedCinderDisksByStorage.getStorageDomainId())
+                                        .getStorageName();
                         return new 
ValidationResult(VdcBllMessages.CANNOT_ADD_CINDER_DISK_VOLUME_LIMIT_EXCEEDED,
                                 String.format("$maxTotalVolumes %d", 
limits.getAbsolute().getMaxTotalVolumes()),
-                                String.format("$diskAlias %s", 
disk.getDiskAlias()));
+                                String.format("$storageName %s", storageName));
                     }
-                    diskIndex++;
                 }
                 return ValidationResult.VALID;
             }
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 55c553b..ba1fb72 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -1417,7 +1417,7 @@
 # Cinder
 ACTION_TYPE_FAILED_PROVIDER_NOT_SUPPORTED=Cannot ${action} ${type}. The 
current type ${providerType} is not supported.
 ACTION_TYPE_FAILED_CINDER=Cannot ${action} ${type}. An error occurred on 
Cinder - '${cinderException}'.
-CANNOT_ADD_CINDER_DISK_VOLUME_LIMIT_EXCEEDED=Cannot ${action} ${type}. Maximum 
number of volumes allowed (${maxTotalVolumes}) exceeded - could not create 
Cinder disk ${diskAlias}.
+CANNOT_ADD_CINDER_DISK_VOLUME_LIMIT_EXCEEDED=Cannot ${action} ${type}. Maximum 
number of volumes allowed (${maxTotalVolumes}) exceeded - could not create 
Cinder disks on Storage Domain ${storageName}.
 CANNOT_ADD_CINDER_DISK_SNAPSHOT_LIMIT_EXCEEDED=Cannot ${action} ${type}. 
Maximum number of snapshots allowed (${maxTotalSnapshots}) exceeded - could not 
create Cinder disk snapshot on Storage ${storageName}.
 CINDER_DISK_ALREADY_REGISTERED=Cannot ${action} ${type}. Cinder disk is 
already registered (${diskAlias}).
 ERROR_CANNOT_DETACH_CINDER_PROVIDER_WITH_IMAGES=Cannot detach a non empty 
Cinder provider.\n\
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 ee737c5..8456596 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
@@ -3791,7 +3791,7 @@
     @DefaultStringValue("Cannot ${action} ${type}. An error occurred on Cinder 
- '${cinderException}'")
     String ACTION_TYPE_FAILED_CINDER();
 
-    @DefaultStringValue("Cannot ${action} ${type}. Maximum number of volumes 
allowed (${maxTotalVolumes}) exceeded - could not create Cinder disk 
${diskAlias}.")
+    @DefaultStringValue("Cannot ${action} ${type}. Maximum number of volumes 
allowed (${maxTotalVolumes}) exceeded - could not create Cinder disks on 
Storage Domain ${storageName}.")
     String CANNOT_ADD_CINDER_DISK_VOLUME_LIMIT_EXCEEDED();
 
     @DefaultStringValue("Cannot ${action} ${type}. Maximum number of snapshots 
allowed (${maxTotalSnapshots}) exceeded - could not create Cinder disk snapshot 
on Storage ${storageName}.")
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 f767384..0feac23 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
@@ -1096,7 +1096,7 @@
 # Cinder
 ACTION_TYPE_FAILED_PROVIDER_NOT_SUPPORTED=Cannot ${action} ${type}. The 
current type ${providerType} is not supported.
 ACTION_TYPE_FAILED_CINDER=Cannot ${action} ${type}. An error occurred on 
Cinder - '${cinderException}'.
-CANNOT_ADD_CINDER_DISK_VOLUME_LIMIT_EXCEEDED=Cannot ${action} ${type}. Maximum 
number of volumes allowed (${maxTotalVolumes}) exceeded - could not create 
Cinder disk ${diskAlias}.
+CANNOT_ADD_CINDER_DISK_VOLUME_LIMIT_EXCEEDED=Cannot ${action} ${type}. Maximum 
number of volumes allowed (${maxTotalVolumes}) exceeded - could not create 
Cinder disks on Storage Domain ${storageName}.
 CANNOT_ADD_CINDER_DISK_SNAPSHOT_LIMIT_EXCEEDED=Cannot ${action} ${type}. 
Maximum number of snapshots allowed (${maxTotalSnapshots}) exceeded - could not 
create Cinder disk snapshot on Storage ${storageName}.
 CINDER_DISK_ALREADY_REGISTERED=Cannot ${action} ${type}. Cinder disk is 
already registered (${diskAlias}).
 
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 d6a1de5..e8a760e 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
@@ -1362,7 +1362,7 @@
 # Cinder
 ACTION_TYPE_FAILED_PROVIDER_NOT_SUPPORTED=Cannot ${action} ${type}. The 
current type ${providerType} is not supported.
 ACTION_TYPE_FAILED_CINDER=Cannot ${action} ${type}. An error occurred on 
Cinder - '${cinderException}'.
-CANNOT_ADD_CINDER_DISK_VOLUME_LIMIT_EXCEEDED=Cannot ${action} ${type}. Maximum 
number of volumes allowed (${maxTotalVolumes}) exceeded - could not create 
Cinder disk ${diskAlias}.
+CANNOT_ADD_CINDER_DISK_VOLUME_LIMIT_EXCEEDED=Cannot ${action} ${type}. Maximum 
number of volumes allowed (${maxTotalVolumes}) exceeded - could not create 
Cinder disks on Storage Domain ${storageName}.
 CANNOT_ADD_CINDER_DISK_SNAPSHOT_LIMIT_EXCEEDED=Cannot ${action} ${type}. 
Maximum number of snapshots allowed (${maxTotalSnapshots}) exceeded - could not 
create Cinder disk snapshot on Storage ${storageName}.
 CINDER_DISK_ALREADY_REGISTERED=Cannot ${action} ${type}. Cinder disk is 
already registered (${diskAlias}).
 ERROR_CANNOT_DETACH_CINDER_PROVIDER_WITH_IMAGES=Cannot detach a non empty 
Cinder provider.\n\


-- 
To view, visit https://gerrit.ovirt.org/41134
To unsubscribe, visit https://gerrit.ovirt.org/settings

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

Reply via email to