You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ch...@apache.org on 2013/05/20 19:55:09 UTC
[1/2] git commit: updated refs/heads/4.1 to 61e8711
Updated Branches:
refs/heads/4.1 08a302382 -> 61e871136
rbd: Allow RBD disks to be attached to a Instance
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e08dd76b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e08dd76b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e08dd76b
Branch: refs/heads/4.1
Commit: e08dd76b3e111e54d4588cd91910274d9d25ea88
Parents: 08a3023
Author: Wido den Hollander <wi...@widodh.nl>
Authored: Fri May 17 17:03:21 2013 +0200
Committer: Chip Childers <ch...@gmail.com>
Committed: Mon May 20 18:54:34 2013 +0100
----------------------------------------------------------------------
.../kvm/resource/LibvirtComputingResource.java | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e08dd76b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index 90ad270..f71e5f3 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -3414,6 +3414,7 @@ ServerResource {
List<DiskDef> disks = null;
Domain dm = null;
DiskDef diskdef = null;
+ KVMStoragePool attachingPool = attachingDisk.getPool();
try {
if (!attach) {
dm = conn.domainLookupByUUID(UUID.nameUUIDFromBytes(vmName
@@ -3438,7 +3439,12 @@ ServerResource {
}
} else {
diskdef = new DiskDef();
- if (attachingDisk.getFormat() == PhysicalDiskFormat.QCOW2) {
+ if (attachingPool.getType() == StoragePoolType.RBD) {
+ diskdef.defNetworkBasedDisk(attachingDisk.getPath(),
+ attachingPool.getSourceHost(), attachingPool.getSourcePort(),
+ attachingPool.getAuthUserName(), attachingPool.getUuid(), devId,
+ DiskDef.diskBus.VIRTIO, diskProtocol.RBD);
+ } else if (attachingDisk.getFormat() == PhysicalDiskFormat.QCOW2) {
diskdef.defFileBasedDisk(attachingDisk.getPath(), devId,
DiskDef.diskBus.VIRTIO, DiskDef.diskFmtType.QCOW2);
} else if (attachingDisk.getFormat() == PhysicalDiskFormat.RAW) {
[2/2] git commit: updated refs/heads/4.1 to 61e8711
Posted by ch...@apache.org.
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 <wi...@42on.com>
Authored: Sat May 18 10:10:45 2013 +0200
Committer: Chip Childers <ch...@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);
}