summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/util/vm/VboxMetaData.java
diff options
context:
space:
mode:
authorVictor Mocanu2017-11-02 17:12:56 +0100
committerVictor Mocanu2017-11-02 17:12:56 +0100
commit1f58a5c478c82978418cb152ad43a7cc18a002a8 (patch)
treeed26ba585b5e9e6cbd1dfe3c6009be259d74cb8e /src/main/java/org/openslx/util/vm/VboxMetaData.java
parent[VBox] added sorting to the keysarrays (diff)
downloadmaster-sync-shared-1f58a5c478c82978418cb152ad43a7cc18a002a8.tar.gz
master-sync-shared-1f58a5c478c82978418cb152ad43a7cc18a002a8.tar.xz
master-sync-shared-1f58a5c478c82978418cb152ad43a7cc18a002a8.zip
[VBox] new working coppy
added new Javadocs, updated getters of VBoxMetaData still got TODOs
Diffstat (limited to 'src/main/java/org/openslx/util/vm/VboxMetaData.java')
-rw-r--r--src/main/java/org/openslx/util/vm/VboxMetaData.java104
1 files changed, 77 insertions, 27 deletions
diff --git a/src/main/java/org/openslx/util/vm/VboxMetaData.java b/src/main/java/org/openslx/util/vm/VboxMetaData.java
index fe3f31c..7e814fa 100644
--- a/src/main/java/org/openslx/util/vm/VboxMetaData.java
+++ b/src/main/java/org/openslx/util/vm/VboxMetaData.java
@@ -18,6 +18,7 @@ import javax.xml.transform.stream.StreamResult;
import org.apache.log4j.Logger;
import org.openslx.bwlp.thrift.iface.OperatingSystem;
import org.openslx.bwlp.thrift.iface.Virtualizer;
+import org.w3c.dom.Element;
class VBoxSoundCardMeta
{
@@ -63,7 +64,6 @@ class VBoxEthernetDevTypeMeta
public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta, VBoxHWVersionMeta, VBoxEthernetDevTypeMeta>
{
-
private static final Logger LOGGER = Logger.getLogger( VboxMetaData.class );
private static final Virtualizer virtualizer = new Virtualizer( "virtualbox", "VirtualBox" );
@@ -72,7 +72,6 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
public VboxMetaData( List<OperatingSystem> osList, File file ) throws IOException, UnsupportedVirtualizerFormatException
{
-
super( osList );
this.config = new VboxConfig( file );
init();
@@ -80,7 +79,6 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
public VboxMetaData( List<OperatingSystem> osList, byte[] vmContent, int length ) throws IOException, UnsupportedVirtualizerFormatException
{
-
super( osList );
this.config = new VboxConfig( vmContent, length );
init();
@@ -88,6 +86,8 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
private void init()
{
+ populateTheMaps();
+
this.config.init();
displayName = config.getDisplayName();
setOs( "virtualbox", config.getOsName() );
@@ -95,19 +95,9 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
for ( HardDisk hardDisk : config.getHdds() ) {
hdds.add( hardDisk );
}
-
- // hey debug code here
- try {
- addFloppy( 0, null, true );
- WriteToFile();
- } catch ( TransformerFactoryConfigurationError | TransformerException e ) {
- // WriteToFile exceptions here...not important for the the LOGGER
- e.printStackTrace();
- }
- // end here
}
- // --TODO will be needed later again
+ // TODO DELETE LATER WHEN NOT NEEDED ANYMORE
private void WriteToFile() throws TransformerFactoryConfigurationError, TransformerException
{
Transformer transformer = TransformerFactory.newInstance().newTransformer();
@@ -115,6 +105,7 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
Source input = new DOMSource( config.getConfigDoc() );
transformer.transform( input, output );
}
+ // TODO END DELETE LATER WHEN NOT NEEDED ANYMORE
@Override
public Virtualizer getVirtualizer()
@@ -270,24 +261,38 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
}
@Override
- public org.openslx.util.vm.VmMetaData.SoundCardType getSoundCard()
+ public VmMetaData.SoundCardType getSoundCard()
{
- // TODO Auto-generated method stub
- return null;
+ VmMetaData.SoundCardType returnsct = null;
+ // TODO ask about controller and driver
+ Element x = (Element) config.findANode( "AudioAdapter" ).item( 0 );
+ returnsct = VmMetaData.SoundCardType.DEFAULT;
+ // TODO End
+ return returnsct;
}
@Override
- public void setDDAcceleration( org.openslx.util.vm.VmMetaData.DDAcceleration type )
+ public void setDDAcceleration( VmMetaData.DDAcceleration type )
{
// TODO Auto-generated method stub
}
@Override
- public org.openslx.util.vm.VmMetaData.DDAcceleration getDDAcceleration()
+ public VmMetaData.DDAcceleration getDDAcceleration()
{
- // TODO Auto-generated method stub
- return null;
+ VmMetaData.DDAcceleration returndda = null;
+ Element x = (Element)config.findANode( "Display" ).item( 0 );
+ if ( x.hasAttribute( "accelerate3D" ) ) {
+ if ( x.getAttribute( "accelerate3D" ).equals( "true" ) ) {
+ returndda = VmMetaData.DDAcceleration.ON;
+ } else {
+ returndda = VmMetaData.DDAcceleration.OFF;
+ }
+ } else {
+ returndda = VmMetaData.DDAcceleration.OFF;
+ }
+ return returndda;
}
@Override
@@ -300,8 +305,11 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
@Override
public HWVersion getHWVersion()
{
- // TODO Auto-generated method stub
- return null;
+ VmMetaData.HWVersion returnhwv = null;
+ // TODO what do here? there is only one supported hwversion as far as I know
+ returnhwv = VmMetaData.HWVersion.NONE;
+ // TODO End
+ return returnhwv;
}
@Override
@@ -314,14 +322,56 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
@Override
public EthernetDevType getEthernetDevType( int cardIndex )
{
- // TODO Auto-generated method stub
- return null;
+ VmMetaData.EthernetDevType returnedt = null;
+ // TODO what do here?
+ // TODO need to search for the 1.st adapter of network tag
+ return VmMetaData.EthernetDevType.AUTO;
}
@Override
public byte[] getDefinitionArray()
{
- // TODO Auto-generated method stub
- return null;
+ return config.toString().getBytes( StandardCharsets.UTF_8 );
+ }
+
+ public void populateTheMaps()
+ {
+ /* add all from VBox supported sound cards here
+ soundCards.put( VmMetaData.SoundCardType.NONE, new VBoxSoundCardMeta( false, null ) );
+ soundCards.put( VmMetaData.SoundCardType.HD_AUDIO, new VBoxSoundCardMeta( true, "hdaudio" ) );
+ // end of supported sound cards
+ // add all from VBox supported settings for the 3D acceleration
+ ddacc.put( VmMetaData.DDAcceleration.ON, new VBoxDDAccelMeta( true ) );
+ ddacc.put( VmMetaData.DDAcceleration.OFF, new VBoxDDAccelMeta( false ) );
+ // end of all from VBox supported settings for the 3D acceleration
+ // add all from VBox supported Hardware versions here
+ hwversion.put( VmMetaData.HWVersion.NONE, new VBoxHWVersionMeta( 0 ) );
+ // end of all from VBox supported Hardware versions here
+ // add all from VBox supported Ethernet devices versions here
+ networkCards.put( VmMetaData.EthernetDevType.E1000, new VBoxEthernetDevTypeMeta( "e1000" ) );
+ // end of all from VBox supported Ethernet devices versions here */
+
+ // add all from vmware supported sound cards here
+ soundCards.put( VmMetaData.SoundCardType.NONE, new VBoxSoundCardMeta( false, null ) );
+ soundCards.put( VmMetaData.SoundCardType.DEFAULT, new VBoxSoundCardMeta( true, null ) );
+ soundCards.put( VmMetaData.SoundCardType.SOUND_BLASTER, new VBoxSoundCardMeta( true, "sb16" ) );
+ soundCards.put( VmMetaData.SoundCardType.ES, new VBoxSoundCardMeta( true, "es1371" ) );
+ soundCards.put( VmMetaData.SoundCardType.HD_AUDIO, new VBoxSoundCardMeta( true, "hdaudio" ) );
+ // end of supported sound cards
+ // add all from vmware supported settings for the 3D acceleration
+ ddacc.put( VmMetaData.DDAcceleration.OFF, new VBoxDDAccelMeta( false ) );
+ ddacc.put( VmMetaData.DDAcceleration.ON, new VBoxDDAccelMeta( true ) );
+ // end of all from vmware supported settings for the 3D acceleration
+ // add all from vmware supported Hardware versions here
+ hwversion.put( VmMetaData.HWVersion.NONE, new VBoxHWVersionMeta( 0 ) );
+ hwversion.put( VmMetaData.HWVersion.THREE, new VBoxHWVersionMeta( 3 ) );
+ hwversion.put( VmMetaData.HWVersion.FOUR, new VBoxHWVersionMeta( 4 ) );
+
+ // end of all from vmware supported Hardware versions here
+ // add all from vmware supported Ethernet devices versions here
+ networkCards.put( VmMetaData.EthernetDevType.AUTO, new VBoxEthernetDevTypeMeta( null ) );
+ networkCards.put( VmMetaData.EthernetDevType.PCNET32, new VBoxEthernetDevTypeMeta( "vlance" ) );
+ networkCards.put( VmMetaData.EthernetDevType.E1000, new VBoxEthernetDevTypeMeta( "e1000" ) );
+ // end of all from vmware supported Ethernet devices versions here
}
}