File 0001-Fix-block_device-driver.patch of Package openstack-cinder

From d7f7e0b45f44ddf8ef215215394714ff00bff2e2 Mon Sep 17 00:00:00 2001
From: Ralf Haferkamp <rhafer@suse.de>
Date: Thu, 9 Jul 2015 14:07:49 +0200
Subject: [PATCH] Fix block_device driver to behave as documented

According to the original blueprint
(https://blueprints.launchpad.net/cinder/+spec/block-device-driver) the
intended behavior of the "BlockDeviceDriver" was to directly attach the block
device to the instances using virtio (without LVM and iSCSI involved) when the
volume's underlying device is located on the same host as the instance that it
is going to be attached to. This is also how it worked through Juno. It got
broken during the Kilo cycle as part of this change:
https://review.openstack.org/#/c/135139/
It seems that the change in behavior was not intended by that patch as it
addressed something completely different. And it was neither mentioned in the
commit message nor anywhere in the review comments.

This patch restores the original behavior.

Change-Id: Ic22f03860a43b767e9097ce6dc5b397cf9f3f076
Closes-Bug: 1473001
---
 cinder/tests/test_block_device.py | 12 ++----------
 cinder/volume/drivers/block_device.py  | 14 +++++++++++---
 2 files changed, 13 insertions(+), 13 deletions(-)

Index: cinder-2015.1.2.dev1/cinder/tests/test_block_device.py
===================================================================
--- cinder-2015.1.2.dev1.orig/cinder/tests/test_block_device.py
+++ cinder-2015.1.2.dev1/cinder/tests/test_block_device.py
@@ -49,16 +49,8 @@ class TestBlockDeviceDriver(cinder.test.
         TEST_CONNECTOR = {'host': 'localhost1'}
 
         data = self.drv.initialize_connection(TEST_VOLUME1, TEST_CONNECTOR)
-        expected_data = {'data': {'auth_method': 'a',
-                                  'auth_password': 'c',
-                                  'auth_username': 'b',
-                                  'encrypted': False,
-                                  'target_discovered': False,
-                                  'target_iqn': '2',
-                                  'target_lun': 3,
-                                  'target_portal': '1',
-                                  'volume_id': 'fake-uuid'},
-                         'driver_volume_type': 'iscsi'}
+        expected_data = {'data': {'device_path': '/dev/loop1'},
+                         'driver_volume_type': 'local'}
 
         self.assertEqual(expected_data, data)
 
Index: cinder-2015.1.2.dev1/cinder/volume/drivers/block_device.py
===================================================================
--- cinder-2015.1.2.dev1.orig/cinder/volume/drivers/block_device.py
+++ cinder-2015.1.2.dev1/cinder/volume/drivers/block_device.py
@@ -202,14 +202,22 @@ class BlockDeviceDriver(driver.VolumeDri
         export_info = self.target_driver.create_export(context,
                                                        volume,
                                                        volume_path)
-        return {'provider_location': export_info['location'],
-                'provider_auth': export_info['auth'], }
+        return {
+            'provider_location': export_info['location'] + ' ' + volume_path,
+            'provider_auth': export_info['auth'],
+        }
 
     def remove_export(self, context, volume):
         self.target_driver.remove_export(context, volume)
 
     def initialize_connection(self, volume, connector):
-        return self.target_driver.initialize_connection(volume, connector)
+        if connector['host'] != volutils.extract_host(volume['host'], 'host'):
+            return self.target_driver.initialize_connection(volume, connector)
+        else:
+            return {
+                'driver_volume_type': 'local',
+                'data': {'device_path': self.local_path(volume)},
+            }
 
     def validate_connector(self, connector):
         return self.target_driver.validate_connector(connector)
openSUSE Build Service is sponsored by