From c2d5e99c47dcc7e6942e47377b2c7bc522c0b642 Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Wed, 24 Mar 2021 12:34:42 +0100 Subject: Add MAC address for network interfaces in Libvirt domain XML documents --- .../openslx/libvirt/domain/device/Interface.java | 34 ++++++++++++++++++++-- 1 file 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 ); @@ -118,6 +118,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. */ @@ -134,6 +154,14 @@ public class Interface extends Device this.removeXmlElement( "source" ); } + /** + * 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. * -- cgit v1.2.3-55-g7522