You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2017/08/05 22:04:25 UTC

[cloudstack] branch master updated: CLOUDSTACK-10034: Use libvirt to create new volumes and not rados-java (#2039)

This is an automated email from the ASF dual-hosted git repository.

bhaisaab pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/master by this push:
     new 2867080  CLOUDSTACK-10034: Use libvirt to create new volumes and not rados-java (#2039)
2867080 is described below

commit 28670809791d9853c21693fbbd80154c9f66824f
Author: Wido den Hollander <wi...@widodh.nl>
AuthorDate: Sun Aug 6 00:04:21 2017 +0200

    CLOUDSTACK-10034: Use libvirt to create new volumes and not rados-java (#2039)
    
    Since libvirt 1.2.2 libvirt will properly create volumes
    using RBD format 2.
    
    We can use libvirt to creates the volumes which strips a bit of
    code from the CloudStack Agent's responsbility.
    
    RBD format 2 is already used by all volumes created by CloudStack.
    
    This format is the most recent format of RBD and is still actively
    being developed.
    
    This removes the support for Ubuntu 12.04 as that does not have the
    proper libvirt version available.
    
    Signed-off-by: Wido den Hollander wido@widodh.nl
    
    We can use libvirt to creates the volumes which strips a bit of
    code from the CloudStack Agent's responsbility.
    
    RBD format 2 is already used by all volumes created by CloudStack.
    
    This format is the most recent format of RBD and is still actively
    being developed.
    
    This removes the support for Ubuntu 12.04 as that does not have the
    proper libvirt version available.
    
    Signed-off-by: Wido den Hollander <wi...@widodh.nl>
---
 debian/control                                     |  3 +-
 .../kvm/storage/LibvirtStorageAdaptor.java         | 78 +++++-----------------
 2 files changed, 19 insertions(+), 62 deletions(-)

diff --git a/debian/control b/debian/control
index fed6622..f402325 100644
--- a/debian/control
+++ b/debian/control
@@ -22,7 +22,8 @@ Description: CloudStack server library
 
 Package: cloudstack-agent
 Architecture: all
-Depends: ${python:Depends}, openjdk-8-jre-headless | java8-runtime-headless | java8-runtime, cloudstack-common (= ${source:Version}), lsb-base (>= 4.0), libcommons-daemon-java, openssh-client, qemu-kvm (>= 1.0), libvirt-bin (>= 0.9.8), uuid-runtime, iproute, ebtables, vlan, jsvc, ipset, python-libvirt, ethtool, iptables, lsb-release, init-system-helpers (>= 1.14~)
+Depends: ${python:Depends}, openjdk-8-jre-headless | java8-runtime-headless | java8-runtime, cloudstack-common (= ${source:Version}), lsb-base (>= 4.0), libcommons-daemon-java, openssh-client, qemu-kvm (>= 1.0), libvirt-bin (>= 1.2.2), uuid-runtime, iproute, ebtables, vlan, jsvc, ipset, python-libvirt, ethtool, iptables, lsb-release, init-system-helpers (>= 1.14~)
+Recommends: init-system-helpers
 Conflicts: cloud-agent, cloud-agent-libs, cloud-agent-deps, cloud-agent-scripts
 Description: CloudStack agent
  The CloudStack agent is in charge of managing shared computing resources in
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
index 6e8ba30..96bb068 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
@@ -659,25 +659,25 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
         s_logger.info("Attempting to create volume " + name + " (" + pool.getType().toString() + ") in pool "
                 + pool.getUuid() + " with size " + size);
 
-        switch (pool.getType()){
-        case RBD:
-            return createPhysicalDiskOnRBD(name, pool, format, provisioningType, size);
-        case NetworkFilesystem:
-        case Filesystem:
-            switch (format){
-            case QCOW2:
-                return createPhysicalDiskByQemuImg(name, pool, format, provisioningType, size);
-            case RAW:
-                return createPhysicalDiskByQemuImg(name, pool, format, provisioningType, size);
-            case DIR:
-                return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
-            case TAR:
+        switch (pool.getType()) {
+            case RBD:
                 return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
+            case NetworkFilesystem:
+            case Filesystem:
+                switch (format) {
+                    case QCOW2:
+                        return createPhysicalDiskByQemuImg(name, pool, format, provisioningType, size);
+                    case RAW:
+                        return createPhysicalDiskByQemuImg(name, pool, format, provisioningType, size);
+                    case DIR:
+                        return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
+                    case TAR:
+                        return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
+                    default:
+                        throw new CloudRuntimeException("Unexpected disk format is specified.");
+                }
             default:
-                throw new CloudRuntimeException("Unexpected disk format is specified.");
-            }
-        default:
-            return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
+                return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
         }
     }
 
@@ -748,50 +748,6 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
         return disk;
     }
 
-    private KVMPhysicalDisk createPhysicalDiskOnRBD(String name, KVMStoragePool pool,
-            PhysicalDiskFormat format, Storage.ProvisioningType provisioningType, long size) {
-        String volPath = null;
-
-        /**
-         * To have RBD function properly we want RBD images of format 2
-         * libvirt currently defaults to format 1
-         *
-         * This has been fixed in libvirt 1.2.2, but that's not upstream
-         * in all distributions
-         *
-         * For that reason we use the native RBD bindings to create the
-         * RBD image until libvirt creates RBD format 2 by default
-         */
-
-        try {
-            s_logger.info("Creating RBD image " + pool.getSourceDir() + "/" + name + " with size " + size);
-
-            Rados r = new Rados(pool.getAuthUserName());
-            r.confSet("mon_host", pool.getSourceHost() + ":" + pool.getSourcePort());
-            r.confSet("key", pool.getAuthSecret());
-            r.confSet("client_mount_timeout", "30");
-            r.connect();
-            s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host"));
-
-            IoCTX io = r.ioCtxCreate(pool.getSourceDir());
-            Rbd rbd = new Rbd(io);
-            rbd.create(name, size, rbdFeatures, rbdOrder);
-
-            r.ioCtxDestroy(io);
-        } catch (RadosException e) {
-            throw new CloudRuntimeException(e.toString());
-        } catch (RbdException e) {
-            throw new CloudRuntimeException(e.toString());
-        }
-
-        volPath = pool.getSourceDir() + "/" + name;
-        KVMPhysicalDisk disk = new KVMPhysicalDisk(volPath, name, pool);
-        disk.setFormat(PhysicalDiskFormat.RAW);
-        disk.setSize(size);
-        disk.setVirtualSize(size);
-        return disk;
-    }
-
     @Override
     public boolean connectPhysicalDisk(String name, KVMStoragePool pool, Map<String, String> details) {
         // this is for managed storage that needs to prep disks prior to use

-- 
To stop receiving notification emails like this one, please contact
['"commits@cloudstack.apache.org" <co...@cloudstack.apache.org>'].