private List<StorageController> buildControllers(IMachine machine) {
List<StorageController> controllers = Lists.newArrayList();
for (IStorageController iStorageController : machine.getStorageControllers()) {
Builder storageControllerBuilder = StorageController.builder();
for (IMediumAttachment iMediumAttachment : machine.getMediumAttachmentsOfController(iStorageController
.getName())) {
IMedium iMedium = iMediumAttachment.getMedium();
if(iMedium != null) {
if (iMedium.getDeviceType().equals(DeviceType.HardDisk)) {
storageControllerBuilder.attachHardDisk(HardDisk.builder().diskpath(iMedium.getLocation())
.autoDelete(true).controllerPort(iMediumAttachment.getPort())
.deviceSlot(iMediumAttachment.getDevice().intValue()).build());
} else if (iMedium.getDeviceType().equals(DeviceType.DVD)) {
storageControllerBuilder.attachISO(iMediumAttachment.getPort(), iMediumAttachment.getDevice().intValue(),
iMedium.getLocation());
}
}
}
controllers.add(storageControllerBuilder.name(iStorageController.getName()).bus(iStorageController.getBus())
.build());
}
return controllers;
}