summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/util/vm/VboxMetaData.java
diff options
context:
space:
mode:
authorVictor Mocanu2017-11-20 15:16:54 +0100
committerVictor Mocanu2017-11-20 15:16:54 +0100
commit1967876ea2e8340a95d424ef873a4ab4e53e4a57 (patch)
treeadcb35fc3179e9863f196c8f5611d2753dee39a9 /src/main/java/org/openslx/util/vm/VboxMetaData.java
parent[VBox] setter for the 3dacceleration works now, added new hardwareversion enu... (diff)
downloadmaster-sync-shared-1967876ea2e8340a95d424ef873a4ab4e53e4a57.tar.gz
master-sync-shared-1967876ea2e8340a95d424ef873a4ab4e53e4a57.tar.xz
master-sync-shared-1967876ea2e8340a95d424ef873a4ab4e53e4a57.zip
[VBox] improved and expanded the setters and getters for the enum types
removed debug messages
Diffstat (limited to 'src/main/java/org/openslx/util/vm/VboxMetaData.java')
-rw-r--r--src/main/java/org/openslx/util/vm/VboxMetaData.java59
1 files changed, 42 insertions, 17 deletions
diff --git a/src/main/java/org/openslx/util/vm/VboxMetaData.java b/src/main/java/org/openslx/util/vm/VboxMetaData.java
index fcb89d9..57563d0 100644
--- a/src/main/java/org/openslx/util/vm/VboxMetaData.java
+++ b/src/main/java/org/openslx/util/vm/VboxMetaData.java
@@ -145,7 +145,6 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
config.changeAttribute( "HardDisk", "location", diskImagePath );
UUID newhdduuid = UUID.randomUUID();
- LOGGER.debug( newhdduuid );
// patching the new uuid in the vbox config file here
String vboxUUid = "{" + newhdduuid.toString() + "}";
@@ -194,7 +193,7 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
@Override
public boolean addDefaultNat()
{
- config.addNewNode( "Adapter", "NAT", false );
+ config.addNewNode( "Adapter", "NAT", true );
return true;
}
@@ -203,7 +202,6 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
try {
WriteToFile();
} catch ( TransformerFactoryConfigurationError | TransformerException e ) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
}
@@ -211,8 +209,9 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
@Override
public void setOs( String vendorOsId )
{
- // TODO Auto-generated method stub
-
+ // TODO test this
+ config.changeAttribute( "Machine", "OSType", vendorOsId );
+ setOs( "vmware", vendorOsId );
}
@Override
@@ -249,25 +248,50 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
@Override
public boolean addCpuCoreCount( int nrOfCores )
{
- config.changeAttribute( "CPU", "count", "1" );
+ config.changeAttribute( "CPU", "count", Integer.toString( nrOfCores ) );
return true;
}
+ // TODO test with/without codec if there is sound
@Override
public void setSoundCard( org.openslx.util.vm.VmMetaData.SoundCardType type )
{
- // TODO Auto-generated method stub
+ VBoxSoundCardMeta sound = soundCards.get( type );
+ if ( type.equals( VmMetaData.SoundCardType.NONE ) ) {
+ config.changeAttribute( "AudioAdapter", "enabled", vmBoolean( false ) );
+ } else {
+ config.changeAttribute( "AudioAdapter", "enabled", vmBoolean( true ) );
+ config.changeAttribute( "AudioAdapter", "controller", sound.value );
+ }
}
+ // TODO test with/without codec if there is sound
@Override
public VmMetaData.SoundCardType getSoundCard()
{
VmMetaData.SoundCardType returnsct = null;
- // TODO ask about controller and driver
- Element x = (Element) config.findANode( "AudioAdapter" ).item( 0 );
- returnsct = VmMetaData.SoundCardType.DEFAULT;
- // TODO End
+ Element x = (Element)config.findANode( "AudioAdapter" ).item( 0 );
+ if ( !x.hasAttribute( "enabled" ) || ( x.hasAttribute( "enabled" ) && x.getAttribute( "enabled" ).equals( "false" ) ) ) {
+ returnsct = VmMetaData.SoundCardType.NONE;
+ } else {
+ String controller = x.getAttribute( "controller" );
+ switch ( controller ) {
+ case "HDA":
+ returnsct = VmMetaData.SoundCardType.HD_AUDIO;
+ break;
+ case "SB16":
+ returnsct = VmMetaData.SoundCardType.SOUND_BLASTER;
+ break;
+ case "AC97":
+ returnsct = VmMetaData.SoundCardType.AC;
+ break;
+ default:
+ // TODO ask around if there exists another possibility to tell the user that the previous argument was wrong without blocking the whole
+ // program
+ throw new IllegalArgumentException( "Invalid entry: " + controller );
+ }
+ }
return returnsct;
}
@@ -275,9 +299,9 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
public void setDDAcceleration( VmMetaData.DDAcceleration type )
{
VBoxDDAccelMeta accel = ddacc.get( type );
- config.changeAttribute( "Display", "accelerate3D", vmBoolean(accel.isPresent));
+ config.changeAttribute( "Display", "accelerate3D", vmBoolean( accel.isPresent ) );
}
-
+
@Override
public VmMetaData.DDAcceleration getDDAcceleration()
{
@@ -340,9 +364,9 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
{
// add all from vmware supported sound cards here
soundCards.put( VmMetaData.SoundCardType.NONE, new VBoxSoundCardMeta( false, 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" ) );
+ soundCards.put( VmMetaData.SoundCardType.SOUND_BLASTER, new VBoxSoundCardMeta( true, "SB16" ) );
+ soundCards.put( VmMetaData.SoundCardType.HD_AUDIO, new VBoxSoundCardMeta( true, "HDA" ) );
+ soundCards.put( VmMetaData.SoundCardType.AC, new VBoxSoundCardMeta( true, "AC97" ) );
// end of supported sound cards
// add all from vmware supported settings for the 3D acceleration
ddacc.put( VmMetaData.DDAcceleration.OFF, new VBoxDDAccelMeta( false ) );
@@ -358,9 +382,10 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
networkCards.put( VmMetaData.EthernetDevType.E1000, new VBoxEthernetDevTypeMeta( "e1000" ) );
// end of all from vmware supported Ethernet devices versions here
}
-
+
/**
* given a boolean value returns a string in lowercase of given boolean
+ *
* @param var
* @return
*/