summaryrefslogtreecommitdiffstats
path: root/src/main/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
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')
-rw-r--r--src/main/java/org/openslx/util/vm/VboxConfig.java26
-rw-r--r--src/main/java/org/openslx/util/vm/VboxMetaData.java59
-rw-r--r--src/main/java/org/openslx/util/vm/VmMetaData.java15
3 files changed, 76 insertions, 24 deletions
diff --git a/src/main/java/org/openslx/util/vm/VboxConfig.java b/src/main/java/org/openslx/util/vm/VboxConfig.java
index 6a44402..efab84b 100644
--- a/src/main/java/org/openslx/util/vm/VboxConfig.java
+++ b/src/main/java/org/openslx/util/vm/VboxConfig.java
@@ -281,6 +281,32 @@ public class VboxConfig
}
/**
+ * Function uses the findANode function to narrow down the wanted node using 2 attributes and
+ * their values
+ *
+ * @param targetTag
+ * @param targetAttr0
+ * @param value0
+ * @param targetAttr1
+ * @param value1
+ * @return
+ */
+ public Node findANode( String targetTag, String targetAttr0, String value0 )
+ {
+ Node returnNode = null;
+
+ NodeList foundNodes = findANode( targetTag );
+
+ for ( int i = 0; i < foundNodes.getLength(); i++ ) {
+ Element node = (Element)foundNodes.item( i );
+ if ( node.hasAttribute( targetAttr0 ) && node.getAttribute( targetAttr0 ).equals( value0 ) ) {
+ returnNode = foundNodes.item( i );
+ }
+ }
+ return returnNode;
+ }
+
+ /**
* Function used to change the value of an attribute
* Use this function if you know the targetNode is unique
*
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
*/
diff --git a/src/main/java/org/openslx/util/vm/VmMetaData.java b/src/main/java/org/openslx/util/vm/VmMetaData.java
index ba9c357..5acfa3b 100644
--- a/src/main/java/org/openslx/util/vm/VmMetaData.java
+++ b/src/main/java/org/openslx/util/vm/VmMetaData.java
@@ -32,7 +32,7 @@ public abstract class VmMetaData<T, U, V, W>
/**
* All the available virtual Sound Cards that are supported by VmxPlayer and VBoxPlayer
- * <add further entries when incorporating other Virtualizers>
+ * <add further entries when incorporating other Hypervisors>
* @author victorm
*
*/
@@ -42,7 +42,8 @@ public abstract class VmMetaData<T, U, V, W>
DEFAULT( "(default)" ),
SOUND_BLASTER( "Sound Blaster 16" ),
ES( "ES 1371" ),
- HD_AUDIO( "Intel Integrated HD Audio" );
+ HD_AUDIO( "Intel Integrated HD Audio" ),
+ AC( "Intel ICH Audio Codec 97");
public final String displayName;
@@ -54,7 +55,7 @@ public abstract class VmMetaData<T, U, V, W>
/**
* All the available settings for the 3D acceleration that are supported by VmxPlayer and VBoxPlayer
- * <add further entries when incorporating other Virtualizers>
+ * <add further entries when incorporating other Hypervisors>
* @author victorm
*
*/
@@ -73,7 +74,7 @@ public abstract class VmMetaData<T, U, V, W>
/**
* All the available virtual Hardware Versions that are supported by VmxPlayer and VBoxPlayer
- * <add further entries when incorporating other Virtualizers>
+ * <add further entries when incorporating other Hypervisors>
* @author victorm
*
*/
@@ -102,7 +103,7 @@ public abstract class VmMetaData<T, U, V, W>
/**
* All the available virtual Network Cards that are supported by VmxPlayer and VBoxPlayer
- * <add further entries when incorporating other Virtualizers>
+ * <add further entries when incorporating other Hypervisors>
* @author victorm
*
*/
@@ -281,7 +282,7 @@ public abstract class VmMetaData<T, U, V, W>
public abstract void applySettingsForLocalEdit();
// meta object needed when reading vm from file
- public static VmMetaData getInstance( List<OperatingSystem> osList, File file ) throws IOException
+ public static VmMetaData<?,?,?,?> getInstance( List<OperatingSystem> osList, File file ) throws IOException
{
try {
return new VmwareMetaData( osList, file );
@@ -298,7 +299,7 @@ public abstract class VmMetaData<T, U, V, W>
}
// meta object needed when reading from configarray
- public static VmMetaData getInstance( List<OperatingSystem> osList, byte[] vmContent, int length ) throws IOException
+ public static VmMetaData<?,?,?,?> getInstance( List<OperatingSystem> osList, byte[] vmContent, int length ) throws IOException
{
try {
return new VmwareMetaData( osList, vmContent, length );