From 77bb6a1407eb90c0d97dd879a94e6ffccfe87e74 Mon Sep 17 00:00:00 2001 From: Daniel Wilson Date: Fri, 24 Jul 2015 14:54:35 -0700 Subject: [PATCH] Add discard to connection properties This adds the discard property to base doc strings and base classes. This also adds the discard capability into the Pure Storage driver on initialize_connection as an example. Change-Id: I43b783d6d935a0104d470255c646b3fe1efdf88f Implements: bp cinder-backend-report-discard --- cinder/tests/unit/test_pure.py | 2 ++ cinder/volume/driver.py | 17 ++++++++++++----- cinder/volume/drivers/pure.py | 2 ++ cinder/volume/targets/iscsi.py | 5 ++++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/cinder/tests/unit/test_pure.py b/cinder/tests/unit/test_pure.py index dce80fe8d..68704fdc8 100644 --- a/cinder/tests/unit/test_pure.py +++ b/cinder/tests/unit/test_pure.py @@ -160,6 +160,7 @@ ISCSI_CONNECTION_INFO = { "target_lun": 1, "target_discovered": True, "access_mode": "rw", + "discard": True, }, } FC_CONNECTION_INFO = { @@ -170,6 +171,7 @@ FC_CONNECTION_INFO = { "target_discovered": True, "access_mode": "rw", "initiator_target_map": INITIATOR_TARGET_MAP, + "discard": True, }, } diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index 28ad33400..f3fc118e5 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -1548,6 +1548,8 @@ class ISCSIDriver(VolumeDriver): :access_mode: the volume access mode allow client used ('rw' or 'ro' currently supported) + :discard: boolean indicating if discard is supported + In some of drivers that support multiple connections (for multipath and for single path with failover on connection failure), it returns :target_iqns, :target_portals, :target_luns, which contain lists of @@ -1664,7 +1666,8 @@ class ISCSIDriver(VolumeDriver): 'target_iqn': 'iqn.2010-10.org.openstack:volume-00000001', 'target_portal': '127.0.0.0.1:3260', 'volume_id': 1, - 'access_mode': 'rw' + 'access_mode': 'rw', + 'discard': False, } } @@ -1684,7 +1687,8 @@ class ISCSIDriver(VolumeDriver): 'target_lun': 1, 'target_luns': [1, 1], 'volume_id': 1, - 'access_mode': 'rw' + 'access_mode': 'rw', + 'discard': False, } } """ @@ -1766,7 +1770,8 @@ class FakeISCSIDriver(ISCSIDriver): def initialize_connection(self, volume, connector): return { 'driver_volume_type': 'iscsi', - 'data': {'access_mode': 'rw'} + 'data': {'access_mode': 'rw'}, + 'discard': False, } def terminate_connection(self, volume, connector, **kwargs): @@ -1920,7 +1925,8 @@ class FibreChannelDriver(VolumeDriver): 'target_discovered': True, 'target_lun': 1, 'target_wwn': '1234567890123', - 'access_mode': 'rw' + 'access_mode': 'rw', + 'discard': False, } } @@ -1932,7 +1938,8 @@ class FibreChannelDriver(VolumeDriver): 'target_discovered': True, 'target_lun': 1, 'target_wwn': ['1234567890123', '0987654321321'], - 'access_mode': 'rw' + 'access_mode': 'rw', + 'discard': False, } } diff --git a/cinder/volume/drivers/pure.py b/cinder/volume/drivers/pure.py index 5fec7965d..375cc7ec6 100644 --- a/cinder/volume/drivers/pure.py +++ b/cinder/volume/drivers/pure.py @@ -650,6 +650,7 @@ class PureISCSIDriver(PureBaseVolumeDriver, san.SanISCSIDriver): "target_lun": connection["lun"], "target_discovered": True, "access_mode": "rw", + "discard": True, }, } @@ -826,6 +827,7 @@ class PureFCDriver(PureBaseVolumeDriver, driver.FibreChannelDriver): "target_wwn": target_wwns, 'access_mode': 'rw', 'initiator_target_map': init_targ_map, + "discard": True, } } diff --git a/cinder/volume/targets/iscsi.py b/cinder/volume/targets/iscsi.py index 1ba1b8aac..b37535a1b 100644 --- a/cinder/volume/targets/iscsi.py +++ b/cinder/volume/targets/iscsi.py @@ -78,6 +78,8 @@ class ISCSITarget(driver.Target): :access_mode: the volume access mode allow client used ('rw' or 'ro' currently supported) + :discard: boolean indicating if discard is supported + In some of drivers that support multiple connections (for multipath and for single path with failover on connection failure), it returns :target_iqns, :target_portals, :target_luns, which contain lists of @@ -289,7 +291,8 @@ class ISCSITarget(driver.Target): 'target_iqn': 'iqn.2010-10.org.openstack:volume-00000001', 'target_portal': '127.0.0.0.1:3260', 'volume_id': '9a0d35d0-175a-11e4-8c21-0800200c9a66', - 'access_mode': 'rw' + 'access_mode': 'rw', + 'discard': False, } } """ -- 2.45.2