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.
This commit is contained in:
Devdeep Singh 2014-09-26 13:13:24 +05:30
parent d19a78ddf7
commit ec1123aca1
3 changed files with 20 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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) {