You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ya...@apache.org on 2013/07/22 07:37:25 UTC
[16/50] [abbrv] git commit: updated refs/heads/pvlan to ce299da
Better parse domain XMLs so network devices can be detached as well
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/239bb13d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/239bb13d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/239bb13d
Branch: refs/heads/pvlan
Commit: 239bb13dde0d32ca3e05a8ea2b35a8885cb30538
Parents: 1851f7f
Author: Wido den Hollander <wi...@42on.com>
Authored: Sat May 18 10:10:45 2013 +0200
Committer: Wido den Hollander <wi...@42on.com>
Committed: Sat May 18 10:34:22 2013 +0200
----------------------------------------------------------------------
.../kvm/resource/LibvirtDomainXMLParser.java | 57 ++++++++++++--------
1 file changed, 36 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/239bb13d/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
index ac4baf1..b8645e1 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
@@ -35,6 +35,7 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef.diskProtocol;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef.nicModel;
@@ -64,31 +65,45 @@ public class LibvirtDomainXMLParser {
NodeList disks = devices.getElementsByTagName("disk");
for (int i = 0; i < disks.getLength(); i++) {
Element disk = (Element) disks.item(i);
- String diskFmtType = getAttrValue("driver", "type", disk);
- String diskFile = getAttrValue("source", "file", disk);
- String diskDev = getAttrValue("source", "dev", disk);
-
- String diskLabel = getAttrValue("target", "dev", disk);
- String bus = getAttrValue("target", "bus", disk);
String type = disk.getAttribute("type");
- String device = disk.getAttribute("device");
-
DiskDef def = new DiskDef();
- if (type.equalsIgnoreCase("file")) {
- if (device.equalsIgnoreCase("disk")) {
- DiskDef.diskFmtType fmt = null;
- if (diskFmtType != null) {
- fmt = DiskDef.diskFmtType.valueOf(diskFmtType
- .toUpperCase());
+ if (type.equalsIgnoreCase("network")) {
+ String diskFmtType = getAttrValue("driver", "type", disk);
+ String diskPath = getAttrValue("source", "name", disk);
+ String protocol = getAttrValue("source", "protocol", disk);
+ String authUserName = getAttrValue("auth", "username", disk);
+ String poolUuid = getAttrValue("secret", "uuid", disk);
+ String host = getAttrValue("host", "name", disk);
+ int port = Integer.parseInt(getAttrValue("host", "port", disk));
+ String diskLabel = getAttrValue("target", "dev", disk);
+ String bus = getAttrValue("target", "bus", disk);
+ def.defNetworkBasedDisk(diskPath, host, port, authUserName, poolUuid, diskLabel,
+ DiskDef.diskBus.valueOf(bus.toUpperCase()), DiskDef.diskProtocol.valueOf(protocol.toUpperCase()));
+ } else {
+ String diskFmtType = getAttrValue("driver", "type", disk);
+ String diskFile = getAttrValue("source", "file", disk);
+ String diskDev = getAttrValue("source", "dev", disk);
+
+ String diskLabel = getAttrValue("target", "dev", disk);
+ String bus = getAttrValue("target", "bus", disk);
+ String device = disk.getAttribute("device");
+
+ if (type.equalsIgnoreCase("file")) {
+ if (device.equalsIgnoreCase("disk")) {
+ DiskDef.diskFmtType fmt = null;
+ if (diskFmtType != null) {
+ fmt = DiskDef.diskFmtType.valueOf(diskFmtType
+ .toUpperCase());
+ }
+ def.defFileBasedDisk(diskFile, diskLabel,
+ DiskDef.diskBus.valueOf(bus.toUpperCase()), fmt);
+ } else if (device.equalsIgnoreCase("cdrom")) {
+ def.defISODisk(diskFile);
}
- def.defFileBasedDisk(diskFile, diskLabel,
- DiskDef.diskBus.valueOf(bus.toUpperCase()), fmt);
- } else if (device.equalsIgnoreCase("cdrom")) {
- def.defISODisk(diskFile);
+ } else if (type.equalsIgnoreCase("block")) {
+ def.defBlockBasedDisk(diskDev, diskLabel,
+ DiskDef.diskBus.valueOf(bus.toUpperCase()));
}
- } else if (type.equalsIgnoreCase("block")) {
- def.defBlockBasedDisk(diskDev, diskLabel,
- DiskDef.diskBus.valueOf(bus.toUpperCase()));
}
diskDefs.add(def);
}