@Override
public List<KvmDrive> get() {
List<KvmDrive> drives = Lists.newArrayList();
{
KvmDrive drive = new KvmDrive();
drive.path = getImagePath().getAbsolutePath();
drive.id = "0";
drive.boot = true;
drive.format = "raw";
drive.media = "disk";
OpsTarget target = OpsContext.get().getInstance(OpsTarget.class);
ProcessExecution fileCommand;
try {
fileCommand = target.executeCommand(Command.build("file --brief {0}", getImagePath()));
} catch (OpsException e) {
throw new IllegalStateException("Error querying file type", e);
}
String fileStdout = fileCommand.getStdOut();
if (fileStdout.contains("QCOW Image")) {
drive.format = "qcow2";
}
drives.add(drive);
}
{
KvmDrive drive = new KvmDrive();
drive.path = getConfigIsoPath().getAbsolutePath();
drive.id = "config";
drive.boot = false;
drive.format = "raw";