public EC2Volume attachVolume( EC2Volume request ) {
try {
request.setDeviceId(mapDeviceToCloudDeviceId(request.getDevice()));
EC2Volume resp = new EC2Volume();
CloudStackVolume vol = getApi().attachVolume(request.getId(), request.getInstanceId(), request.getDeviceId());
if(vol != null) {
resp.setAttached(vol.getAttached());
resp.setCreated(vol.getCreated());
resp.setDevice(request.getDevice());
resp.setDeviceId(vol.getDeviceId());
resp.setHypervisor(vol.getHypervisor());
resp.setId(vol.getId());
resp.setInstanceId(vol.getVirtualMachineId());
resp.setSize(vol.getSize());
resp.setSnapshotId(vol.getSnapshotId());
resp.setState(vol.getState());
resp.setType(vol.getVolumeType());
resp.setVMState(vol.getVirtualMachineState());
resp.setAttachmentState(mapToAmazonVolumeAttachmentState(vol.getVirtualMachineState()));
resp.setZoneName(vol.getZoneName());
return resp;
}
throw new EC2ServiceException( ServerError.InternalError, "An unexpected error occurred." );
} catch( Exception e ) {
logger.error( "EC2 AttachVolume 2 - ", e);