cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kis...@apache.org
Subject git commit: updated refs/heads/4.4 to 50b9205
Date Thu, 27 Mar 2014 09:14:30 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4 b4d3aac74 -> 50b92054c


CLOUDSTACK-6122: Map rbd image on host before attaching to Vm


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/50b92054
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/50b92054
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/50b92054

Branch: refs/heads/4.4
Commit: 50b92054c57b211fc37de72218c67ec21956649a
Parents: b4d3aac
Author: Kishan Kavala <kishan@cloud.com>
Authored: Thu Mar 27 14:33:34 2014 +0530
Committer: Kishan Kavala <kishan@cloud.com>
Committed: Thu Mar 27 14:35:09 2014 +0530

----------------------------------------------------------------------
 .../kvm/resource/LibvirtComputingResource.java  |  4 ++++
 .../kvm/storage/KVMStorageProcessor.java        | 20 ++++++++++++++++++--
 2 files changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/50b92054/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 1d7d1b2..14b7f2f 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
@@ -5458,4 +5458,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements
Serv
 
     }
 
+    public HypervisorType getHypervisorType(){
+        return _hypervisorType;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/50b92054/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
index 9813389..0024c8e 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
@@ -38,6 +38,7 @@ import java.util.UUID;
 
 import javax.naming.ConfigurationException;
 
+import com.cloud.hypervisor.Hypervisor;
 import org.apache.commons.io.FileUtils;
 import org.apache.log4j.Logger;
 import org.libvirt.Connect;
@@ -955,8 +956,23 @@ public class KVMStorageProcessor implements StorageProcessor {
             } else {
                 diskdef = new DiskDef();
                 if (attachingPool.getType() == StoragePoolType.RBD) {
-                    diskdef.defNetworkBasedDisk(attachingDisk.getPath(), attachingPool.getSourceHost(),
attachingPool.getSourcePort(), attachingPool.getAuthUserName(),
-                        attachingPool.getUuid(), devId, DiskDef.diskBus.VIRTIO, diskProtocol.RBD,
DiskDef.diskFmtType.RAW);
+                    if(resource.getHypervisorType() == Hypervisor.HypervisorType.LXC){
+                        // For LXC, map image to host and then attach to Vm
+                        String mapRbd = Script.runSimpleBashScript("rbd map " + attachingDisk.getPath()
+ " --id "+attachingPool.getAuthUserName());
+                        //Split pool and image details from disk path
+                        String[] splitPoolImage = attachingDisk.getPath().split("/");
+                        //ToDo: rbd showmapped supports json and xml output. Use json/xml
to get device
+                        String device = Script.runSimpleBashScript("rbd showmapped | grep
\""+splitPoolImage[0]+"  "+splitPoolImage[1]+"\" | cut -d \" \" -f10");
+                        if (device != null) {
+                            s_logger.debug("RBD device on host is: "+device);
+                            diskdef.defBlockBasedDisk(device, devId, DiskDef.diskBus.VIRTIO);
+                        } else {
+                            throw new InternalErrorException("Error while mapping disk "+attachingDisk.getPath()+"
on host");
+                        }
+                    } else {
+                        diskdef.defNetworkBasedDisk(attachingDisk.getPath(), attachingPool.getSourceHost(),
attachingPool.getSourcePort(), attachingPool.getAuthUserName(),
+                                attachingPool.getUuid(), devId, DiskDef.diskBus.VIRTIO, diskProtocol.RBD,
DiskDef.diskFmtType.RAW);
+                    }
                 } else if (attachingPool.getType() == StoragePoolType.Gluster) {
                     String mountpoint = attachingPool.getLocalPath();
                     String path = attachingDisk.getPath();


Mime
View raw message