summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/util/vm/QemuMetaData.java
diff options
context:
space:
mode:
authorChristopher Lucas2018-12-06 17:44:42 +0100
committerChristopher Lucas2018-12-06 17:44:42 +0100
commit50c0a1ad622f39f5e9e5d7e5654be86c2086bfee (patch)
treec6a3248129058711a591d3b3855a794f73c8ea85 /src/main/java/org/openslx/util/vm/QemuMetaData.java
parentLearning git (diff)
downloadmaster-sync-shared-50c0a1ad622f39f5e9e5d7e5654be86c2086bfee.tar.gz
master-sync-shared-50c0a1ad622f39f5e9e5d7e5654be86c2086bfee.tar.xz
master-sync-shared-50c0a1ad622f39f5e9e5d7e5654be86c2086bfee.zip
Optimized Upload with new Map and Enum system
Diffstat (limited to 'src/main/java/org/openslx/util/vm/QemuMetaData.java')
-rw-r--r--src/main/java/org/openslx/util/vm/QemuMetaData.java132
1 files changed, 65 insertions, 67 deletions
diff --git a/src/main/java/org/openslx/util/vm/QemuMetaData.java b/src/main/java/org/openslx/util/vm/QemuMetaData.java
index cf3b550..c1a062b 100644
--- a/src/main/java/org/openslx/util/vm/QemuMetaData.java
+++ b/src/main/java/org/openslx/util/vm/QemuMetaData.java
@@ -12,8 +12,7 @@ import org.apache.log4j.Logger;
import org.openslx.bwlp.thrift.iface.OperatingSystem;
import org.openslx.bwlp.thrift.iface.Virtualizer;
import org.openslx.thrifthelper.TConst;
-import org.openslx.util.vm.QemuConfig.Header;
-import static org.openslx.util.vm.QemuConfig.Header.MACHINE;
+import static org.openslx.util.vm.QemuConfig.Header.*;
class QemuDDAccelMeta {
@@ -98,10 +97,10 @@ public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAcce
public void init() {
registerVirtualHW();
+ config.setHdds();
displayName = config.getDisplayName();
setOs(config.getOsName());
- isMachineSnapshot = config.isMachineSnapshot();
- config.setHdds();
+ isMachineSnapshot = config.isMachineSnapshot();
for (HardDisk hardDisk : config.getHdds()) {
hdds.add(hardDisk);
}
@@ -128,8 +127,7 @@ public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAcce
option = new TreeMap<>();
String bus = "anychipset";
DriveBusType busType = DriveBusType.IDE;
- //drive
- option = config.get("[drive \"disk0\"]");
+ option = config.get(DRIVE.getHeader(), DRIVE.getID());
if (option != null) {
option.replace("file", "\"" + diskImage.getAbsolutePath() + "\"");
bus = option.get("if");
@@ -148,7 +146,7 @@ public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAcce
break;
}
//device
- option = config.get("[dev0]");
+// option = config.get("[dev0]");
hdds.add(new HardDisk(option.get("driver"), busType, diskImage.getAbsolutePath()));
return true;
}
@@ -162,12 +160,12 @@ public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAcce
option.put("if", "\"scsi\"");
String status = (isMachineSnapshot == true ? "on" : "off");
option.put("snapshot", "\"" + status + "\"");
- config.set("[drive \"drive" + driveCounter + "\"]", option);
+// config.set("[drive \"drive" + driveCounter + "\"]", option);
//device
option.put("drive", "\"drive" + driveCounter + "\"");
option.put("driver", "scsi-hd");
- config.set("[device]", option);
+////// config.set("[device]", option);
hdds.add(new HardDisk("anychipset", DriveBusType.IDE, diskImagePath));
driveCounter++;
@@ -189,7 +187,7 @@ public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAcce
public boolean addDisplayName(String name) {
option = new TreeMap<>();
option.put("guest", "\"" + name + "\"");
- config.set("[name]", option);
+// config.set("[name]", option);
return true;
}
@@ -197,7 +195,7 @@ public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAcce
public boolean addRam(int mem) {
option = new TreeMap<>();
option.put("size", "\"" + mem + "\"");
- config.set("[memory]", option);
+// config.set("[memory]", option);
return true;
}
@@ -211,7 +209,7 @@ public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAcce
}
option.put("if", "\"floppy\"");
option.put("file", image);
- config.set("[drive \"floppy" + floppyCounter + "\"]", option);
+// config.set("[drive \"floppy" + floppyCounter + "\"]", option);
floppyCounter++;
}
@@ -220,7 +218,7 @@ public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAcce
option = new TreeMap<>();
option.put("media", "\"cdrom\"");
option.put("file", image);
- config.set("[drive \"cdrom" + cdromCounter + "\"]", option);
+// config.set("[drive \"cdrom" + cdromCounter + "\"]", option);
cdromCounter++;
return true;
}
@@ -229,7 +227,7 @@ public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAcce
public boolean addCpuCoreCount(int nrOfCores) {
option = new TreeMap<>();
option.put("cpus", "\"" + nrOfCores + "\"");
- config.set("[smp-opts]", option);
+// config.set("[smp-opts]", option);
return true;
}
@@ -271,29 +269,29 @@ public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAcce
option = new TreeMap<>();
option.put("driver", "\"" + dev.value + "\"");
option.put("netdev", "\"net" + cardIndex + "\"");
- config.set("[device]", option);
+// config.set("[device]", option);
}
@Override
public VmMetaData.EthernetDevType getEthernetDevType(int cardIndex) {
- QemuEthernetDevTypeMeta ethernetDevTypeMeta = null;
- for (String key : config.get().keySet()) {
- if (key.equals("[dev" + cardIndex + "]")) {//wont work dev0
- if (config.get(key).get("netdev").equals("\"net" + cardIndex + "\"")) {
- String devs = config.get(key).get("driver");
-
- for (EthernetDevType type : VmMetaData.EthernetDevType.values()) {
- ethernetDevTypeMeta = networkCards.get(type);
- if (ethernetDevTypeMeta == null) {
- continue;
- }
- if (devs.equals(ethernetDevTypeMeta.value)) {
- return type;
- }
- }
- }
- }
- }
+// QemuEthernetDevTypeMeta ethernetDevTypeMeta = null;
+// for (String key : config.get().keySet()) {
+// if (key.equals("[dev" + cardIndex + "]")) {//wont work dev0
+// if (config.get(key).get("netdev").equals("\"net" + cardIndex + "\"")) {
+// String devs = config.get(key).get("driver");
+//
+// for (EthernetDevType type : VmMetaData.EthernetDevType.values()) {
+// ethernetDevTypeMeta = networkCards.get(type);
+// if (ethernetDevTypeMeta == null) {
+// continue;
+// }
+// if (devs.equals(ethernetDevTypeMeta.value)) {
+// return type;
+// }
+// }
+// }
+// }
+// }
return EthernetDevType.AUTO;
}
@@ -301,40 +299,40 @@ public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAcce
public boolean addEthernet(VmMetaData.EtherType type) {
boolean ret = false;
int index = 0;
- for (;; ++index) {
- TreeMap<String, String> dev = config.get("[dev" + index + "]");
+// for (;; ++index) {
+// TreeMap<String, String> dev = config.get("[dev" + index + "]");
- if (dev == null) {
- break;
- } else {
- if (dev.get("netdev") == null) {
- break;
- }
- }
- }
- switch (type) {
- case NAT:
- //netdev
- option = new TreeMap<>();
- option.put("br", "nat1");
- option.put("type", "bridge");
- config.set("[netdev \"net" + index + "\"]", option);
- //device
- option = new TreeMap<>();
- break;
- case BRIDGED:
- option = new TreeMap<>();
- option.put("br", "'br0'");
- option.put("type", "'bridge'");
- config.set("[netdev \"net" + index + "\"]", option);
- break;
- case HOST_ONLY:
- //Dont know how to do it...
- break;
- default:
- // Should not come to this...
- break;
- }
+// if (dev == null) {
+// break;
+// } else {
+// if (dev.get("netdev") == null) {
+// break;
+// }
+// }
+// }
+// switch (type) {
+// case NAT:
+// //netdev
+// option = new TreeMap<>();
+// option.put("br", "nat1");
+// option.put("type", "bridge");
+//// config.set("[netdev \"net" + index + "\"]", option);
+// //device
+// option = new TreeMap<>();
+// break;
+// case BRIDGED:
+// option = new TreeMap<>();
+// option.put("br", "'br0'");
+// option.put("type", "'bridge'");
+//// config.set("[netdev \"net" + index + "\"]", option);
+// break;
+// case HOST_ONLY:
+// //Dont know how to do it...
+// break;
+// default:
+// // Should not come to this...
+// break;
+// }
return ret;
}
@@ -351,7 +349,7 @@ public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAcce
} else {
option.put("usb", "\"off\"");
}
- config.set(MACHINE.value(), option);
+// config.set(MACHINE.value(), option);
}
@Override