You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by wi...@apache.org on 2014/09/28 11:40:38 UTC

[38/50] [abbrv] git commit: updated refs/heads/statscollector-graphite to 621156c

CLOUDSTACK-7495. Volume resize is only supported on kvm, vmware and xenserver. If
the operation is tried on other hypervisors it fails but logs a stack trace. We
should just log a message that the operation isn't supported.


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

Branch: refs/heads/statscollector-graphite
Commit: ec1123aca18009ac91e571e150fcf4c98df5e482
Parents: d19a78d
Author: Devdeep Singh <de...@gmail.com>
Authored: Fri Sep 26 13:13:24 2014 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Fri Sep 26 13:15:31 2014 +0530

----------------------------------------------------------------------
 .../command/admin/volume/ResizeVolumeCmdByAdmin.java    | 12 ++++++++++--
 .../api/command/user/volume/ResizeVolumeCmd.java        | 11 +++++++++--
 server/src/com/cloud/storage/VolumeApiServiceImpl.java  |  2 +-
 3 files changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ec1123ac/api/src/org/apache/cloudstack/api/command/admin/volume/ResizeVolumeCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/ResizeVolumeCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/ResizeVolumeCmdByAdmin.java
index d1d253c..542fff5 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/volume/ResizeVolumeCmdByAdmin.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/volume/ResizeVolumeCmdByAdmin.java
@@ -24,6 +24,7 @@ import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
 import org.apache.cloudstack.api.response.VolumeResponse;
 import org.apache.cloudstack.context.CallContext;
 
+import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.storage.Volume;
 
@@ -33,8 +34,15 @@ public class ResizeVolumeCmdByAdmin extends ResizeVolumeCmd {
 
     @Override
     public void execute() throws ResourceAllocationException{
-        CallContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G");
-        Volume volume = _volumeService.resizeVolume(this);
+        Volume volume = null;
+        try {
+            CallContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G");
+            volume = _volumeService.resizeVolume(this);
+        } catch (InvalidParameterValueException ex) {
+            s_logger.info(ex.getMessage());
+            throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, ex.getMessage());
+        }
+
         if (volume != null) {
             VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, volume);
             //FIXME - have to be moved to ApiResponseHelper

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ec1123ac/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
index 49fd6ca..4ec9449 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
@@ -160,8 +160,15 @@ public class ResizeVolumeCmd extends BaseAsyncCmd {
 
     @Override
     public void execute() throws ResourceAllocationException {
-        CallContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G");
-        Volume volume = _volumeService.resizeVolume(this);
+        Volume volume = null;
+        try {
+            CallContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G");
+            volume = _volumeService.resizeVolume(this);
+        } catch (InvalidParameterValueException ex) {
+            s_logger.info(ex.getMessage());
+            throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, ex.getMessage());
+        }
+
         if (volume != null) {
             VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, volume);
             //FIXME - have to be moved to ApiResponseHelper

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ec1123ac/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index 8ccede7..d89ea4f 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -720,7 +720,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
         if (hypervisorType != HypervisorType.KVM && hypervisorType != HypervisorType.XenServer &&
                 hypervisorType != HypervisorType.VMware && hypervisorType != HypervisorType.Any && hypervisorType != HypervisorType.None) {
-            throw new InvalidParameterValueException("CloudStack currently only supports volumes marked as the KVM, VMware, or XenServer hypervisor type for resize.");
+            throw new InvalidParameterValueException("CloudStack currently supports volume resize only on KVM, VMware, or XenServer.");
         }
 
         if (volume.getState() != Volume.State.Ready && volume.getState() != Volume.State.Allocated) {