diff options
author | Victor Mocanu | 2017-05-22 12:15:47 +0200 |
---|---|---|
committer | Victor Mocanu | 2017-05-22 12:15:47 +0200 |
commit | 908be91fa0ecca4ef0904bce729b3aaf184d2c4b (patch) | |
tree | 2ac20675e4d1c01ba4f7c7c5f789a3cf13e111c7 /src/main/java/org/openslx/util/vm/VmwareConfig.java | |
parent | Add Feature support for dozmod; add allowLoginByDefault option (diff) | |
download | master-sync-shared-908be91fa0ecca4ef0904bce729b3aaf184d2c4b.tar.gz master-sync-shared-908be91fa0ecca4ef0904bce729b3aaf184d2c4b.tar.xz master-sync-shared-908be91fa0ecca4ef0904bce729b3aaf184d2c4b.zip |
[VBOX] restructured generic VmMetaData for comming VBox support
Diffstat (limited to 'src/main/java/org/openslx/util/vm/VmwareConfig.java')
-rw-r--r-- | src/main/java/org/openslx/util/vm/VmwareConfig.java | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/main/java/org/openslx/util/vm/VmwareConfig.java b/src/main/java/org/openslx/util/vm/VmwareConfig.java index c0e30f6..f425b23 100644 --- a/src/main/java/org/openslx/util/vm/VmwareConfig.java +++ b/src/main/java/org/openslx/util/vm/VmwareConfig.java @@ -1,7 +1,9 @@ package org.openslx.util.vm; +import java.awt.RenderingHints.Key; import java.io.BufferedReader; import java.io.ByteArrayInputStream; +import java.io.Console; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -31,7 +33,7 @@ public class VmwareConfig // (void) } - public VmwareConfig( File file ) throws IOException + public VmwareConfig( File file ) throws IOException, UnsupportedVirtualizerFormatException { int todo = (int)Math.min( 100000, file.length() ); int offset = 0; @@ -53,7 +55,7 @@ public class VmwareConfig } - public VmwareConfig( InputStream is ) throws IOException + public VmwareConfig( InputStream is ) throws IOException, UnsupportedVirtualizerFormatException { int todo = Math.max( 4000, Math.min( 100000, is.available() ) ); int offset = 0; @@ -68,22 +70,33 @@ public class VmwareConfig init( data, offset ); } - public VmwareConfig( byte[] vmxContent, int length ) + public VmwareConfig( byte[] vmxContent, int length ) throws UnsupportedVirtualizerFormatException { init( vmxContent, length ); } - private void init( byte[] vmxContent, int length ) + // function is used for both .vmx and .vmdk files + private void init( byte[] vmxContent, int length) throws UnsupportedVirtualizerFormatException { try { + boolean isValid = false; BufferedReader reader = getVmxReader( vmxContent, length ); String line; while ( ( line = reader.readLine() ) != null ) { KeyValuePair entry = parse( line ); + + if ( entry != null ) { - set( entry.key, unescape( entry.value ) ); + // TODO ask Simon which key is best for the check + if ( entry.key.equals("virtualHW.version") || entry.key.equals("ddb.virtualHWVersion")) { + isValid = true; + } + set( entry.key, unescape( entry.value ) ); } } + if (!isValid) { + throw new UnsupportedVirtualizerFormatException("not Vmware image format"); + } } catch ( IOException e ) { LOGGER.warn( "Exception when loading vmx from byte array (how!?)", e ); } |