  
      def _cleanup_lvm(self, instance):
          """Delete all LVM disks for given instance object."""
-@@ -2618,13 +2619,15 @@ class LibvirtDriver(driver.ComputeDriver):
+@@ -2639,13 +2640,15 @@ class LibvirtDriver(driver.ComputeDriver):
              if size == 0 or suffix == '.rescue':
                  size = None
  

+        client.shutdown()
+
+    def supports_layering(self):
+        return hasattr(self.rbd, 'RBD_FEATURE_LAYERING')
+
+    def ceph_args(self):
+        args = []
+        if self.rbd_user:
+            args.extend(['--id', self.rbd_user])

+
+class RBDDriver(object):
+
+    def __init__(self, pool, ceph_conf, rbd_user):
+        self.pool = pool.encode('utf8')
+        # NOTE(angdraug): rados.Rados fails to connect if ceph_conf is None:
+        # https://github.com/ceph/ceph/pull/1787
+        self.ceph_conf = ceph_conf.encode('utf8') if ceph_conf else ''
+        self.rbd_user = rbd_user.encode('utf8') if rbd_user else None
+        if rbd is None:
+            raise RuntimeError(_('rbd python libraries not found'))
+
+    def _connect_to_rados(self, pool=None):
+        client = rados.Rados(rados_id=self.rbd_user,
+                             conffile=self.ceph_conf)
+        try:
+            client.connect()
+            pool_to_open = pool or self.pool
+            ioctx = client.open_ioctx(pool_to_open.encode('utf-8'))
+            return client, ioctx
+        except rados.Error:
+            # shutdown cannot raise an exception
+            client.shutdown()
+            raise
