summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/util/vm/VboxMetaData.java
diff options
context:
space:
mode:
authorVictor Mocanu2018-04-04 14:10:54 +0200
committerVictor Mocanu2018-04-04 14:10:54 +0200
commit625affe1a6b0fcecd826c1f4960074545f0def43 (patch)
tree859f8db451e0536e31d97bdf48aa47338684266e /src/main/java/org/openslx/util/vm/VboxMetaData.java
parent[Vbox] repaired a null pointer exception when disabling USB (diff)
downloadmaster-sync-shared-625affe1a6b0fcecd826c1f4960074545f0def43.tar.gz
master-sync-shared-625affe1a6b0fcecd826c1f4960074545f0def43.tar.xz
master-sync-shared-625affe1a6b0fcecd826c1f4960074545f0def43.zip
[Vbox] code formating
Diffstat (limited to 'src/main/java/org/openslx/util/vm/VboxMetaData.java')
-rw-r--r--src/main/java/org/openslx/util/vm/VboxMetaData.java22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/main/java/org/openslx/util/vm/VboxMetaData.java b/src/main/java/org/openslx/util/vm/VboxMetaData.java
index 1d857b0..c1b8a9b 100644
--- a/src/main/java/org/openslx/util/vm/VboxMetaData.java
+++ b/src/main/java/org/openslx/util/vm/VboxMetaData.java
@@ -69,9 +69,7 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
public static enum EthernetType
{
- NAT( "vboxnet1" ),
- BRIDGED( "vboxnet0" ),
- HOST_ONLY( "vboxnet2" );
+ NAT( "vboxnet1" ), BRIDGED( "vboxnet0" ), HOST_ONLY( "vboxnet2" );
public final String vnet;
@@ -151,7 +149,7 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
config.changeAttribute( "HardDisk", "location", diskImagePath );
UUID newhdduuid = UUID.randomUUID();
-
+
// patching the new uuid in the vbox config file here
String vboxUUid = "{" + newhdduuid.toString() + "}";
config.changeAttribute( "HardDisk", "uuid", vboxUUid );
@@ -163,15 +161,15 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
// order when we are adding them to the bytebuffer won't help
//
// the following is a workaround that works
- ByteBuffer buffer = ByteBuffer.wrap( new byte[16] );
+ ByteBuffer buffer = ByteBuffer.wrap( new byte[ 16 ] );
buffer.putLong( newhdduuid.getMostSignificantBits() );
buffer.putLong( newhdduuid.getLeastSignificantBits() );
byte[] oldOrder = buffer.array();
// make a coppy here because the last 8 Bytes don't need to change position
byte[] bytesToWrite = Arrays.copyOf( oldOrder, oldOrder.length );
// use an offset int[] to help with the shuffle
- int[] offsets = { 3, 2, 1, 0, 5, 4, 7, 6};
- for ( int index = 0; index < 8; index++) {
+ int[] offsets = { 3, 2, 1, 0, 5, 4, 7, 6 };
+ for ( int index = 0; index < 8; index++ ) {
bytesToWrite[index] = oldOrder[offsets[index]];
}
try ( RandomAccessFile file = new RandomAccessFile( diskImage, "rw" ) ) {
@@ -236,7 +234,7 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
}
Element attachedDev = null;
-
+
if ( image == null ) {
attachedDev = (Element)config.addNewNode( "StorageController", "AttachedDevice", true, "name", "Floppy" );
LOGGER.warn( "Floppy controller has no image attached" );
@@ -250,7 +248,7 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
floppyImageTag.setAttribute( "uuid", VboxConfig.PlaceHolder.FLOPPYUUID.holderName() );
floppyImageTag.setAttribute( "location", VboxConfig.PlaceHolder.FLOPPYLOCATION.holderName() );
}
-
+
attachedDev.setAttribute( "type", "Floppy" );
attachedDev.setAttribute( "hotpluggable", "false" );
attachedDev.setAttribute( "port", "0" );
@@ -435,11 +433,11 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta,
public boolean addEthernet( VmMetaData.EtherType type )
{
Node hostOnlyInterfaceNode = config.addNewNode( "Adapter", "HostOnlyInterface", true, "slot", "0" );
- if (hostOnlyInterfaceNode == null) {
- LOGGER.error("Failed to create node for HostOnlyInterface.");
+ if ( hostOnlyInterfaceNode == null ) {
+ LOGGER.error( "Failed to create node for HostOnlyInterface." );
return false;
}
- return config.addAttributeToNode(hostOnlyInterfaceNode, "name", EthernetType.valueOf(type.name()).vnet);
+ return config.addAttributeToNode( hostOnlyInterfaceNode, "name", EthernetType.valueOf( type.name() ).vnet );
}
@Override