cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chipchild...@apache.org
Subject [2/2] git commit: updated refs/heads/4.1 to 61e8711
Date Mon, 20 May 2013 17:55:10 GMT
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/61e87113
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/61e87113
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/61e87113

Branch: refs/heads/4.1
Commit: 61e871136ae33c9cd585bce6b8fdaeac3643b899
Parents: e08dd76
Author: Wido den Hollander <wido@42on.com>
Authored: Sat May 18 10:10:45 2013 +0200
Committer: Chip Childers <chip.childers@gmail.com>
Committed: Mon May 20 18:54:59 2013 +0100

----------------------------------------------------------------------
 .../kvm/resource/LibvirtDomainXMLParser.java       |   57 +++++++++------
 1 files changed, 36 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61e87113/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 b622b6d..1122d70 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
@@ -34,6 +34,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;
 
@@ -63,31 +64,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);
             }


Mime
View raw message