From 669f5df1a6a00799053cfcbc8c7209f8f4afb233 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 17 Sep 2018 13:58:58 +0200 Subject: Improve VM descriütion file detection and parsing --- src/main/java/org/openslx/util/vm/VmMetaData.java | 41 +++++++---------------- 1 file changed, 12 insertions(+), 29 deletions(-) (limited to 'src/main/java/org/openslx/util/vm/VmMetaData.java') diff --git a/src/main/java/org/openslx/util/vm/VmMetaData.java b/src/main/java/org/openslx/util/vm/VmMetaData.java index d98deee..aafb6a4 100644 --- a/src/main/java/org/openslx/util/vm/VmMetaData.java +++ b/src/main/java/org/openslx/util/vm/VmMetaData.java @@ -259,33 +259,27 @@ public abstract class VmMetaData * * @param osList List of supported operating systems * @param file VM's machine description file to get the metadata instance from - * @return VmMetaData object representing the relevant parts of the given machine description - * @throws IOException + * @return VmMetaData object representing the relevant parts of the given machine description */ - public static VmMetaData getInstance( List osList, File file ) throws IOException + public static VmMetaData getInstance( List osList, File file ) + throws IOException { - Exception errEx = null; try { return new VmwareMetaData( osList, file ); } catch ( UnsupportedVirtualizerFormatException e ) { - LOGGER.debug( "Disk file not .vmdk" ); - errEx = e; + LOGGER.info( "Not a VMware file", e ); } try { return new VboxMetaData( osList, file ); } catch ( UnsupportedVirtualizerFormatException e ) { - LOGGER.debug( "Disk file not .vdi" ); - errEx = e; + LOGGER.info( "Not a VirtualBox file", e ); } try { return new QemuMetaData( osList, file ); } catch ( Exception e ) { - LOGGER.debug( "Disk file not qemu supported format" ); - errEx = e; - } - if ( errEx != null ) { - LOGGER.error( "Unsupported disk file format!", errEx ); + LOGGER.info( "Not a QEmu file", e ); } + LOGGER.error( "Could not detect any known virtualizer format" ); return null; } @@ -300,29 +294,18 @@ public abstract class VmMetaData */ public static VmMetaData getInstance( List osList, byte[] vmContent, int length ) throws IOException { - Exception errEx = null; try { return new VmwareMetaData( osList, vmContent, length ); } catch ( UnsupportedVirtualizerFormatException e ) { - LOGGER.debug( "Machine description not in .vmx format." ); - errEx = e; + LOGGER.info( "Not a VMware file", e ); } try { return new VboxMetaData( osList, vmContent, length ); - } catch ( UnsupportedVirtualizerFormatException | NullPointerException e ) { - LOGGER.debug( "Machine description not in .vbox format." ); - errEx = e; - } - // how to do this check ?? - try { - return new QemuMetaData( osList, vmContent ); - } catch ( Exception e ) { - LOGGER.debug( "Machine description not in qemu supported format" ); - errEx = e; - } - if ( errEx != null ) { - LOGGER.error( "Machine description has an unknown format!", errEx ); + } catch ( UnsupportedVirtualizerFormatException e ) { + LOGGER.info( "Not a VirtualBox file", e ); } + // TODO QEmu -- hack above expects qcow2 file, so we can't do anything here yet + LOGGER.error( "Could not detect any known virtualizer format" ); return null; } -- cgit v1.2.3-55-g7522