Updated Branches:
  refs/heads/master ca1358633 -> 2aafc39f3

CLOUDSTACK-2957
deployVm API size attribute should be capped by the storage.max.volume.size as 
it is in createVolume.


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

Branch: refs/heads/master
Commit: 2aafc39f3d0570fac1ddcebf4623f1c37e8e47e5
Parents: ca13586
Author: Nitin Mehta <nitin.me...@citrix.com>
Authored: Wed Jun 12 16:57:59 2013 +0530
Committer: Nitin Mehta <nitin.me...@citrix.com>
Committed: Wed Jun 12 17:01:41 2013 +0530

----------------------------------------------------------------------
 .../cloudstack/platform/orchestration/CloudOrchestrator.java | 8 +++++++-
 server/src/com/cloud/storage/VolumeManager.java              | 2 ++
 server/src/com/cloud/storage/VolumeManagerImpl.java          | 3 ++-
 3 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2aafc39f/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
----------------------------------------------------------------------
diff --git 
a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
 
b/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
index ca299ea..96fb1d9 100755
--- 
a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
+++ 
b/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
@@ -25,6 +25,7 @@ import java.util.Map;
 
 import javax.inject.Inject;
 
+import com.cloud.storage.VolumeManager;
 import org.apache.cloudstack.engine.cloud.entity.api.NetworkEntity;
 import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
 import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity;
@@ -87,6 +88,9 @@ public class CloudOrchestrator implements 
OrchestrationService {
        @Inject
        protected AccountDao _accountDao = null;
 
+    @Inject
+    VolumeManager _volumeMgr;
+
        public CloudOrchestrator() {
        }
 
@@ -200,6 +204,7 @@ public class CloudOrchestrator implements 
OrchestrationService {
                                                "Disk offering " + diskOffering
                                                                + " requires 
size parameter.");
                        }
+                _volumeMgr.validateVolumeSizeRange(size * 1024 * 1024 * 1024);
                }
                dataDiskOfferings.add(new Pair<DiskOfferingVO, 
Long>(diskOffering, size));
                }
@@ -246,7 +251,8 @@ public class CloudOrchestrator implements 
OrchestrationService {
                                throw new InvalidParameterValueException("Disk 
offering "
                                                + diskOffering + " requires 
size parameter.");
                        }
-               }
+            _volumeMgr.validateVolumeSizeRange(size * 1024 * 1024 * 1024);
+        }
                rootDiskOffering.first(diskOffering);
                rootDiskOffering.second(size);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2aafc39f/server/src/com/cloud/storage/VolumeManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManager.java 
b/server/src/com/cloud/storage/VolumeManager.java
index 47fbda8..56de408 100644
--- a/server/src/com/cloud/storage/VolumeManager.java
+++ b/server/src/com/cloud/storage/VolumeManager.java
@@ -109,4 +109,6 @@ public interface VolumeManager extends VolumeApiService {
     String getVmNameFromVolumeId(long volumeId);
 
     String getStoragePoolOfVolume(long volumeId);
+
+    boolean validateVolumeSizeRange(long size);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2aafc39f/server/src/com/cloud/storage/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java 
b/server/src/com/cloud/storage/VolumeManagerImpl.java
index 43f3681..4297efb 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -1311,7 +1311,8 @@ public class VolumeManagerImpl extends ManagerBase 
implements VolumeManager {
         return true;
     }
 
-    private boolean validateVolumeSizeRange(long size) {
+    @Override
+    public boolean validateVolumeSizeRange(long size) {
         if (size < 0 || (size > 0 && size < (1024 * 1024 * 1024))) {
             throw new InvalidParameterValueException(
                     "Please specify a size of at least 1 Gb.");

Reply via email to