mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-8119. Propagate error message to UI for attach/detach volume failure operations.
For AttachVolume/DetachVolume API command, improve user error message in case of RuntimeException by throwing the exception instead of 'Unexpected Exception'.
This commit is contained in:
parent
67eff27f54
commit
4d7ede535d
|
|
@ -1367,7 +1367,11 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||
hostService.invalidateServiceContext(null);
|
||||
}
|
||||
|
||||
String msg = "AttachVolumeCommand failed due to " + VmwareHelper.getExceptionMessage(e);
|
||||
String msg = "";
|
||||
if (isAttach)
|
||||
msg += "Failed to attach volume: " + e.getMessage();
|
||||
else
|
||||
msg += "Failed to detach volume: " + e.getMessage();
|
||||
s_logger.error(msg, e);
|
||||
return new AttachAnswer(msg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1378,6 +1378,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
throw (ConcurrentOperationException)jobResult;
|
||||
else if (jobResult instanceof InvalidParameterValueException)
|
||||
throw (InvalidParameterValueException)jobResult;
|
||||
else if (jobResult instanceof RuntimeException)
|
||||
throw (RuntimeException)jobResult;
|
||||
else if (jobResult instanceof Throwable)
|
||||
throw new RuntimeException("Unexpected exception", (Throwable)jobResult);
|
||||
else if (jobResult instanceof Long) {
|
||||
|
|
@ -1580,6 +1582,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
if (jobResult != null) {
|
||||
if (jobResult instanceof ConcurrentOperationException)
|
||||
throw (ConcurrentOperationException)jobResult;
|
||||
else if (jobResult instanceof RuntimeException)
|
||||
throw (RuntimeException)jobResult;
|
||||
else if (jobResult instanceof Throwable)
|
||||
throw new RuntimeException("Unexpected exception", (Throwable)jobResult);
|
||||
else if (jobResult instanceof Long) {
|
||||
|
|
|
|||
|
|
@ -1126,6 +1126,14 @@ public class VirtualMachineMO extends BaseMO {
|
|||
throw new Exception("No such disk device: " + vmdkDatastorePath);
|
||||
}
|
||||
|
||||
// IDE virtual disk cannot be detached if VM is running
|
||||
if (deviceInfo.second() != null && deviceInfo.second().contains("ide")) {
|
||||
if (getPowerState() == VirtualMachinePowerState.POWERED_ON) {
|
||||
throw new Exception("Removing a virtual disk over IDE controller is not supported while VM is running in VMware hypervisor. " +
|
||||
"Please re-try when VM is not running.");
|
||||
}
|
||||
}
|
||||
|
||||
List<Pair<String, ManagedObjectReference>> chain = getDiskDatastorePathChain(deviceInfo.first(), true);
|
||||
|
||||
VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
|
||||
|
|
|
|||
Loading…
Reference in New Issue