diff options
author | Simon Rettberg | 2018-09-17 13:58:58 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-09-17 13:58:58 +0200 |
commit | 669f5df1a6a00799053cfcbc8c7209f8f4afb233 (patch) | |
tree | 4752834a79f6ed0d879c83cf6d2e9fed91dbc74b /src/main/java/org/openslx/util/vm/VmMetaData.java | |
parent | remove unused import (diff) | |
download | master-sync-shared-669f5df1a6a00799053cfcbc8c7209f8f4afb233.tar.gz master-sync-shared-669f5df1a6a00799053cfcbc8c7209f8f4afb233.tar.xz master-sync-shared-669f5df1a6a00799053cfcbc8c7209f8f4afb233.zip |
Improve VM descriütion file detection and parsing
Diffstat (limited to 'src/main/java/org/openslx/util/vm/VmMetaData.java')
-rw-r--r-- | src/main/java/org/openslx/util/vm/VmMetaData.java | 41 |
1 files changed, 12 insertions, 29 deletions
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<T, U, V, W> * * @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<OperatingSystem> osList, File file ) throws IOException + public static VmMetaData<?, ?, ?, ?> getInstance( List<OperatingSystem> 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<T, U, V, W> */ public static VmMetaData<?, ?, ?, ?> getInstance( List<OperatingSystem> 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; } |