Perform basic verification on the passed-in IOPS values

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ab601866
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ab601866
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ab601866

Branch: refs/heads/sf-plugins
Commit: ab6018665911a6c744baf43629ff79fdbc3e441b
Parents: 6bee875
Author: Mike Tutkowski <[email protected]>
Authored: Sun Jul 12 22:35:33 2015 -0600
Committer: Mike Tutkowski <[email protected]>
Committed: Fri Sep 18 19:28:20 2015 -0600

----------------------------------------------------------------------
 .../solidfire/ApiSolidFireServiceImpl2.java       | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ab601866/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl2.java
----------------------------------------------------------------------
diff --git 
a/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl2.java
 
b/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl2.java
index d91febc..7c585a8 100644
--- 
a/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl2.java
+++ 
b/plugins/api/solidfire/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl2.java
@@ -639,6 +639,8 @@ public class ApiSolidFireServiceImpl2 extends AdapterBase 
implements APIChecker,
     }
 
     private SfVolume createVolume(String name, long size, long minIops, long 
maxIops, long burstIops, long accountId, long sfVirtualNetworkId) {
+        verifyIops(minIops, maxIops, burstIops);
+
         Account account = _accountDao.findById(accountId);
 
         SfVirtualNetwork sfVirtualNetwork = 
getSfVirtualNetwork(sfVirtualNetworkId);
@@ -740,6 +742,8 @@ public class ApiSolidFireServiceImpl2 extends AdapterBase 
implements APIChecker,
     }
 
     private SfVolumeVO updateVolume(SfVolumeVO sfVolumeVO, long size, long 
minIops, long maxIops, long burstIops) {
+        verifyIops(minIops, maxIops, burstIops);
+
         SfVirtualNetwork sfVirtualNetwork = 
getSfVirtualNetwork(sfVolumeVO.getSfVirtualNetworkId());
 
         Account account = 
_accountDao.findById(sfVirtualNetwork.getAccountId());
@@ -989,4 +993,18 @@ public class ApiSolidFireServiceImpl2 extends AdapterBase 
implements APIChecker,
 
         return sfVirtualNetworkVOsToReturn;
     }
+
+    private static void verifyIops(long minIops, long maxIops, long burstIops) 
{
+        if (minIops <= 0 || maxIops <= 0 || burstIops <= 0) {
+            throw new IllegalArgumentException("The 'Min IOPS', 'Max IOPS', 
and 'Burst IOPS' values must be greater than 0.");
+        }
+
+        if (minIops > maxIops) {
+            throw new IllegalArgumentException("The 'Min IOPS' value cannot 
exceed the 'Max IOPS' value.");
+        }
+
+        if (maxIops > burstIops) {
+            throw new IllegalArgumentException("The 'Max IOPS' value cannot 
exceed the 'Burst IOPS' value.");
+        }
+    }
 }

Reply via email to