summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorVictor Mocanu2017-11-21 13:36:02 +0100
committerVictor Mocanu2017-11-21 13:36:02 +0100
commitcb22d2a446c5a6d0978f8317761eaf0532df6867 (patch)
treee55d5039d8b2ae59b19d813137b4db5d4fad3291 /src/main/java/org
parent[VBox] improved and expanded the setters and getters for the enum types (diff)
downloadmaster-sync-shared-cb22d2a446c5a6d0978f8317761eaf0532df6867.tar.gz
master-sync-shared-cb22d2a446c5a6d0978f8317761eaf0532df6867.tar.xz
master-sync-shared-cb22d2a446c5a6d0978f8317761eaf0532df6867.zip
[VBox] added all networkcards for virtualbox made small change to internal class
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/openslx/util/vm/VboxMetaData.java69
-rw-r--r--src/main/java/org/openslx/util/vm/VmMetaData.java30
2 files changed, 71 insertions, 28 deletions
diff --git a/src/main/java/org/openslx/util/vm/VboxMetaData.java b/src/main/java/org/openslx/util/vm/VboxMetaData.java
index 57563d0..a4dc063 100644
--- a/src/main/java/org/openslx/util/vm/VboxMetaData.java
+++ b/src/main/java/org/openslx/util/vm/VboxMetaData.java
@@ -55,10 +55,12 @@ class VBoxHWVersionMeta
class VBoxEthernetDevTypeMeta
{
public final String value;
+ public final boolean isPresent;
- public VBoxEthernetDevTypeMeta( String val )
+ public VBoxEthernetDevTypeMeta( boolean present, String val )
{
value = val;
+ isPresent = present;
}
}
@@ -258,12 +260,8 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
{
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 );
- }
+ config.changeAttribute( "AudioAdapter", "enabled", vmBoolean( sound.isPresent ) );
+ config.changeAttribute( "AudioAdapter", "controller", sound.value );
}
// TODO test with/without codec if there is sound
@@ -287,9 +285,7 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
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 );
+ throw new IllegalArgumentException( "Invalid entry: controller=" + controller );
}
}
return returnsct;
@@ -341,17 +337,46 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
@Override
public void setEthernetDevType( int cardIndex, EthernetDevType type )
{
- // TODO Auto-generated method stub
-
+ String index = "0";
+ VBoxEthernetDevTypeMeta networkc = networkCards.get( type );
+ // TODO cardIndex is not used yet...maybe later needed for different network cards
+ config.changeAttribute( "Adapter", "enabled", vmBoolean( networkc.isPresent ), "slot", index );
+ config.changeAttribute( "Adapter", "type", networkc.value, "slot", index );
}
@Override
public EthernetDevType getEthernetDevType( int cardIndex )
{
VmMetaData.EthernetDevType returnedt = null;
- // TODO what do here?
- // TODO need to search for the 1.st adapter of network tag
- return VmMetaData.EthernetDevType.AUTO;
+ Element x = (Element)config.findANode( "Adapter" ).item( 0 );
+ if ( !x.hasAttribute( "enabled" ) || ( x.hasAttribute( "enabled" ) && x.getAttribute( "enabled" ).equals( "false" ) ) ) {
+ returnedt = VmMetaData.EthernetDevType.NONE;
+ } else {
+ String type = x.getAttribute( "type" );
+ switch ( type ) {
+ case "Am79C970A":
+ returnedt = VmMetaData.EthernetDevType.PCNETPCI2;
+ break;
+ case "Am79C973":
+ returnedt = VmMetaData.EthernetDevType.PCNETFAST3;
+ break;
+ case "82540EM":
+ returnedt = VmMetaData.EthernetDevType.PRO1000MTD;
+ break;
+ case "82543GC":
+ returnedt = VmMetaData.EthernetDevType.PRO1000TS;
+ break;
+ case "82545EM":
+ returnedt = VmMetaData.EthernetDevType.PRO1000MTS;
+ break;
+ case "virtio":
+ returnedt = VmMetaData.EthernetDevType.PARAVIRT;
+ break;
+ default:
+ throw new IllegalArgumentException( "Invalid entry: type=" + type);
+ }
+ }
+ return returnedt;
}
@Override
@@ -363,7 +388,8 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
public void populateTheMaps()
{
// add all from vmware supported sound cards here
- soundCards.put( VmMetaData.SoundCardType.NONE, new VBoxSoundCardMeta( false, null ) );
+ // none type needs to have a valid value; it takes the value of AC97; if value is left null or empty vm will not start because value is not valid
+ soundCards.put( VmMetaData.SoundCardType.NONE, new VBoxSoundCardMeta( false, "AC97" ) );
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" ) );
@@ -377,9 +403,14 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
// 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" ) );
+ // none type needs to have a valid value; it takes the value of pcnetcpi2; if value is left null or empty vm will not start because value is not valid
+ networkCards.put( VmMetaData.EthernetDevType.NONE, new VBoxEthernetDevTypeMeta( false, "Am79C970A" ) );
+ networkCards.put( VmMetaData.EthernetDevType.PCNETPCI2, new VBoxEthernetDevTypeMeta( true, "Am79C970A" ) );
+ networkCards.put( VmMetaData.EthernetDevType.PCNETFAST3, new VBoxEthernetDevTypeMeta( true, "Am79C973" ) );
+ networkCards.put( VmMetaData.EthernetDevType.PRO1000MTD, new VBoxEthernetDevTypeMeta( true, "82540EM" ) );
+ networkCards.put( VmMetaData.EthernetDevType.PRO1000TS, new VBoxEthernetDevTypeMeta( true, "82543GC" ) );
+ networkCards.put( VmMetaData.EthernetDevType.PRO1000MTS, new VBoxEthernetDevTypeMeta( true, "82545EM" ) );
+ networkCards.put( VmMetaData.EthernetDevType.PARAVIRT, new VBoxEthernetDevTypeMeta( true, "virtio" ) );
// end of all from vmware supported Ethernet devices versions here
}
diff --git a/src/main/java/org/openslx/util/vm/VmMetaData.java b/src/main/java/org/openslx/util/vm/VmMetaData.java
index 5acfa3b..10f1373 100644
--- a/src/main/java/org/openslx/util/vm/VmMetaData.java
+++ b/src/main/java/org/openslx/util/vm/VmMetaData.java
@@ -33,6 +33,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 Hypervisors>
+ *
* @author victorm
*
*/
@@ -43,7 +44,7 @@ public abstract class VmMetaData<T, U, V, W>
SOUND_BLASTER( "Sound Blaster 16" ),
ES( "ES 1371" ),
HD_AUDIO( "Intel Integrated HD Audio" ),
- AC( "Intel ICH Audio Codec 97");
+ AC( "Intel ICH Audio Codec 97" );
public final String displayName;
@@ -54,8 +55,10 @@ public abstract class VmMetaData<T, U, V, W>
}
/**
- * All the available settings for the 3D acceleration that are supported by VmxPlayer and VBoxPlayer
+ * All the available settings for the 3D acceleration that are supported by VmxPlayer and
+ * VBoxPlayer
* <add further entries when incorporating other Hypervisors>
+ *
* @author victorm
*
*/
@@ -75,6 +78,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 Hypervisors>
+ *
* @author victorm
*
*/
@@ -91,7 +95,6 @@ public abstract class VmMetaData<T, U, V, W>
ELEVEN( "11 (Workstation 11, Player/Fusion 7)" ),
TWELVE( "12 (Workstation/Player 12, Fusion 8)" ),
DEFAULT( "default" );
-
public final String displayName;
@@ -104,6 +107,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 Hypervisors>
+ *
* @author victorm
*
*/
@@ -114,7 +118,14 @@ public abstract class VmMetaData<T, U, V, W>
E1000( "Intel E1000 (PCI)" ),
E1000E( "Intel E1000e (PCI-Express)" ),
VMXNET( "VMXnet" ),
- VMXNET3( "VMXnet 3" );
+ VMXNET3( "VMXnet 3" ),
+ PCNETPCI2( "PCnet-PCI II" ),
+ PCNETFAST3( "PCnet-FAST III" ),
+ PRO1000MTD( "Intel PRO/1000 MT Desktop" ),
+ PRO1000TS( "Intel PRO/1000 T Server" ),
+ PRO1000MTS( "Intel PRO/1000 MT Server" ),
+ PARAVIRT( "Paravirtualized Network" ),
+ NONE( "No Network Card" );
public final String displayName;
@@ -282,7 +293,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 );
@@ -299,7 +310,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 );
@@ -351,11 +362,12 @@ public abstract class VmMetaData<T, U, V, W>
public abstract EthernetDevType getEthernetDevType( int cardIndex );
public abstract byte[] getDefinitionArray();
-
+
/**
*
- * Function used by subclasses to put the virtual devices, which the subclass supports in the respected map
- * (i.e. a supported virtual Soundcard in the soundCards Map
+ * Function used by subclasses to put the virtual devices, which the subclass supports in the
+ * respected map
+ * (i.e. a supported virtual Soundcard in the soundCards Map
*/
public abstract void populateTheMaps();
}