summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/libvirt
diff options
context:
space:
mode:
authorManuel Bentele2021-03-24 12:34:42 +0100
committerManuel Bentele2021-03-24 12:34:42 +0100
commitc2d5e99c47dcc7e6942e47377b2c7bc522c0b642 (patch)
tree9a35fa4d6e8ce973adbde85f669a883e2b24420b /src/main/java/org/openslx/libvirt
parentAdd support for emulator binary in Libvirt domain XML documents (diff)
downloadmaster-sync-shared-c2d5e99c47dcc7e6942e47377b2c7bc522c0b642.tar.gz
master-sync-shared-c2d5e99c47dcc7e6942e47377b2c7bc522c0b642.tar.xz
master-sync-shared-c2d5e99c47dcc7e6942e47377b2c7bc522c0b642.zip
Add MAC address for network interfaces in Libvirt domain XML documents
Diffstat (limited to 'src/main/java/org/openslx/libvirt')
-rw-r--r--src/main/java/org/openslx/libvirt/domain/device/Interface.java34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/main/java/org/openslx/libvirt/domain/device/Interface.java b/src/main/java/org/openslx/libvirt/domain/device/Interface.java
index b09c7da..dae3c11 100644
--- a/src/main/java/org/openslx/libvirt/domain/device/Interface.java
+++ b/src/main/java/org/openslx/libvirt/domain/device/Interface.java
@@ -59,16 +59,16 @@ public class Interface extends Device
{
return Type.fromString( this.getXmlElementAttributeValue( "type" ) );
}
-
+
/**
* Sets type of the network device.
*
* @return type of the network device.
*/
- public void setType(Type type)
+ public void setType( Type type )
{
String source = this.getSource();
-
+
// change type and set source again
this.setXmlElementAttributeValue( "type", type.toString() );
this.setSource( source );
@@ -119,6 +119,26 @@ public class Interface extends Device
}
/**
+ * Returns MAC address of the network device.
+ *
+ * @return MAC address of the network device.
+ */
+ public String getMacAddress()
+ {
+ return this.getXmlElementAttributeValue( "mac", "address" );
+ }
+
+ /**
+ * Sets MAC address of the network device.
+ *
+ * @param macAddress MAC address for the network device.
+ */
+ public void setMacAddress( String macAddress )
+ {
+ this.setXmlElementAttributeValue( "mac", "address", macAddress );
+ }
+
+ /**
* Removes boot oder entry of the network interface device.
*/
public void removeBootOrder()
@@ -135,6 +155,14 @@ public class Interface extends Device
}
/**
+ * Removes MAC address of the network interface device.
+ */
+ public void removeMacAddress()
+ {
+ this.removeXmlElement( "mac" );
+ }
+
+ /**
* Creates a non-existent network interface device as Libvirt XML device element.
*
* @param iface network device that is created.