final Volume volume = createPreferredVolumeFromDisk();
try {
checkVolume(volume);
VirtualMachine virtualMachine = getPreferredVirtualMachine();
logger.info("attaching volume %s to vm %s", volume, virtualMachine);
AsyncCreateResponse job = client.getVolumeApi().attachVolume(volume.getId(), virtualMachine.getId());
assertTrue(jobComplete.apply(job.getJobId()));
Volume attachedVolume = findVolumeWithId(volume.getId());
checkVolume(attachedVolume);
assertEquals(virtualMachine.getId(), attachedVolume.getVirtualMachineId());
assertNotNull(attachedVolume.getAttached());
logger.info("detaching volume %s from vm %s", volume, virtualMachine);
job = client.getVolumeApi().detachVolume(volume.getId());
assertTrue(jobComplete.apply(job.getJobId()));