Daniel Erez has uploaded a new change for review.

Change subject: core: CinderDisksValidator - validateCinderDiskLimits
......................................................................

core: CinderDisksValidator - validateCinderDiskLimits

Validate Cinder disks limits on CinderDisksValidator
(needed fro AddCinderDisk canDo validations.

Change-Id: I532cbb800a54f9742d11c361789ba3bf693d01ad
Bug-Url: https://bugzilla.redhat.com/1185826
Signed-off-by: Daniel Erez <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/storage/OpenStackVolumeProviderProxy.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/storage/CinderDisksValidator.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
7 files changed, 33 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/23/39023/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/storage/OpenStackVolumeProviderProxy.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/storage/OpenStackVolumeProviderProxy.java
index 10b7801..c0ac4db 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/storage/OpenStackVolumeProviderProxy.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/storage/OpenStackVolumeProviderProxy.java
@@ -1,6 +1,7 @@
 package org.ovirt.engine.core.bll.provider.storage;
 
 import com.woorea.openstack.cinder.Cinder;
+import com.woorea.openstack.cinder.model.Limits;
 import com.woorea.openstack.cinder.model.Volume;
 import com.woorea.openstack.cinder.model.VolumeForCreate;
 import org.ovirt.engine.core.bll.provider.ProviderProxyFactory;
@@ -65,6 +66,10 @@
         return getClient(getTenantId()).volumes().show(id).execute();
     }
 
+    public Limits getLimits() {
+        return getClient(getTenantId()).limits().list().execute();
+    }
+
     @Override
     public void onRemoval() {
         List<StorageDomain> storageDomains = 
getDbFacade().getStorageDomainDao().getAllByConnectionId(provider.getId());
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 5491ced..3b873f4 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
@@ -1,6 +1,7 @@
 package org.ovirt.engine.core.bll.validator.storage;
 
 import com.woorea.openstack.base.client.OpenStackResponseException;
+import com.woorea.openstack.cinder.model.Limits;
 import org.ovirt.engine.core.bll.ValidationResult;
 import org.ovirt.engine.core.bll.provider.storage.OpenStackVolumeProviderProxy;
 import org.ovirt.engine.core.common.businessentities.storage.CinderDisk;
@@ -40,6 +41,24 @@
         }
     }
 
+    public ValidationResult validateCinderDiskLimits() {
+        return validate(new Callable<ValidationResult>() {
+            @Override
+            public ValidationResult call() {
+                for (CinderDisk disk : cinderDisks) {
+                    OpenStackVolumeProviderProxy proxy = 
diskProxyMap.get(disk.getId());
+                    Limits limits = proxy.getLimits();
+                    if (limits.getAbsolute().getTotalVolumesUsed() >= 
limits.getAbsolute().getMaxTotalVolumes()) {
+                        return new 
ValidationResult(VdcBllMessages.CANNOT_ADD_CINDER_DISK_VOLUME_LIMIT_EXCEEDED,
+                                String.format("$maxTotalVolumes %d", 
limits.getAbsolute().getMaxTotalVolumes()),
+                                String.format("$diskAlias %s", 
disk.getDiskAlias()));
+                    }
+                }
+                return ValidationResult.VALID;
+            }
+        });
+    }
+
     private Map<Guid, OpenStackVolumeProviderProxy> 
getVolumeProviderProxyMap() {
         if (diskProxyMap == null) {
             diskProxyMap = new HashMap<>();
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 a3c0d92..a9cf91c 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
@@ -1174,7 +1174,9 @@
     ACTION_TYPE_REMOVE_GRAPHICS_DEV_INVALID_PARAMS,
 
     // Cinder
-    ACTION_TYPE_FAILED_PROVIDER_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED);
+    ACTION_TYPE_FAILED_PROVIDER_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
+    ACTION_TYPE_FAILED_CINDER(ErrorType.INTERNAL_ERROR),
+    CANNOT_ADD_CINDER_DISK_VOLUME_LIMIT_EXCEEDED(ErrorType.CONFLICT);
 
     private ErrorType messageType;
 
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 858ea8e..e469678 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -1377,3 +1377,4 @@
 # 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}.
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 972bee1..32dffbd 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
@@ -3669,4 +3669,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}.")
+    String CANNOT_ADD_CINDER_DISK_VOLUME_LIMIT_EXCEEDED();
 }
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 a0cfcc9..736ab41 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
@@ -1093,3 +1093,4 @@
 # 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}.
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 ad4df61..a73a1c3 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
@@ -1330,3 +1330,4 @@
 # 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}.


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

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

Reply via email to