summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Bentele2021-04-23 16:44:18 +0200
committerManuel Bentele2021-04-23 16:44:18 +0200
commit966cbd842fac0996742f33c85c60221c9e461930 (patch)
tree75970d9c506730c1736c8b01430b5ad0c56b22ed
parentEncapsulate transformation logic for virtualization configurations (diff)
downloadmaster-sync-shared-966cbd842fac0996742f33c85c60221c9e461930.tar.gz
master-sync-shared-966cbd842fac0996742f33c85c60221c9e461930.tar.xz
master-sync-shared-966cbd842fac0996742f33c85c60221c9e461930.zip
Refactors and abstracts version information in config logic and disk image
-rw-r--r--src/main/java/org/openslx/virtualization/Version.java190
-rw-r--r--src/main/java/org/openslx/virtualization/configuration/VirtualizationConfiguration.java87
-rw-r--r--src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationDocker.java43
-rw-r--r--src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationQemu.java77
-rw-r--r--src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationVirtualBox.java50
-rw-r--r--src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationVmware.java91
-rw-r--r--src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogic.java2
-rw-r--r--src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModClientToDozModServer.java4
-rw-r--r--src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToDozModClient.java4
-rw-r--r--src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToStatelessClient.java4
-rw-r--r--src/main/java/org/openslx/virtualization/virtualizer/Virtualizer.java8
-rw-r--r--src/main/java/org/openslx/virtualization/virtualizer/VirtualizerDocker.java14
-rw-r--r--src/main/java/org/openslx/virtualization/virtualizer/VirtualizerQemu.java12
-rw-r--r--src/main/java/org/openslx/virtualization/virtualizer/VirtualizerVirtualBox.java12
-rw-r--r--src/main/java/org/openslx/virtualization/virtualizer/VirtualizerVmware.java28
-rw-r--r--src/main/java/org/openslx/vm/disk/DiskImage.java3
-rw-r--r--src/main/java/org/openslx/vm/disk/DiskImageQcow2.java8
-rw-r--r--src/main/java/org/openslx/vm/disk/DiskImageUtils.java20
-rw-r--r--src/main/java/org/openslx/vm/disk/DiskImageVdi.java6
-rw-r--r--src/main/java/org/openslx/vm/disk/DiskImageVmdk.java13
-rw-r--r--src/test/java/org/openslx/virtualization/VersionTest.java98
-rw-r--r--src/test/java/org/openslx/virtualization/configuration/VirtualizationConfigurationQemuTest.java35
-rw-r--r--src/test/java/org/openslx/vm/disk/DiskImageQcow2Test.java27
-rw-r--r--src/test/java/org/openslx/vm/disk/DiskImageVdiTest.java7
-rw-r--r--src/test/java/org/openslx/vm/disk/DiskImageVmdkTest.java13
25 files changed, 482 insertions, 374 deletions
diff --git a/src/main/java/org/openslx/virtualization/Version.java b/src/main/java/org/openslx/virtualization/Version.java
new file mode 100644
index 0000000..7d4d016
--- /dev/null
+++ b/src/main/java/org/openslx/virtualization/Version.java
@@ -0,0 +1,190 @@
+package org.openslx.virtualization;
+
+import java.util.List;
+import java.util.function.Predicate;
+
+/**
+ * Represents a version information.
+ *
+ * The version information is used in the field of virtualization (for virtualizers, disk images,
+ * virtualization configuration files, ...).
+ *
+ * @author Manuel Bentele
+ * @version 1.0
+ */
+public class Version implements Comparable<Version>
+{
+ private final short major;
+ private final short minor;
+ private final String name;
+
+ /**
+ * Creates a new version.
+ *
+ * The version consists of a major version, whereas the minor version is set to the value
+ * <code>0</code> and the version name is undefined.
+ *
+ * @param major
+ */
+ public Version( short major )
+ {
+ this( major, Short.valueOf( "0" ), null );
+ }
+
+ /**
+ * Creates a new version.
+ *
+ * The version consists of a major version labeled with a version name, whereas the minor version
+ * is set to the value <code>0</code>.
+ *
+ * @param major major version.
+ * @param name version name.
+ */
+ public Version( short major, String name )
+ {
+ this( major, Short.valueOf( "0" ), name );
+ }
+
+ /**
+ * Creates a new version.
+ *
+ * The version consists of a major and a minor version, whereas the version name is undefined.
+ *
+ * @param major major version.
+ * @param minor minor version.
+ */
+ public Version( short major, short minor )
+ {
+ this( major, minor, null );
+ }
+
+ /**
+ * Creates a new version.
+ *
+ * The version consists of a major and a minor version labeled with a version name.
+ *
+ * @param major major version.
+ * @param minor minor version.
+ * @param name version name.
+ */
+ public Version( short major, short minor, String name )
+ {
+ this.major = major;
+ this.minor = minor;
+ this.name = name;
+ }
+
+ /**
+ * Returns the major version.
+ *
+ * @return major version.
+ */
+ public short getMajor()
+ {
+ return this.major;
+ }
+
+ /**
+ * Returns the minor version.
+ *
+ * @return minor version.
+ */
+ public short getMinor()
+ {
+ return this.minor;
+ }
+
+ /**
+ * Returns the full version as {@link Integer}.
+ *
+ * The full version consists of the major and minor version where both are combined in one
+ * {@link Integer} value. The upper 16-bits of the value represent the major number, whereas
+ * the lower 16-bits represent the minor number.
+ *
+ * @return full version as {@link Integer}.
+ */
+ public int getVersion()
+ {
+ final int major = this.major;
+ final int minor = this.minor;
+
+ return ( major << Short.SIZE ) | minor;
+ }
+
+ /**
+ * Returns the name of the version.
+ *
+ * @return name of the version.
+ */
+ public String getName()
+ {
+ return this.name;
+ }
+
+ /**
+ * Checks if version is supported by a version from a list of supported versions.
+ *
+ * @param supportedVersions list of supported versions.
+ * @return state whether version is supported by a version from the list of versions or not.
+ */
+ public boolean isSupported( List<Version> supportedVersions )
+ {
+ return supportedVersions.contains( this );
+ }
+
+ /**
+ * Returns a version from a list of supported versions by its given major version.
+ *
+ * @param major version.
+ * @param supportedVersions list of supported versions.
+ * @return version from a list of supported versions by its given major version.
+ */
+ public static Version getInstanceByMajorFromVersions( short major, List<Version> supportedVersions )
+ {
+ final Predicate<Version> byMajor = version -> major == version.getMajor();
+ return supportedVersions.stream().filter( byMajor ).findFirst().orElse( null );
+ }
+
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( obj == null ) {
+ return false;
+ } else if ( this.getClass() != obj.getClass() ) {
+ return false;
+ } else if ( this.compareTo( Version.class.cast( obj ) ) == 0 ) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int compareTo( Version v )
+ {
+ // compare the current version to the specified version
+ if ( this.getMajor() < v.getMajor() ) {
+ // current major version is smaller than the given major version
+ return -1;
+ } else if ( this.getMajor() > v.getMajor() ) {
+ // current major version is larger than the given major version
+ return 1;
+ } else {
+ // current major version is equal to the given major version
+ // so compare the current minor version to the specified minor version
+ if ( this.getMinor() < v.getMinor() ) {
+ // current minor version is smaller than the given minor version
+ // so the entire version is smaller than the given version
+ return -1;
+ } else if ( this.getMinor() > v.getMinor() ) {
+ // current minor version is larger than the given minor version
+ // so the entire version is larger than the given version
+ return 1;
+ } else {
+ // current minor version is equal to the given minor version
+ // so the entire version is equal to the given version
+ return 0;
+ }
+ }
+ }
+}
diff --git a/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfiguration.java b/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfiguration.java
index 69cd3d5..04260df 100644
--- a/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfiguration.java
+++ b/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfiguration.java
@@ -2,7 +2,7 @@ package org.openslx.virtualization.configuration;
import java.io.File;
import java.io.IOException;
-import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -12,14 +12,14 @@ import java.util.Map.Entry;
import org.apache.log4j.Logger;
import org.openslx.bwlp.thrift.iface.OperatingSystem;
+import org.openslx.virtualization.Version;
import org.openslx.virtualization.virtualizer.Virtualizer;
-import org.openslx.vm.disk.DiskImage;
/**
* Describes a configured virtual machine. This class is parsed from a machine
* description, like a *.vmx for VMware machines.
*/
-public abstract class VirtualizationConfiguration<T, U, V, W, X>
+public abstract class VirtualizationConfiguration<T, U, W, X>
{
private static final Logger LOGGER = Logger.getLogger( VirtualizationConfiguration.class );
@@ -28,7 +28,6 @@ public abstract class VirtualizationConfiguration<T, U, V, W, X>
*/
protected Map<SoundCardType, T> soundCards = new HashMap<>();
protected Map<DDAcceleration, U> ddacc = new HashMap<>();
- protected Map<HWVersion, V> hwversion = new HashMap<>();
protected Map<EthernetDevType, W> networkCards = new HashMap<>();
protected Map<UsbSpeed, X> usbSpeeds = new HashMap<>();
@@ -65,36 +64,6 @@ public abstract class VirtualizationConfiguration<T, U, V, W, X>
}
/**
- * Virtual hardware version - currently only in use for VMPlayer
- */
- public static enum HWVersion
- {
- NONE( "(invalid)" ),
- THREE( " 3 (Workstation 4/5, Player 1)" ),
- FOUR( " 4 (Workstation 4/5, Player 1/2, Fusion 1)" ),
- SIX( " 6 (Workstation 6)" ),
- SEVEN( " 7 (Workstation 6.5/7, Player 3, Fusion 2/3)" ),
- EIGHT( " 8 (Workstation 8, Player/Fusion 4)" ),
- NINE( " 9 (Workstation 9, Player/Fusion 5)" ),
- TEN( "10 (Workstation 10, Player/Fusion 6)" ),
- ELEVEN( "11 (Workstation 11, Player/Fusion 7)" ),
- TWELVE( "12 (Workstation/Player 12, Fusion 8)" ),
- FOURTEEN( "14 (Workstation/Player 14, Fusion 10)"),
- FIFTEEN( "15 (Workstation/Player 15, Fusion 11)"),
- FIFTEEN_ONE( "16 (Workstation/Player 15.1, Fusion 11.1)"),
- SIXTEEN( "17 (Workstation/Player 16, Fusion 12)"),
- SIXTEEN_ONE( "18 (Workstation/Player 16.1, Fusion 12.1)"),
- DEFAULT( "default" );
-
- public final String displayName;
-
- private HWVersion( String dName )
- {
- this.displayName = dName;
- }
- }
-
- /**
* Virtual network cards
*/
public static enum EthernetDevType
@@ -180,11 +149,11 @@ public abstract class VirtualizationConfiguration<T, U, V, W, X>
return availables;
}
- public List<HWVersion> getSupportedHWVersions()
+ public List<Version> getSupportedHWVersions()
{
- ArrayList<HWVersion> availables = new ArrayList<HWVersion>( hwversion.keySet() );
+ final List<Version> availables = this.getVirtualizer().getSupportedVersions();
Collections.sort( availables );
- return availables;
+ return Collections.unmodifiableList( availables );
}
public List<EthernetDevType> getSupportedEthernetDevices()
@@ -233,20 +202,6 @@ public abstract class VirtualizationConfiguration<T, U, V, W, X>
return isMachineSnapshot;
}
- /**
- * This method should return a minimal representation of the input meta data.
- * The representation is platform dependent, and should be stripped of all
- * non-essential configuration, such as CD/DVD/FLoppy drives, serial or parallel
- * ports, shared folders, or anything else that could be considered sensible
- * information (absolute paths containing the local user's name).
- */
- public abstract byte[] getFilteredDefinitionArray();
-
- public final ByteBuffer getFilteredDefinition()
- {
- return ByteBuffer.wrap( getFilteredDefinitionArray() );
- }
-
/*
* Methods
*/
@@ -291,20 +246,13 @@ public abstract class VirtualizationConfiguration<T, U, V, W, X>
}
/**
- * Returns list of image formats supported by the VM's hypervisor.
- *
- * @return list of image formats.
- */
- public abstract List<DiskImage.ImageFormat> getSupportedImageFormats();
-
- /**
* Returns a VmMetaData instance of the given machine description given as file
*
* @param osList List of supported operating systems
* @param file VM's machine description file to get the metadata instance from
* @return VmMetaData object representing the relevant parts of the given machine description
*/
- public static VirtualizationConfiguration<?, ?, ?, ?, ?> getInstance( List<OperatingSystem> osList, File file )
+ public static VirtualizationConfiguration<?, ?, ?, ?> getInstance( List<OperatingSystem> osList, File file )
throws IOException
{
try {
@@ -341,7 +289,7 @@ public abstract class VirtualizationConfiguration<T, U, V, W, X>
* @return VmMetaData object representing the relevant parts of the given machine description
* @throws IOException
*/
- public static VirtualizationConfiguration<?, ?, ?, ?, ?> getInstance( List<OperatingSystem> osList, byte[] vmContent, int length )
+ public static VirtualizationConfiguration<?, ?, ?, ?> getInstance( List<OperatingSystem> osList, byte[] vmContent, int length )
throws IOException
{
try {
@@ -402,9 +350,9 @@ public abstract class VirtualizationConfiguration<T, U, V, W, X>
public abstract DDAcceleration getDDAcceleration();
- public abstract void setHWVersion( HWVersion type );
+ public abstract void setVirtualizerVersion( Version type );
- public abstract HWVersion getHWVersion();
+ public abstract Version getVirtualizerVersion();
public abstract void setEthernetDevType( int cardIndex, EthernetDevType type );
@@ -414,7 +362,18 @@ public abstract class VirtualizationConfiguration<T, U, V, W, X>
public abstract UsbSpeed getMaxUsbSpeed();
- public abstract byte[] getDefinitionArray();
+ public abstract byte[] getConfigurationAsByteArray();
+
+ public String getConfigurationAsString()
+ {
+ return new String( this.getConfigurationAsByteArray(), StandardCharsets.UTF_8 );
+ }
+
+ @Override
+ public String toString()
+ {
+ return this.getConfigurationAsString();
+ }
public abstract boolean addEthernet( EtherType type );
@@ -451,7 +410,7 @@ public abstract class VirtualizationConfiguration<T, U, V, W, X>
public abstract void transformNonPersistent() throws VirtualizationConfigurationException;
/**
- * Function used to register virtual devices
+ * Function used to register virtual devices.
*/
public abstract void registerVirtualHW();
}
diff --git a/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationDocker.java b/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationDocker.java
index 3c21fe4..4c727a6 100644
--- a/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationDocker.java
+++ b/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationDocker.java
@@ -2,16 +2,13 @@ package org.openslx.virtualization.configuration;
import org.apache.log4j.Logger;
import org.openslx.bwlp.thrift.iface.OperatingSystem;
+import org.openslx.virtualization.Version;
import org.openslx.virtualization.virtualizer.VirtualizerDocker;
-import org.openslx.vm.disk.DiskImage;
-import org.openslx.vm.disk.DiskImage.ImageFormat;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
class DockerSoundCardMeta
@@ -22,10 +19,6 @@ class DockerDDAccelMeta
{
}
-class DockerHWVersionMeta
-{
-}
-
class DockerEthernetDevTypeMeta
{
}
@@ -34,19 +27,13 @@ class DockerUsbSpeedMeta
{
}
-public class VirtualizationConfigurationDocker extends VirtualizationConfiguration<DockerSoundCardMeta, DockerDDAccelMeta, DockerHWVersionMeta, DockerEthernetDevTypeMeta, DockerUsbSpeedMeta> {
+public class VirtualizationConfigurationDocker extends VirtualizationConfiguration<DockerSoundCardMeta, DockerDDAccelMeta, DockerEthernetDevTypeMeta, DockerUsbSpeedMeta> {
/**
* File name extension for Docker virtualization configuration files.
*/
- private static final String CONFIGURATION_FILE_NAME_EXTENSION = null;
-
- /**
- * List of supported image formats by the Docker hypervisor.
- */
- private static final List<DiskImage.ImageFormat> SUPPORTED_IMAGE_FORMATS = Collections.unmodifiableList(
- Arrays.asList( ImageFormat.NONE ) );
-
+ private static final String FILE_NAME_EXTENSION = null;
+
private static final Logger LOGGER = Logger.getLogger( VirtualizationConfigurationDocker.class);
/**
@@ -109,16 +96,6 @@ public class VirtualizationConfigurationDocker extends VirtualizationConfigurati
}
}
- @Override public byte[] getFilteredDefinitionArray() {
- return containerDefinition;
- }
-
- @Override
- public List<DiskImage.ImageFormat> getSupportedImageFormats()
- {
- return VirtualizationConfigurationDocker.SUPPORTED_IMAGE_FORMATS;
- }
-
@Override public void transformEditable() throws VirtualizationConfigurationException {
}
@@ -179,12 +156,12 @@ public class VirtualizationConfigurationDocker extends VirtualizationConfigurati
return DDAcceleration.OFF;
}
- @Override public void setHWVersion(HWVersion type) {
+ @Override public void setVirtualizerVersion(Version type) {
}
- @Override public HWVersion getHWVersion() {
- return HWVersion.DEFAULT;
+ @Override public Version getVirtualizerVersion() {
+ return null;
}
@Override public void setEthernetDevType(int cardIndex, EthernetDevType type) {
@@ -203,8 +180,8 @@ public class VirtualizationConfigurationDocker extends VirtualizationConfigurati
return UsbSpeed.NONE;
}
- @Override public byte[] getDefinitionArray() {
- return new byte[0];
+ @Override public byte[] getConfigurationAsByteArray() {
+ return this.containerDefinition;
}
@Override public boolean addEthernet(EtherType type) {
@@ -221,6 +198,6 @@ public class VirtualizationConfigurationDocker extends VirtualizationConfigurati
@Override
public String getFileNameExtension() {
- return VirtualizationConfigurationDocker.CONFIGURATION_FILE_NAME_EXTENSION;
+ return VirtualizationConfigurationDocker.FILE_NAME_EXTENSION;
}
}
diff --git a/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationQemu.java b/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationQemu.java
index 534f0e5..37186b9 100644
--- a/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationQemu.java
+++ b/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationQemu.java
@@ -4,8 +4,6 @@ import java.io.File;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;
@@ -25,9 +23,8 @@ import org.openslx.libvirt.domain.device.Video;
import org.openslx.libvirt.xml.LibvirtXmlDocumentException;
import org.openslx.libvirt.xml.LibvirtXmlSerializationException;
import org.openslx.libvirt.xml.LibvirtXmlValidationException;
+import org.openslx.virtualization.Version;
import org.openslx.virtualization.virtualizer.VirtualizerQemu;
-import org.openslx.vm.disk.DiskImage;
-import org.openslx.vm.disk.DiskImage.ImageFormat;
/**
* Metadata to describe the hardware type of a QEMU sound card.
@@ -98,40 +95,6 @@ class QemuDDAccelMeta
}
/**
- * Metadata to describe the version of a QEMU virtual machine configuration.
- *
- * @author Manuel Bentele
- * @version 1.0
- */
-class QemuHWVersionMeta
-{
- /**
- * Stores the version of a QEMU virtual machine configuration.
- */
- private final int version;
-
- /**
- * Creates metadata to describe the version of a QEMU virtual machine configuration.
- *
- * @param version version of the QEMU virtual machine configuration.
- */
- public QemuHWVersionMeta( int version )
- {
- this.version = version;
- }
-
- /**
- * Returns version of the QEMU virtual machine configuration.
- *
- * @return version of the QEMU virtual machine configuration.
- */
- public int getVersion()
- {
- return this.version;
- }
-}
-
-/**
* Metadata to describe the hardware type of a QEMU ethernet device.
*
* @author Manuel Bentele
@@ -223,7 +186,7 @@ class QemuUsbSpeedMeta
* @version 1.0
*/
public class VirtualizationConfigurationQemu extends
- VirtualizationConfiguration<QemuSoundCardMeta, QemuDDAccelMeta, QemuHWVersionMeta, QemuEthernetDevTypeMeta, QemuUsbSpeedMeta>
+ VirtualizationConfiguration<QemuSoundCardMeta, QemuDDAccelMeta, QemuEthernetDevTypeMeta, QemuUsbSpeedMeta>
{
/**
* Name of the network bridge for the LAN.
@@ -248,13 +211,7 @@ public class VirtualizationConfigurationQemu extends
/**
* File name extension for QEMU (Libvirt) virtualization configuration files.
*/
- private static final String CONFIGURATION_FILE_NAME_EXTENSION = ".xml";
-
- /**
- * List of supported image formats by the QEMU hypervisor.
- */
- private static final List<DiskImage.ImageFormat> SUPPORTED_IMAGE_FORMATS = Collections.unmodifiableList(
- Arrays.asList( ImageFormat.QCOW2, ImageFormat.VMDK, ImageFormat.VDI ) );
+ public static final String FILE_NAME_EXTENSION = "xml";
/**
* Libvirt XML configuration file to modify configuration of virtual machine for QEMU.
@@ -360,29 +317,13 @@ public class VirtualizationConfigurationQemu extends
}
@Override
- public byte[] getFilteredDefinitionArray()
+ public void transformEditable() throws VirtualizationConfigurationException
{
// removes all specified boot order entries
this.vmConfig.removeBootOrder();
// removes all source networks of all specified network interfaces
this.vmConfig.removeInterfaceDevicesSource();
-
- // output filtered Libvirt domain XML configuration
- String configuration = this.vmConfig.toString();
- return configuration.getBytes( StandardCharsets.UTF_8 );
- }
-
- @Override
- public List<DiskImage.ImageFormat> getSupportedImageFormats()
- {
- return VirtualizationConfigurationQemu.SUPPORTED_IMAGE_FORMATS;
- }
-
- @Override
- public void transformEditable() throws VirtualizationConfigurationException
- {
- // NOT implemented yet
}
@Override
@@ -668,13 +609,13 @@ public class VirtualizationConfigurationQemu extends
}
@Override
- public void setHWVersion( HWVersion type )
+ public void setVirtualizerVersion( Version type )
{
// NOT supported by the QEMU hypervisor
}
@Override
- public HWVersion getHWVersion()
+ public Version getVirtualizerVersion()
{
// NOT supported by the QEMU hypervisor
return null;
@@ -754,7 +695,7 @@ public class VirtualizationConfigurationQemu extends
}
@Override
- public byte[] getDefinitionArray()
+ public byte[] getConfigurationAsByteArray()
{
String configuration = this.vmConfig.toString();
@@ -859,8 +800,6 @@ public class VirtualizationConfigurationQemu extends
ddacc.put( VirtualizationConfiguration.DDAcceleration.OFF, new QemuDDAccelMeta( false ) );
ddacc.put( VirtualizationConfiguration.DDAcceleration.ON, new QemuDDAccelMeta( true ) );
- hwversion.put( VirtualizationConfiguration.HWVersion.DEFAULT, new QemuHWVersionMeta( 0 ) );
-
networkCards.put( VirtualizationConfiguration.EthernetDevType.NONE, new QemuEthernetDevTypeMeta( null ) );
networkCards.put( VirtualizationConfiguration.EthernetDevType.AUTO, new QemuEthernetDevTypeMeta( Interface.Model.VIRTIO_NET_PCI ) );
networkCards.put( VirtualizationConfiguration.EthernetDevType.PCNETPCI2, new QemuEthernetDevTypeMeta( Interface.Model.PCNET ) );
@@ -879,6 +818,6 @@ public class VirtualizationConfigurationQemu extends
@Override
public String getFileNameExtension()
{
- return VirtualizationConfigurationQemu.CONFIGURATION_FILE_NAME_EXTENSION;
+ return VirtualizationConfigurationQemu.FILE_NAME_EXTENSION;
}
}
diff --git a/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationVirtualBox.java b/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationVirtualBox.java
index 90b1879..d987495 100644
--- a/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationVirtualBox.java
+++ b/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationVirtualBox.java
@@ -6,7 +6,6 @@ import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
@@ -14,10 +13,9 @@ import java.util.UUID;
import org.apache.log4j.Logger;
import org.openslx.bwlp.thrift.iface.OperatingSystem;
import org.openslx.thrifthelper.TConst;
+import org.openslx.virtualization.Version;
import org.openslx.virtualization.configuration.VirtualizationConfigurationVirtualboxFileFormat.PlaceHolder;
import org.openslx.virtualization.virtualizer.VirtualizerVirtualBox;
-import org.openslx.vm.disk.DiskImage;
-import org.openslx.vm.disk.DiskImage.ImageFormat;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -45,16 +43,6 @@ class VBoxDDAccelMeta
}
}
-class VBoxHWVersionMeta
-{
- public final int version;
-
- public VBoxHWVersionMeta( int vers )
- {
- version = vers;
- }
-}
-
class VBoxEthernetDevTypeMeta
{
public final String value;
@@ -78,18 +66,12 @@ class VBoxUsbSpeedMeta
}
}
-public class VirtualizationConfigurationVirtualBox extends VirtualizationConfiguration<VBoxSoundCardMeta, VBoxDDAccelMeta, VBoxHWVersionMeta, VBoxEthernetDevTypeMeta, VBoxUsbSpeedMeta>
+public class VirtualizationConfigurationVirtualBox extends VirtualizationConfiguration<VBoxSoundCardMeta, VBoxDDAccelMeta, VBoxEthernetDevTypeMeta, VBoxUsbSpeedMeta>
{
/**
* File name extension for VirtualBox virtualization configuration files..
*/
- private static final String CONFIGURATION_FILE_NAME_EXTENSION = ".vbox";
-
- /**
- * List of supported image formats by the VirtualBox hypervisor.
- */
- private static final List<DiskImage.ImageFormat> SUPPORTED_IMAGE_FORMATS = Collections.unmodifiableList(
- Arrays.asList( ImageFormat.VDI ) );
+ public static final String FILE_NAME_EXTENSION = "vbox";
private static final Logger LOGGER = Logger.getLogger( VirtualizationConfigurationVirtualBox.class );
@@ -130,12 +112,6 @@ public class VirtualizationConfigurationVirtualBox extends VirtualizationConfigu
hdds.add( hardDisk );
}
}
-
- @Override
- public List<DiskImage.ImageFormat> getSupportedImageFormats()
- {
- return VirtualizationConfigurationVirtualBox.SUPPORTED_IMAGE_FORMATS;
- }
@Override
public void transformEditable() throws VirtualizationConfigurationException
@@ -150,15 +126,9 @@ public class VirtualizationConfigurationVirtualBox extends VirtualizationConfigu
}
@Override
- public byte[] getDefinitionArray()
+ public byte[] getConfigurationAsByteArray()
{
- return config.toString( false ).getBytes( StandardCharsets.UTF_8 );
- }
-
- @Override
- public byte[] getFilteredDefinitionArray()
- {
- return config.toString( false ).getBytes( StandardCharsets.UTF_8 );
+ return config.toString( true ).getBytes( StandardCharsets.UTF_8 );
}
@Override
@@ -384,15 +354,15 @@ public class VirtualizationConfigurationVirtualBox extends VirtualizationConfigu
* Virtual Box accepts per default only one hardware version and is hidden from the user
*/
@Override
- public void setHWVersion( HWVersion type )
+ public void setVirtualizerVersion( Version type )
{
}
@Override
- public VirtualizationConfiguration.HWVersion getHWVersion()
+ public Version getVirtualizerVersion()
{
// Virtual Box uses only one virtual hardware version and can't be changed
- return VirtualizationConfiguration.HWVersion.DEFAULT;
+ return null;
}
@Override
@@ -444,8 +414,6 @@ public class VirtualizationConfigurationVirtualBox extends VirtualizationConfigu
ddacc.put( VirtualizationConfiguration.DDAcceleration.OFF, new VBoxDDAccelMeta( false ) );
ddacc.put( VirtualizationConfiguration.DDAcceleration.ON, new VBoxDDAccelMeta( true ) );
- hwversion.put( VirtualizationConfiguration.HWVersion.DEFAULT, new VBoxHWVersionMeta( 0 ) );
-
// 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( VirtualizationConfiguration.EthernetDevType.NONE, new VBoxEthernetDevTypeMeta( false, "Am79C970A" ) );
networkCards.put( VirtualizationConfiguration.EthernetDevType.PCNETPCI2, new VBoxEthernetDevTypeMeta( true, "Am79C970A" ) );
@@ -538,6 +506,6 @@ public class VirtualizationConfigurationVirtualBox extends VirtualizationConfigu
@Override
public String getFileNameExtension()
{
- return VirtualizationConfigurationVirtualBox.CONFIGURATION_FILE_NAME_EXTENSION;
+ return VirtualizationConfigurationVirtualBox.FILE_NAME_EXTENSION;
}
}
diff --git a/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationVmware.java b/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationVmware.java
index 9f490d4..894f52b 100644
--- a/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationVmware.java
+++ b/src/main/java/org/openslx/virtualization/configuration/VirtualizationConfigurationVmware.java
@@ -3,8 +3,6 @@ package org.openslx.virtualization.configuration;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -16,10 +14,9 @@ import org.apache.log4j.Logger;
import org.openslx.bwlp.thrift.iface.OperatingSystem;
import org.openslx.thrifthelper.TConst;
import org.openslx.util.Util;
+import org.openslx.virtualization.Version;
import org.openslx.virtualization.configuration.VirtualizationConfigurationVmwareFileFormat.ConfigEntry;
import org.openslx.virtualization.virtualizer.VirtualizerVmware;
-import org.openslx.vm.disk.DiskImage;
-import org.openslx.vm.disk.DiskImage.ImageFormat;
class VmWareSoundCardMeta
{
@@ -43,16 +40,6 @@ class VmWareDDAccelMeta
}
}
-class VmWareHWVersionMeta
-{
- public final int version;
-
- public VmWareHWVersionMeta( int vers )
- {
- version = vers;
- }
-}
-
class VmWareEthernetDevTypeMeta
{
public final String value;
@@ -75,18 +62,12 @@ class VmwareUsbSpeed
}
}
-public class VirtualizationConfigurationVmware extends VirtualizationConfiguration<VmWareSoundCardMeta, VmWareDDAccelMeta, VmWareHWVersionMeta, VmWareEthernetDevTypeMeta, VmwareUsbSpeed>
+public class VirtualizationConfigurationVmware extends VirtualizationConfiguration<VmWareSoundCardMeta, VmWareDDAccelMeta, VmWareEthernetDevTypeMeta, VmwareUsbSpeed>
{
/**
* File name extension for VMware virtualization configuration files.
*/
- private static final String CONFIGURATION_FILE_NAME_EXTENSION = ".vmx";
-
- /**
- * List of supported image formats by the VMware hypervisor.
- */
- private static final List<DiskImage.ImageFormat> SUPPORTED_IMAGE_FORMATS = Collections.unmodifiableList(
- Arrays.asList( ImageFormat.VMDK ) );
+ public static final String FILE_NAME_EXTENSION = "vmx";
private static final Logger LOGGER = Logger.getLogger( VirtualizationConfigurationVmware.class );
@@ -256,12 +237,6 @@ public class VirtualizationConfigurationVmware extends VirtualizationConfigurati
device.present = Boolean.parseBoolean( value );
}
}
-
- @Override
- public List<DiskImage.ImageFormat> getSupportedImageFormats()
- {
- return VirtualizationConfigurationVmware.SUPPORTED_IMAGE_FORMATS;
- }
@Override
public boolean addHddTemplate( File diskImage, String hddMode, String redoDir )
@@ -440,17 +415,11 @@ public class VirtualizationConfigurationVmware extends VirtualizationConfigurati
setOs( TConst.VIRT_VMWARE, vendorOsId );
}
- @Override
- public byte[] getFilteredDefinitionArray()
+ public byte[] getConfigurationAsByteArray()
{
return config.toString( true, false ).getBytes( StandardCharsets.UTF_8 );
}
- public byte[] getDefinitionArray()
- {
- return config.toString( false, false ).getBytes( StandardCharsets.UTF_8 );
- }
-
private static class Device
{
public boolean present = false;
@@ -534,26 +503,15 @@ public class VirtualizationConfigurationVmware extends VirtualizationConfigurati
}
}
- public void setHWVersion( VirtualizationConfiguration.HWVersion type )
+ public void setVirtualizerVersion( Version type )
{
- VmWareHWVersionMeta hwVersionMeta = hwversion.get( type );
- addFiltered( "virtualHW.version", vmInteger( hwVersionMeta.version ) );
+ addFiltered( "virtualHW.version", vmInteger( type.getMajor() ) );
}
- public VirtualizationConfiguration.HWVersion getHWVersion()
+ public Version getVirtualizerVersion()
{
- int currentValue = Util.parseInt( config.get( "virtualHW.version" ), -1 );
- VmWareHWVersionMeta hwVersionMeta = null;
- for ( VirtualizationConfiguration.HWVersion ver : VirtualizationConfiguration.HWVersion.values() ) {
- hwVersionMeta = hwversion.get( ver );
- if ( hwVersionMeta == null ) {
- continue;
- }
- if ( currentValue == hwVersionMeta.version ) {
- return ver;
- }
- }
- return HWVersion.NONE;
+ final short major = Integer.valueOf( Util.parseInt( config.get( "virtualHW.version" ), -1 ) ).shortValue();
+ return Version.getInstanceByMajorFromVersions( major, this.getVirtualizer().getSupportedVersions() );
}
public void setEthernetDevType( int cardIndex, VirtualizationConfiguration.EthernetDevType type )
@@ -644,37 +602,24 @@ public class VirtualizationConfigurationVmware extends VirtualizationConfigurati
{
soundCards.put( VirtualizationConfiguration.SoundCardType.NONE, new VmWareSoundCardMeta( false, null ) );
soundCards.put( VirtualizationConfiguration.SoundCardType.DEFAULT, new VmWareSoundCardMeta( true, null ) );
- soundCards.put( VirtualizationConfiguration.SoundCardType.SOUND_BLASTER, new VmWareSoundCardMeta( true, "sb16" ) );
+ soundCards.put( VirtualizationConfiguration.SoundCardType.SOUND_BLASTER,
+ new VmWareSoundCardMeta( true, "sb16" ) );
soundCards.put( VirtualizationConfiguration.SoundCardType.ES, new VmWareSoundCardMeta( true, "es1371" ) );
soundCards.put( VirtualizationConfiguration.SoundCardType.HD_AUDIO, new VmWareSoundCardMeta( true, "hdaudio" ) );
ddacc.put( VirtualizationConfiguration.DDAcceleration.OFF, new VmWareDDAccelMeta( false ) );
ddacc.put( VirtualizationConfiguration.DDAcceleration.ON, new VmWareDDAccelMeta( true ) );
- hwversion.put( VirtualizationConfiguration.HWVersion.NONE, new VmWareHWVersionMeta( 0 ) );
- hwversion.put( VirtualizationConfiguration.HWVersion.THREE, new VmWareHWVersionMeta( 3 ) );
- hwversion.put( VirtualizationConfiguration.HWVersion.FOUR, new VmWareHWVersionMeta( 4 ) );
- hwversion.put( VirtualizationConfiguration.HWVersion.SIX, new VmWareHWVersionMeta( 6 ) );
- hwversion.put( VirtualizationConfiguration.HWVersion.SEVEN, new VmWareHWVersionMeta( 7 ) );
- hwversion.put( VirtualizationConfiguration.HWVersion.EIGHT, new VmWareHWVersionMeta( 8 ) );
- hwversion.put( VirtualizationConfiguration.HWVersion.NINE, new VmWareHWVersionMeta( 9 ) );
- hwversion.put( VirtualizationConfiguration.HWVersion.TEN, new VmWareHWVersionMeta( 10 ) );
- hwversion.put( VirtualizationConfiguration.HWVersion.ELEVEN, new VmWareHWVersionMeta( 11 ) );
- hwversion.put( VirtualizationConfiguration.HWVersion.TWELVE, new VmWareHWVersionMeta( 12 ) );
- hwversion.put( VirtualizationConfiguration.HWVersion.FOURTEEN, new VmWareHWVersionMeta( 14 ) );
- hwversion.put( VirtualizationConfiguration.HWVersion.FIFTEEN, new VmWareHWVersionMeta( 15 ) );
- hwversion.put( VirtualizationConfiguration.HWVersion.FIFTEEN_ONE, new VmWareHWVersionMeta( 16 ) );
- hwversion.put( VirtualizationConfiguration.HWVersion.SIXTEEN, new VmWareHWVersionMeta( 17 ) );
- hwversion.put( VirtualizationConfiguration.HWVersion.SIXTEEN_ONE, new VmWareHWVersionMeta( 18 ) );
-
networkCards.put( VirtualizationConfiguration.EthernetDevType.AUTO, new VmWareEthernetDevTypeMeta( null ) );
- networkCards.put( VirtualizationConfiguration.EthernetDevType.PCNET32, new VmWareEthernetDevTypeMeta( "vlance" ) );
+ networkCards.put( VirtualizationConfiguration.EthernetDevType.PCNET32,
+ new VmWareEthernetDevTypeMeta( "vlance" ) );
networkCards.put( VirtualizationConfiguration.EthernetDevType.E1000, new VmWareEthernetDevTypeMeta( "e1000" ) );
networkCards.put( VirtualizationConfiguration.EthernetDevType.E1000E, new VmWareEthernetDevTypeMeta( "e1000e" ) );
networkCards.put( VirtualizationConfiguration.EthernetDevType.VMXNET, new VmWareEthernetDevTypeMeta( "vmxnet" ) );
- networkCards.put( VirtualizationConfiguration.EthernetDevType.VMXNET3, new VmWareEthernetDevTypeMeta( "vmxnet3" ) );
-
- usbSpeeds.put( VirtualizationConfiguration.UsbSpeed.NONE, new VmwareUsbSpeed( 0, null ));
+ networkCards.put( VirtualizationConfiguration.EthernetDevType.VMXNET3,
+ new VmWareEthernetDevTypeMeta( "vmxnet3" ) );
+
+ usbSpeeds.put( VirtualizationConfiguration.UsbSpeed.NONE, new VmwareUsbSpeed( 0, null ) );
usbSpeeds.put( VirtualizationConfiguration.UsbSpeed.USB1_1, new VmwareUsbSpeed( 1, "usb" ) );
usbSpeeds.put( VirtualizationConfiguration.UsbSpeed.USB2_0, new VmwareUsbSpeed( 2, "ehci" ) );
usbSpeeds.put( VirtualizationConfiguration.UsbSpeed.USB3_0, new VmwareUsbSpeed( 3, "usb_xhci" ) );
@@ -683,7 +628,7 @@ public class VirtualizationConfigurationVmware extends VirtualizationConfigurati
@Override
public String getFileNameExtension()
{
- return VirtualizationConfigurationVmware.CONFIGURATION_FILE_NAME_EXTENSION;
+ return VirtualizationConfigurationVmware.FILE_NAME_EXTENSION;
}
}
diff --git a/src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogic.java b/src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogic.java
index 5bfbf8f..1aac943 100644
--- a/src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogic.java
+++ b/src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogic.java
@@ -3,7 +3,7 @@ package org.openslx.virtualization.configuration.logic;
import org.openslx.virtualization.configuration.VirtualizationConfiguration;
import org.openslx.virtualization.configuration.transformation.TransformationGeneric;
-public abstract class ConfigurationLogic<T> extends TransformationGeneric<VirtualizationConfiguration<?, ?, ?, ?, ?>, T>
+public abstract class ConfigurationLogic<T> extends TransformationGeneric<VirtualizationConfiguration<?, ?, ?, ?>, T>
{
public ConfigurationLogic( String name )
{
diff --git a/src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModClientToDozModServer.java b/src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModClientToDozModServer.java
index 76a845f..ca25aa3 100644
--- a/src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModClientToDozModServer.java
+++ b/src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModClientToDozModServer.java
@@ -15,7 +15,7 @@ public class ConfigurationLogicDozModClientToDozModServer
super( ConfigurationLogicDozModClientToDozModServer.CONFIGURATION_LOGIC_NAME );
}
- private void validateInputs( VirtualizationConfiguration<?, ?, ?, ?, ?> config,
+ private void validateInputs( VirtualizationConfiguration<?, ?, ?, ?> config,
ConfigurationDataDozModClientToDozModServer args )
throws TransformationException
{
@@ -27,7 +27,7 @@ public class ConfigurationLogicDozModClientToDozModServer
}
@Override
- public void transform( VirtualizationConfiguration<?, ?, ?, ?, ?> config,
+ public void transform( VirtualizationConfiguration<?, ?, ?, ?> config,
ConfigurationDataDozModClientToDozModServer args )
throws TransformationException
{
diff --git a/src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToDozModClient.java b/src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToDozModClient.java
index fa3a505..6d8687f 100644
--- a/src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToDozModClient.java
+++ b/src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToDozModClient.java
@@ -22,7 +22,7 @@ public class ConfigurationLogicDozModServerToDozModClient
super( ConfigurationLogicDozModServerToDozModClient.CONFIGURATION_LOGIC_NAME );
}
- private void validateInputs( VirtualizationConfiguration<?, ?, ?, ?, ?> config,
+ private void validateInputs( VirtualizationConfiguration<?, ?, ?, ?> config,
ConfigurationDataDozModServerToDozModClient args )
throws TransformationException
{
@@ -62,7 +62,7 @@ public class ConfigurationLogicDozModServerToDozModClient
}
@Override
- public void transform( VirtualizationConfiguration<?, ?, ?, ?, ?> config,
+ public void transform( VirtualizationConfiguration<?, ?, ?, ?> config,
ConfigurationDataDozModServerToDozModClient args )
throws TransformationException
{
diff --git a/src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToStatelessClient.java b/src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToStatelessClient.java
index 4c20b1f..8697df1 100644
--- a/src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToStatelessClient.java
+++ b/src/main/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToStatelessClient.java
@@ -19,7 +19,7 @@ public class ConfigurationLogicDozModServerToStatelessClient
super( ConfigurationLogicDozModServerToStatelessClient.CONFIGURATION_LOGIC_NAME );
}
- private void validateInputs( VirtualizationConfiguration<?, ?, ?, ?, ?> config,
+ private void validateInputs( VirtualizationConfiguration<?, ?, ?, ?> config,
ConfigurationDataDozModServerToStatelessClient args )
throws TransformationException
{
@@ -31,7 +31,7 @@ public class ConfigurationLogicDozModServerToStatelessClient
}
@Override
- public void transform( VirtualizationConfiguration<?, ?, ?, ?, ?> config,
+ public void transform( VirtualizationConfiguration<?, ?, ?, ?> config,
ConfigurationDataDozModServerToStatelessClient args )
throws TransformationException
{
diff --git a/src/main/java/org/openslx/virtualization/virtualizer/Virtualizer.java b/src/main/java/org/openslx/virtualization/virtualizer/Virtualizer.java
index e74d15e..ac3a4ec 100644
--- a/src/main/java/org/openslx/virtualization/virtualizer/Virtualizer.java
+++ b/src/main/java/org/openslx/virtualization/virtualizer/Virtualizer.java
@@ -2,6 +2,7 @@ package org.openslx.virtualization.virtualizer;
import java.util.List;
+import org.openslx.virtualization.Version;
import org.openslx.vm.disk.DiskImage.ImageFormat;
/**
@@ -57,4 +58,11 @@ public abstract class Virtualizer
* @return list of supported disk image formats by the virtualizer.
*/
public abstract List<ImageFormat> getSupportedImageFormats();
+
+ /**
+ * Returns a list of supported versions of the virtualizer.
+ *
+ * @return list of supported versions of the virtualizer.
+ */
+ public abstract List<Version> getSupportedVersions();
}
diff --git a/src/main/java/org/openslx/virtualization/virtualizer/VirtualizerDocker.java b/src/main/java/org/openslx/virtualization/virtualizer/VirtualizerDocker.java
index 4461595..673447b 100644
--- a/src/main/java/org/openslx/virtualization/virtualizer/VirtualizerDocker.java
+++ b/src/main/java/org/openslx/virtualization/virtualizer/VirtualizerDocker.java
@@ -5,6 +5,7 @@ import java.util.Collections;
import java.util.List;
import org.openslx.thrifthelper.TConst;
+import org.openslx.virtualization.Version;
import org.openslx.vm.disk.DiskImage;
import org.openslx.vm.disk.DiskImage.ImageFormat;
@@ -28,11 +29,16 @@ public class VirtualizerDocker extends Virtualizer
.unmodifiableList( Arrays.asList( ImageFormat.NONE ) );
/**
+ * List of supported versions of the Docker virtualizer.
+ */
+ private static final List<Version> VIRTUALIZER_SUPPORTED_VERSIONS = null;
+
+ /**
* Creates a new Docker virtualizer.
*/
public VirtualizerDocker()
{
- super( new org.openslx.bwlp.thrift.iface.Virtualizer( TConst.VIRT_DOCKER, VirtualizerDocker.VIRTUALIZER_NAME ));
+ super( new org.openslx.bwlp.thrift.iface.Virtualizer( TConst.VIRT_DOCKER, VirtualizerDocker.VIRTUALIZER_NAME ) );
}
@Override
@@ -40,4 +46,10 @@ public class VirtualizerDocker extends Virtualizer
{
return VirtualizerDocker.VIRTUALIZER_SUPPORTED_IMAGE_FORMATS;
}
+
+ @Override
+ public List<Version> getSupportedVersions()
+ {
+ return VirtualizerDocker.VIRTUALIZER_SUPPORTED_VERSIONS;
+ }
}
diff --git a/src/main/java/org/openslx/virtualization/virtualizer/VirtualizerQemu.java b/src/main/java/org/openslx/virtualization/virtualizer/VirtualizerQemu.java
index 731209b..4456538 100644
--- a/src/main/java/org/openslx/virtualization/virtualizer/VirtualizerQemu.java
+++ b/src/main/java/org/openslx/virtualization/virtualizer/VirtualizerQemu.java
@@ -5,6 +5,7 @@ import java.util.Collections;
import java.util.List;
import org.openslx.thrifthelper.TConst;
+import org.openslx.virtualization.Version;
import org.openslx.vm.disk.DiskImage;
import org.openslx.vm.disk.DiskImage.ImageFormat;
@@ -28,6 +29,11 @@ public class VirtualizerQemu extends Virtualizer
.unmodifiableList( Arrays.asList( ImageFormat.QCOW2, ImageFormat.VMDK, ImageFormat.VDI ) );
/**
+ * List of supported versions of the QEMU virtualizer.
+ */
+ private static final List<Version> VIRTUALIZER_SUPPORTED_VERSIONS = null;
+
+ /**
* Creates a new QEMU virtualizer.
*/
public VirtualizerQemu()
@@ -40,4 +46,10 @@ public class VirtualizerQemu extends Virtualizer
{
return VirtualizerQemu.VIRTUALIZER_SUPPORTED_IMAGE_FORMATS;
}
+
+ @Override
+ public List<Version> getSupportedVersions()
+ {
+ return VirtualizerQemu.VIRTUALIZER_SUPPORTED_VERSIONS;
+ }
}
diff --git a/src/main/java/org/openslx/virtualization/virtualizer/VirtualizerVirtualBox.java b/src/main/java/org/openslx/virtualization/virtualizer/VirtualizerVirtualBox.java
index 77662ab..6be7cbf 100644
--- a/src/main/java/org/openslx/virtualization/virtualizer/VirtualizerVirtualBox.java
+++ b/src/main/java/org/openslx/virtualization/virtualizer/VirtualizerVirtualBox.java
@@ -5,6 +5,7 @@ import java.util.Collections;
import java.util.List;
import org.openslx.thrifthelper.TConst;
+import org.openslx.virtualization.Version;
import org.openslx.vm.disk.DiskImage;
import org.openslx.vm.disk.DiskImage.ImageFormat;
@@ -28,6 +29,11 @@ public class VirtualizerVirtualBox extends Virtualizer
.unmodifiableList( Arrays.asList( ImageFormat.VDI ) );
/**
+ * List of supported version of the VirtualBox virtualizer.
+ */
+ private static final List<Version> VIRTUALIZER_SUPPORTED_VERSIONS = null;
+
+ /**
* Creates a new VirtualBox virtualizer.
*/
public VirtualizerVirtualBox()
@@ -41,4 +47,10 @@ public class VirtualizerVirtualBox extends Virtualizer
{
return VirtualizerVirtualBox.VIRTUALIZER_SUPPORTED_IMAGE_FORMATS;
}
+
+ @Override
+ public List<Version> getSupportedVersions()
+ {
+ return VirtualizerVirtualBox.VIRTUALIZER_SUPPORTED_VERSIONS;
+ }
}
diff --git a/src/main/java/org/openslx/virtualization/virtualizer/VirtualizerVmware.java b/src/main/java/org/openslx/virtualization/virtualizer/VirtualizerVmware.java
index 7b766eb..6e676f3 100644
--- a/src/main/java/org/openslx/virtualization/virtualizer/VirtualizerVmware.java
+++ b/src/main/java/org/openslx/virtualization/virtualizer/VirtualizerVmware.java
@@ -5,6 +5,7 @@ import java.util.Collections;
import java.util.List;
import org.openslx.thrifthelper.TConst;
+import org.openslx.virtualization.Version;
import org.openslx.vm.disk.DiskImage;
import org.openslx.vm.disk.DiskImage.ImageFormat;
@@ -28,6 +29,26 @@ public class VirtualizerVmware extends Virtualizer
.unmodifiableList( Arrays.asList( ImageFormat.VMDK ) );
/**
+ * List of supported versions of the VMware virtualizer.
+ */
+ private static final List<Version> VIRTUALIZER_SUPPORTED_VERSIONS = Collections.unmodifiableList(
+ Arrays.asList(
+ new Version( Short.valueOf( "03" ), "Workstation 4/5, Player 1" ),
+ new Version( Short.valueOf( "04" ), "Workstation 4/5, Player 1/2, Fusion 1" ),
+ new Version( Short.valueOf( "06" ), "Workstation 6" ),
+ new Version( Short.valueOf( "07" ), "Workstation 6.5/7, Player 3, Fusion 2/3" ),
+ new Version( Short.valueOf( "08" ), "Workstation 8, Player/Fusion 4" ),
+ new Version( Short.valueOf( "09" ), "Workstation 9, Player/Fusion 5" ),
+ new Version( Short.valueOf( "10" ), "Workstation 10, Player/Fusion 6" ),
+ new Version( Short.valueOf( "11" ), "Workstation 11, Player/Fusion 7" ),
+ new Version( Short.valueOf( "12" ), "Workstation/Player 12, Fusion 8" ),
+ new Version( Short.valueOf( "14" ), "Workstation/Player 14, Fusion 10" ),
+ new Version( Short.valueOf( "15" ), "Workstation/Player 15, Fusion 11" ),
+ new Version( Short.valueOf( "16" ), "Workstation/Player 15.1, Fusion 11.1" ),
+ new Version( Short.valueOf( "17" ), "Workstation/Player 16, Fusion 12" ),
+ new Version( Short.valueOf( "18" ), "Workstation/Player 16.1, Fusion 12.1" ) ) );
+
+ /**
* Creates a new VMware virtualizer.
*/
public VirtualizerVmware()
@@ -40,4 +61,11 @@ public class VirtualizerVmware extends Virtualizer
{
return VirtualizerVmware.VIRTUALIZER_SUPPORTED_IMAGE_FORMATS;
}
+
+ @Override
+ public List<Version> getSupportedVersions()
+ {
+ return VirtualizerVmware.VIRTUALIZER_SUPPORTED_VERSIONS;
+ }
+
}
diff --git a/src/main/java/org/openslx/vm/disk/DiskImage.java b/src/main/java/org/openslx/vm/disk/DiskImage.java
index 38964f4..309ad77 100644
--- a/src/main/java/org/openslx/vm/disk/DiskImage.java
+++ b/src/main/java/org/openslx/vm/disk/DiskImage.java
@@ -9,6 +9,7 @@ import java.util.function.Predicate;
import org.openslx.bwlp.thrift.iface.Virtualizer;
import org.openslx.thrifthelper.TConst;
+import org.openslx.virtualization.Version;
/**
* Disk image for virtual machines.
@@ -103,7 +104,7 @@ public abstract class DiskImage
*
* @throws DiskImageException unable to obtain version of the disk image format.
*/
- public abstract int getVersion() throws DiskImageException;
+ public abstract Version getVersion() throws DiskImageException;
/**
* Returns the disk image description.
diff --git a/src/main/java/org/openslx/vm/disk/DiskImageQcow2.java b/src/main/java/org/openslx/vm/disk/DiskImageQcow2.java
index 5f72a00..04e61ea 100644
--- a/src/main/java/org/openslx/vm/disk/DiskImageQcow2.java
+++ b/src/main/java/org/openslx/vm/disk/DiskImageQcow2.java
@@ -5,6 +5,8 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
+import org.openslx.virtualization.Version;
+
/**
* QCOW2 disk image for virtual machines.
*
@@ -120,7 +122,7 @@ public class DiskImageQcow2 extends DiskImage
// check if QCOW2 image uses extended L2 tables
// extended L2 tables are only possible in QCOW2 version 3 header format
- if ( this.getVersion() >= 3 ) {
+ if ( this.getVersion().getMajor() >= Short.valueOf( "3" ) ) {
// read incompatible feature bits
final long qcowIncompatibleFeatures = DiskImageUtils.readLong( diskFile, 72 );
@@ -216,7 +218,7 @@ public class DiskImageQcow2 extends DiskImage
}
@Override
- public int getVersion() throws DiskImageException
+ public Version getVersion() throws DiskImageException
{
final RandomAccessFile diskFile = this.getDiskImage();
final int qcowVersion = DiskImageUtils.readInt( diskFile, 4 );
@@ -228,7 +230,7 @@ public class DiskImageQcow2 extends DiskImage
throw new DiskImageException( errorMsg );
}
- return DiskImageUtils.versionFromMajor( Integer.valueOf( qcowVersion ).shortValue() );
+ return new Version( Integer.valueOf( qcowVersion ).shortValue() );
}
@Override
diff --git a/src/main/java/org/openslx/vm/disk/DiskImageUtils.java b/src/main/java/org/openslx/vm/disk/DiskImageUtils.java
index e704b74..cc29721 100644
--- a/src/main/java/org/openslx/vm/disk/DiskImageUtils.java
+++ b/src/main/java/org/openslx/vm/disk/DiskImageUtils.java
@@ -141,24 +141,4 @@ public class DiskImageUtils
return new String( values );
}
-
- public static int versionFromMajorMinor( final short major, final short minor )
- {
- return ( ( Integer.valueOf( major ) << 16 ) | minor );
- }
-
- public static int versionFromMajor( final short major )
- {
- return DiskImageUtils.versionFromMajorMinor( major, Short.valueOf( "0" ) );
- }
-
- public static short versionToMajor( final int version )
- {
- return Integer.valueOf( version >> 16 ).shortValue();
- }
-
- public static short versionToMinor( final int version )
- {
- return Integer.valueOf( version & 0x0000FFFF ).shortValue();
- }
}
diff --git a/src/main/java/org/openslx/vm/disk/DiskImageVdi.java b/src/main/java/org/openslx/vm/disk/DiskImageVdi.java
index 1c34c1d..16db956 100644
--- a/src/main/java/org/openslx/vm/disk/DiskImageVdi.java
+++ b/src/main/java/org/openslx/vm/disk/DiskImageVdi.java
@@ -5,6 +5,8 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
+import org.openslx.virtualization.Version;
+
/**
* VDI disk image for virtual machines.
*
@@ -94,14 +96,14 @@ public class DiskImageVdi extends DiskImage
}
@Override
- public int getVersion() throws DiskImageException
+ public Version getVersion() throws DiskImageException
{
final RandomAccessFile diskFile = this.getDiskImage();
final short vdiVersionMajor = Short.reverseBytes( DiskImageUtils.readShort( diskFile, 68 ) );
final short vdiVersionMinor = Short.reverseBytes( DiskImageUtils.readShort( diskFile, 70 ) );
- return DiskImageUtils.versionFromMajorMinor( vdiVersionMajor, vdiVersionMinor );
+ return new Version( vdiVersionMajor, vdiVersionMinor );
}
@Override
diff --git a/src/main/java/org/openslx/vm/disk/DiskImageVmdk.java b/src/main/java/org/openslx/vm/disk/DiskImageVmdk.java
index 1f475d9..7f59bc3 100644
--- a/src/main/java/org/openslx/vm/disk/DiskImageVmdk.java
+++ b/src/main/java/org/openslx/vm/disk/DiskImageVmdk.java
@@ -7,6 +7,7 @@ import java.io.RandomAccessFile;
import org.openslx.util.Util;
import org.openslx.virtualization.configuration.VirtualizationConfigurationVmwareFileFormat;
+import org.openslx.virtualization.Version;
import org.openslx.virtualization.configuration.VirtualizationConfigurationException;
/**
@@ -184,10 +185,10 @@ public class DiskImageVmdk extends DiskImage
*
* @throws DiskImageException
*/
- public int getHwVersion() throws DiskImageException
+ public Version getHwVersion() throws DiskImageException
{
final VirtualizationConfigurationVmwareFileFormat vmdkConfig = this.getVmdkConfig();
- final int hwVersion;
+ final Version hwVersion;
if ( vmdkConfig != null ) {
// VMDK image contains a hardware version, so return parsed hardware version
@@ -195,11 +196,11 @@ public class DiskImageVmdk extends DiskImage
final String hwVersionStr = vmdkConfig.get( "ddb.virtualHWVersion" );
final int hwVersionMajor = Util.parseInt( hwVersionStr, DiskImageVmdk.VMDK_DEFAULT_HW_VERSION );
- hwVersion = DiskImageUtils.versionFromMajor( Integer.valueOf( hwVersionMajor ).shortValue() );
+ hwVersion = new Version( Integer.valueOf( hwVersionMajor ).shortValue() );
} else {
// VMDK image does not contain any hardware version, so return default hardware version
final int hwVersionMajor = DiskImageVmdk.VMDK_DEFAULT_HW_VERSION;
- hwVersion = DiskImageUtils.versionFromMajor( Integer.valueOf( hwVersionMajor ).shortValue() );
+ hwVersion = new Version( Integer.valueOf( hwVersionMajor ).shortValue() );
}
return hwVersion;
@@ -276,12 +277,12 @@ public class DiskImageVmdk extends DiskImage
}
@Override
- public int getVersion() throws DiskImageException
+ public Version getVersion() throws DiskImageException
{
final RandomAccessFile diskFile = this.getDiskImage();
final int vmdkVersion = Integer.reverseBytes( DiskImageUtils.readInt( diskFile, 4 ) );
- return DiskImageUtils.versionFromMajor( Integer.valueOf( vmdkVersion ).shortValue() );
+ return new Version( Integer.valueOf( vmdkVersion ).shortValue() );
}
@Override
diff --git a/src/test/java/org/openslx/virtualization/VersionTest.java b/src/test/java/org/openslx/virtualization/VersionTest.java
new file mode 100644
index 0000000..c1ad21b
--- /dev/null
+++ b/src/test/java/org/openslx/virtualization/VersionTest.java
@@ -0,0 +1,98 @@
+package org.openslx.virtualization;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class VersionTest
+{
+ @Test
+ @DisplayName( "Test that version is supported in list of versions" )
+ public void testVersionIsSupported()
+ {
+ final Version version = new Version( Short.valueOf( "2" ), Short.valueOf( "3" ) );
+ final List<Version> versions = Collections.unmodifiableList( Arrays.asList(
+ new Version( Short.valueOf( "2" ) ),
+ new Version( Short.valueOf( "4" ), Short.valueOf( "3" ) ),
+ new Version( Short.valueOf( "2" ), Short.valueOf( "3" ) ),
+ new Version( Short.valueOf( "1" ), Short.valueOf( "3" ) ) ) );
+
+ assertTrue( version.isSupported( versions ) );
+ }
+
+ @Test
+ @DisplayName( "Test that version is not supported in list of versions" )
+ public void testVersionIsNotSupported()
+ {
+ final Version version = new Version( Short.valueOf( "2" ), Short.valueOf( "3" ) );
+ final List<Version> versions = Collections.unmodifiableList( Arrays.asList(
+ new Version( Short.valueOf( "2" ) ),
+ new Version( Short.valueOf( "4" ), Short.valueOf( "3" ) ),
+ new Version( Short.valueOf( "6" ), Short.valueOf( "9" ) ),
+ new Version( Short.valueOf( "1" ), Short.valueOf( "3" ) ) ) );
+
+ assertFalse( version.isSupported( versions ) );
+ }
+
+ @Test
+ @DisplayName( "Test that versions are equal" )
+ public void testVersionEquals()
+ {
+ final Version versionOne = new Version( Short.valueOf( "2" ), Short.valueOf( "3" ) );
+ final Version versionTwo = new Version( Short.valueOf( "2" ), Short.valueOf( "3" ) );
+
+ assertTrue( versionOne.equals( versionTwo ) );
+ assertTrue( versionTwo.equals( versionOne ) );
+ }
+
+ @Test
+ @DisplayName( "Test that versions are not equal" )
+ public void testVersionNotEquals()
+ {
+ final Version versionOne = new Version( Short.valueOf( "3" ), Short.valueOf( "2" ) );
+ final Version versionTwo = new Version( Short.valueOf( "3" ), Short.valueOf( "3" ) );
+
+ assertFalse( versionOne.equals( versionTwo ) );
+ assertFalse( versionTwo.equals( versionOne ) );
+ }
+
+ @Test
+ @DisplayName( "Test that version is smaller than" )
+ public void testVersionSmallerThan()
+ {
+ final Version versionOne = new Version( Short.valueOf( "2" ), Short.valueOf( "3" ) );
+ final Version versionTwo = new Version( Short.valueOf( "3" ), Short.valueOf( "2" ) );
+
+ assertEquals( -1, versionOne.compareTo( versionTwo ) );
+ assertEquals( 1, versionTwo.compareTo( versionOne ) );
+ }
+
+ @Test
+ @DisplayName( "Test that version is larger than" )
+ public void testVersionLargerThan()
+ {
+ final Version versionOne = new Version( Short.valueOf( "3" ), Short.valueOf( "3" ) );
+ final Version versionTwo = new Version( Short.valueOf( "3" ), Short.valueOf( "2" ) );
+
+ assertEquals( 1, versionOne.compareTo( versionTwo ) );
+ assertEquals( -1, versionTwo.compareTo( versionOne ) );
+ }
+
+ @Test
+ @DisplayName( "Test that versions are equal (compareTo)" )
+ public void testVersionEqualCompareTo()
+ {
+ final Version versionOne = new Version( Short.valueOf( "2" ), Short.valueOf( "3" ) );
+ final Version versionTwo = new Version( Short.valueOf( "2" ), Short.valueOf( "3" ) );
+
+ assertEquals( 0, versionOne.compareTo( versionTwo ) );
+ assertEquals( 0, versionTwo.compareTo( versionOne ) );
+ }
+}
diff --git a/src/test/java/org/openslx/virtualization/configuration/VirtualizationConfigurationQemuTest.java b/src/test/java/org/openslx/virtualization/configuration/VirtualizationConfigurationQemuTest.java
index fe82a53..0412002 100644
--- a/src/test/java/org/openslx/virtualization/configuration/VirtualizationConfigurationQemuTest.java
+++ b/src/test/java/org/openslx/virtualization/configuration/VirtualizationConfigurationQemuTest.java
@@ -107,7 +107,7 @@ public class VirtualizationConfigurationQemuTest
final Domain vmLibvirtDomainConfig = VirtualizationConfigurationQemuTest
.getPrivateDomainFromQemuMetaData( vmConfig );
- final List<DiskImage.ImageFormat> supportedImageFormats = vmConfig.getSupportedImageFormats();
+ final List<DiskImage.ImageFormat> supportedImageFormats = vmConfig.getVirtualizer().getSupportedImageFormats();
assertNotNull( supportedImageFormats );
assertEquals( 3, supportedImageFormats.size() );
@@ -150,9 +150,7 @@ public class VirtualizationConfigurationQemuTest
final Domain vmLibvirtDomainConfig = VirtualizationConfigurationQemuTest
.getPrivateDomainFromQemuMetaData( vmConfig );
- final int numberOfDeletedElements = 1;
-
- final String unfilteredXmlConfig = new String( vmConfig.getDefinitionArray(), StandardCharsets.UTF_8 );
+ final String unfilteredXmlConfig = new String( vmConfig.getConfigurationAsByteArray(), StandardCharsets.UTF_8 );
final String originalXmlConfig = FileUtils.readFileToString( file, StandardCharsets.UTF_8 );
assertNotNull( unfilteredXmlConfig );
@@ -160,34 +158,7 @@ public class VirtualizationConfigurationQemuTest
final int lengthUnfilteredXmlConfig = unfilteredXmlConfig.split( System.lineSeparator() ).length;
final int lengthOriginalXmlConfig = originalXmlConfig.split( System.lineSeparator() ).length;
- assertEquals( lengthOriginalXmlConfig, lengthUnfilteredXmlConfig + numberOfDeletedElements );
-
- assertDoesNotThrow( () -> vmLibvirtDomainConfig.validateXml() );
- }
-
- @Test
- @DisplayName( "Test output of filtered VM configuration" )
- public void testQemuMetaDataGetFilteredDefinitionArray()
- throws VirtualizationConfigurationException, IOException, NoSuchFieldException, SecurityException,
- IllegalArgumentException, IllegalAccessException
- {
- File file = LibvirtXmlTestResources.getLibvirtXmlFile( "qemu-kvm_default-archlinux-vm.xml" );
- VirtualizationConfigurationQemu vmConfig = new VirtualizationConfigurationQemu( null, file );
-
- final Domain vmLibvirtDomainConfig = VirtualizationConfigurationQemuTest
- .getPrivateDomainFromQemuMetaData( vmConfig );
-
- final int numberOfDeletedElements = 2;
-
- final String filteredXmlConfig = new String( vmConfig.getFilteredDefinitionArray(), StandardCharsets.UTF_8 );
- final String originalXmlConfig = FileUtils.readFileToString( file, StandardCharsets.UTF_8 );
-
- assertNotNull( filteredXmlConfig );
-
- final int lengthFilteredXmlConfig = filteredXmlConfig.split( System.lineSeparator() ).length;
- final int lengthOriginalXmlConfig = originalXmlConfig.split( System.lineSeparator() ).length;
-
- assertEquals( lengthOriginalXmlConfig, lengthFilteredXmlConfig + numberOfDeletedElements );
+ assertEquals( lengthOriginalXmlConfig, lengthUnfilteredXmlConfig );
assertDoesNotThrow( () -> vmLibvirtDomainConfig.validateXml() );
}
diff --git a/src/test/java/org/openslx/vm/disk/DiskImageQcow2Test.java b/src/test/java/org/openslx/vm/disk/DiskImageQcow2Test.java
index 530cd60..7804d7d 100644
--- a/src/test/java/org/openslx/vm/disk/DiskImageQcow2Test.java
+++ b/src/test/java/org/openslx/vm/disk/DiskImageQcow2Test.java
@@ -7,6 +7,7 @@ import java.io.IOException;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.openslx.virtualization.Version;
import org.openslx.vm.disk.DiskImage.ImageFormat;
public class DiskImageQcow2Test
@@ -16,7 +17,7 @@ public class DiskImageQcow2Test
public void testQcow2DiskImage() throws DiskImageException, IOException
{
final DiskImage image = DiskImage.newInstance( DiskImageTestResources.getDiskFile( "image-default.qcow2" ) );
- final int imageVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "3" ) );
+ final Version imageVersion = new Version( Short.valueOf( "3" ) );
assertEquals( ImageFormat.QCOW2.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );
@@ -32,7 +33,7 @@ public class DiskImageQcow2Test
{
final DiskImage image = DiskImage
.newInstance( DiskImageTestResources.getDiskFile( "image_cs-16384_cp-on_l2-on.qcow2" ) );
- final int imageVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "3" ) );
+ final Version imageVersion = new Version( Short.valueOf( "3" ) );
assertEquals( ImageFormat.QCOW2.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );
@@ -48,7 +49,7 @@ public class DiskImageQcow2Test
{
final DiskImage image = DiskImage
.newInstance( DiskImageTestResources.getDiskFile( "image_cs-16384_cp-on_l2-off.qcow2" ) );
- final int imageVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "3" ) );
+ final Version imageVersion = new Version( Short.valueOf( "3" ) );
assertEquals( ImageFormat.QCOW2.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );
@@ -64,7 +65,7 @@ public class DiskImageQcow2Test
{
final DiskImage image = DiskImage
.newInstance( DiskImageTestResources.getDiskFile( "image_cs-16384_cp-off_l2-on.qcow2" ) );
- final int imageVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "3" ) );
+ final Version imageVersion = new Version( Short.valueOf( "3" ) );
assertEquals( ImageFormat.QCOW2.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );
@@ -80,7 +81,7 @@ public class DiskImageQcow2Test
{
final DiskImage image = DiskImage
.newInstance( DiskImageTestResources.getDiskFile( "image_cs-16384_cp-off_l2-off.qcow2" ) );
- final int imageVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "3" ) );
+ final Version imageVersion = new Version( Short.valueOf( "3" ) );
assertEquals( ImageFormat.QCOW2.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );
@@ -96,7 +97,7 @@ public class DiskImageQcow2Test
{
final DiskImage image = DiskImage
.newInstance( DiskImageTestResources.getDiskFile( "image_cs-65536_cp-on_l2-on.qcow2" ) );
- final int imageVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "3" ) );
+ final Version imageVersion = new Version( Short.valueOf( "3" ) );
assertEquals( ImageFormat.QCOW2.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );
@@ -112,7 +113,7 @@ public class DiskImageQcow2Test
{
final DiskImage image = DiskImage
.newInstance( DiskImageTestResources.getDiskFile( "image_cs-65536_cp-on_l2-off.qcow2" ) );
- final int imageVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "3" ) );
+ final Version imageVersion = new Version( Short.valueOf( "3" ) );
assertEquals( ImageFormat.QCOW2.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );
@@ -128,7 +129,7 @@ public class DiskImageQcow2Test
{
final DiskImage image = DiskImage
.newInstance( DiskImageTestResources.getDiskFile( "image_cs-65536_cp-off_l2-on.qcow2" ) );
- final int imageVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "3" ) );
+ final Version imageVersion = new Version( Short.valueOf( "3" ) );
assertEquals( ImageFormat.QCOW2.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );
@@ -144,7 +145,7 @@ public class DiskImageQcow2Test
{
final DiskImage image = DiskImage
.newInstance( DiskImageTestResources.getDiskFile( "image_cs-65536_cp-off_l2-off.qcow2" ) );
- final int imageVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "3" ) );
+ final Version imageVersion = new Version( Short.valueOf( "3" ) );
assertEquals( ImageFormat.QCOW2.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );
@@ -160,7 +161,7 @@ public class DiskImageQcow2Test
{
final DiskImage image = DiskImage
.newInstance( DiskImageTestResources.getDiskFile( "image_cs-2097152_cp-on_l2-on.qcow2" ) );
- final int imageVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "3" ) );
+ final Version imageVersion = new Version( Short.valueOf( "3" ) );
assertEquals( ImageFormat.QCOW2.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );
@@ -176,7 +177,7 @@ public class DiskImageQcow2Test
{
final DiskImage image = DiskImage
.newInstance( DiskImageTestResources.getDiskFile( "image_cs-2097152_cp-on_l2-off.qcow2" ) );
- final int imageVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "3" ) );
+ final Version imageVersion = new Version( Short.valueOf( "3" ) );
assertEquals( ImageFormat.QCOW2.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );
@@ -192,7 +193,7 @@ public class DiskImageQcow2Test
{
final DiskImage image = DiskImage
.newInstance( DiskImageTestResources.getDiskFile( "image_cs-2097152_cp-off_l2-on.qcow2" ) );
- final int imageVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "3" ) );
+ final Version imageVersion = new Version( Short.valueOf( "3" ) );
assertEquals( ImageFormat.QCOW2.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );
@@ -208,7 +209,7 @@ public class DiskImageQcow2Test
{
final DiskImage image = DiskImage
.newInstance( DiskImageTestResources.getDiskFile( "image_cs-2097152_cp-off_l2-off.qcow2" ) );
- final int imageVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "3" ) );
+ final Version imageVersion = new Version( Short.valueOf( "3" ) );
assertEquals( ImageFormat.QCOW2.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );
diff --git a/src/test/java/org/openslx/vm/disk/DiskImageVdiTest.java b/src/test/java/org/openslx/vm/disk/DiskImageVdiTest.java
index 492c6aa..85112cc 100644
--- a/src/test/java/org/openslx/vm/disk/DiskImageVdiTest.java
+++ b/src/test/java/org/openslx/vm/disk/DiskImageVdiTest.java
@@ -7,6 +7,7 @@ import java.io.IOException;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.openslx.virtualization.Version;
import org.openslx.vm.disk.DiskImage.ImageFormat;
public class DiskImageVdiTest
@@ -16,7 +17,7 @@ public class DiskImageVdiTest
public void testVdiDiskImage() throws DiskImageException, IOException
{
final DiskImage image = DiskImage.newInstance( DiskImageTestResources.getDiskFile( "image-default.vdi" ) );
- final int imageVersion = DiskImageUtils.versionFromMajorMinor( Short.valueOf( "1" ), Short.valueOf( "1" ) );
+ final Version imageVersion = new Version( Short.valueOf( "1" ), Short.valueOf( "1" ) );
assertEquals( ImageFormat.VDI.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );
@@ -25,13 +26,13 @@ public class DiskImageVdiTest
assertEquals( imageVersion, image.getVersion() );
assertNotNull( image.getDescription() );
}
-
+
@Test
@DisplayName( "Test detection of VDI disk image snapshot" )
public void testVdiDiskImageSnapshot() throws DiskImageException, IOException
{
final DiskImage image = DiskImage.newInstance( DiskImageTestResources.getDiskFile( "image-default_snapshot.vdi" ) );
- final int imageVersion = DiskImageUtils.versionFromMajorMinor( Short.valueOf( "1" ), Short.valueOf( "1" ) );
+ final Version imageVersion = new Version( Short.valueOf( "1" ), Short.valueOf( "1" ) );
assertEquals( ImageFormat.VDI.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );
diff --git a/src/test/java/org/openslx/vm/disk/DiskImageVmdkTest.java b/src/test/java/org/openslx/vm/disk/DiskImageVmdkTest.java
index 00cf561..4c8be82 100644
--- a/src/test/java/org/openslx/vm/disk/DiskImageVmdkTest.java
+++ b/src/test/java/org/openslx/vm/disk/DiskImageVmdkTest.java
@@ -8,6 +8,7 @@ import java.io.IOException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.openslx.virtualization.Version;
import org.openslx.vm.disk.DiskImage.ImageFormat;
public class DiskImageVmdkTest
@@ -17,8 +18,8 @@ public class DiskImageVmdkTest
public void testVmdkDiskImage() throws DiskImageException, IOException
{
final DiskImage image = DiskImage.newInstance( DiskImageTestResources.getDiskFile( "image-default.vmdk" ) );
- final int imageVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "1" ) );
- final int imageHwVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "18" ) );
+ final Version imageVersion = new Version( Short.valueOf( "1" ) );
+ final Version imageHwVersion = new Version( Short.valueOf( "18" ) );
assertEquals( ImageFormat.VMDK.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );
@@ -37,8 +38,8 @@ public class DiskImageVmdkTest
public void testVmdkDiskImageType0() throws DiskImageException, IOException
{
final DiskImage image = DiskImage.newInstance( DiskImageTestResources.getDiskFile( "image_t0.vmdk" ) );
- final int imageVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "1" ) );
- final int imageHwVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "18" ) );
+ final Version imageVersion = new Version( Short.valueOf( "1" ) );
+ final Version imageHwVersion = new Version( Short.valueOf( "18" ) );
assertEquals( ImageFormat.VMDK.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );
@@ -93,8 +94,8 @@ public class DiskImageVmdkTest
public void testVmdkDiskImageType5() throws DiskImageException, IOException
{
final DiskImage image = DiskImage.newInstance( DiskImageTestResources.getDiskFile( "image_t5.vmdk" ) );
- final int imageVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "3" ) );
- final int imageHwVersion = DiskImageUtils.versionFromMajor( Short.valueOf( "18" ) );
+ final Version imageVersion = new Version( Short.valueOf( "3" ) );
+ final Version imageHwVersion = new Version( Short.valueOf( "18" ) );
assertEquals( ImageFormat.VMDK.toString(), image.getFormat().toString() );
assertEquals( true, image.isStandalone() );