summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/libvirt/domain/Domain.java
diff options
context:
space:
mode:
authorManuel Bentele2021-03-19 13:42:29 +0100
committerManuel Bentele2021-03-19 13:42:29 +0100
commitbf15b73d90a18e52f8764058d6fe80037d8a2307 (patch)
treed4ac8e92b187c6aee1a63ed2e6d56f11ff2bdb85 /src/main/java/org/openslx/libvirt/domain/Domain.java
parentFix warning due to missing file-based NVMe support in Libvirt (diff)
downloadmaster-sync-shared-bf15b73d90a18e52f8764058d6fe80037d8a2307.tar.gz
master-sync-shared-bf15b73d90a18e52f8764058d6fe80037d8a2307.tar.xz
master-sync-shared-bf15b73d90a18e52f8764058d6fe80037d8a2307.zip
Add implementation of Libvirt XML capabilities documents
Diffstat (limited to 'src/main/java/org/openslx/libvirt/domain/Domain.java')
-rw-r--r--src/main/java/org/openslx/libvirt/domain/Domain.java116
1 files changed, 116 insertions, 0 deletions
diff --git a/src/main/java/org/openslx/libvirt/domain/Domain.java b/src/main/java/org/openslx/libvirt/domain/Domain.java
index 4e15ec1..9611c59 100644
--- a/src/main/java/org/openslx/libvirt/domain/Domain.java
+++ b/src/main/java/org/openslx/libvirt/domain/Domain.java
@@ -353,6 +353,122 @@ public class Domain extends LibvirtXmlDocument
}
/**
+ * Returns OS type defined in the Libvirt domain XML document.
+ *
+ * @return OS type of the virtual machine.
+ */
+ public OsType getOsType()
+ {
+ final String osType = this.getRootXmlNode().getXmlElementValue( "os/type" );
+ return OsType.fromString( osType );
+ }
+
+ /**
+ * Set OS type in the Libvirt domain XML document.
+ *
+ * @param type OS type for the virtual machine.
+ */
+ public void setOsType( OsType type )
+ {
+ this.getRootXmlNode().setXmlElementValue( "os/type", type.toString() );
+ }
+
+ /**
+ * Returns OS architecture defined in the Libvirt domain XML document.
+ *
+ * @return OS architecture of the virtual machine.
+ */
+ public String getOsArch()
+ {
+ return this.getRootXmlNode().getXmlElementAttributeValue( "os/type", "arch" );
+ }
+
+ /**
+ * Set OS architecture in the Libvirt domain XML document.
+ *
+ * @param arch OS architecture for the virtual machine.
+ */
+ public void setOsArch( String arch )
+ {
+ this.getRootXmlNode().setXmlElementAttributeValue( "os/type", "arch", arch );
+ }
+
+ /**
+ * Returns OS machine defined in the Libvirt domain XML document.
+ *
+ * @return OS machine of the virtual machine.
+ */
+ public String getOsMachine()
+ {
+ return this.getRootXmlNode().getXmlElementAttributeValue( "os/type", "machine" );
+ }
+
+ /**
+ * Set OS machine in the Libvirt domain XML document.
+ *
+ * @param machine OS machine for the virtual machine.
+ */
+ public void setOsMachine( String machine )
+ {
+ this.getRootXmlNode().setXmlElementAttributeValue( "os/type", "machine", machine );
+ }
+
+ /**
+ * Operating system types specifiable for a virtual machine in the Libvirt domain XML document.
+ *
+ * @author Manuel Bentele
+ * @version 1.0
+ */
+ public enum OsType
+ {
+ // @formatter:off
+ XEN ( "xen" ),
+ LINUX( "linux" ),
+ HVM ( "hvm" ),
+ EXE ( "exe" ),
+ UML ( "uml" );
+ // @formatter:on
+
+ /**
+ * Name of the OS type in a Libvirt domain XML document.
+ */
+ private final String osType;
+
+ /**
+ * Creates an OS type.
+ *
+ * @param osType valid name of the OS type in the Libvirt domain XML document.
+ */
+ OsType( String osType )
+ {
+ this.osType = osType;
+ }
+
+ @Override
+ public String toString()
+ {
+ return this.osType;
+ }
+
+ /**
+ * Creates an OS type from its name with error check.
+ *
+ * @param osType name of the OS type in the Libvirt domain XML document.
+ * @return valid OS type.
+ */
+ public static OsType fromString( String osType )
+ {
+ for ( OsType t : OsType.values() ) {
+ if ( t.osType.equalsIgnoreCase( osType ) ) {
+ return t;
+ }
+ }
+
+ return null;
+ }
+ }
+
+ /**
* Returns virtual machine CPU model defined in the Libvirt domain XML document.
*
* @return CPU model of virtual machine.