DaanHoogland commented on a change in pull request #3532: Add new "Add volume" button, to add volume to VM instance directly URL: https://github.com/apache/cloudstack/pull/3532#discussion_r312402426
########## File path: server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java ########## @@ -1662,7 +1629,45 @@ public Volume attachVolumeToVM(Long vmId, Long volumeId, Long deviceId) { return vol; } } + + public Volume verifyVmAndAttachVolume(Long vmId, VolumeVO volume){ + Account caller = CallContext.current().getCallingAccount(); + Volume vol = null; + if (vmId != null) { + // Check that the virtual machine ID is valid and it's a user vm + UserVmVO vm = _userVmDao.findById(vmId); + if (vm == null || vm.getType() != VirtualMachine.Type.User) { + throw new InvalidParameterValueException("Please specify a valid User VM."); + } + + // Check that the VM is in the correct state Review comment: checkVmIsInCorrectState() ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services