From 2d61d8b1cfe84252bce82d8d38699c1cb7457f58 Mon Sep 17 00:00:00 2001 From: Tomoki Sekiyama Date: Fri, 13 Feb 2015 18:49:54 -0500 Subject: [PATCH] Ensure initialize_connection in targets pass multipath parameter When the connector dict specified to initialize_connection has 'multipath' key, its value should be passed to _get_iscsi_properties so that it can generate multipath information if available. This removes the duplicated codes and ensures every target passes the multipath property. Change-Id: Ia4a8c14c3d2544682f677622fb2dfe4291d95ffc --- cinder/volume/targets/iscsi.py | 4 +++- cinder/volume/targets/iser.py | 22 ---------------------- cinder/volume/targets/lio.py | 9 +-------- cinder/volume/targets/scst.py | 7 ------- cinder/volume/targets/tgt.py | 9 --------- 5 files changed, 4 insertions(+), 47 deletions(-) diff --git a/cinder/volume/targets/iscsi.py b/cinder/volume/targets/iscsi.py index aea40eaf9..8dd1e78f6 100644 --- a/cinder/volume/targets/iscsi.py +++ b/cinder/volume/targets/iscsi.py @@ -279,7 +279,9 @@ class ISCSITarget(driver.Target): } """ - iscsi_properties = self._get_iscsi_properties(volume) + iscsi_properties = self._get_iscsi_properties(volume, + connector.get( + 'multipath')) return { 'driver_volume_type': self.iscsi_protocol, 'data': iscsi_properties diff --git a/cinder/volume/targets/iser.py b/cinder/volume/targets/iser.py index a6a3b5eea..5cfa7220a 100644 --- a/cinder/volume/targets/iser.py +++ b/cinder/volume/targets/iser.py @@ -44,25 +44,3 @@ class ISERTgtAdm(tgt.TgtAdm): self.configuration.iscsi_ip_address = \ self.configuration.iser_ip_address self.configuration.iscsi_port = self.configuration.iser_port - - def initialize_connection(self, volume, connector): - """Initializes the connection and returns connection info. - The iser driver returns a driver_volume_type of 'iser'. - The format of the driver data is defined in _get_iscsi_properties. - Example return value:: - { - 'driver_volume_type': 'iser' - 'data': { - 'target_discovered': True, - 'target_iqn': - 'iqn.2010-10.org.openstack:volume-00000001', - 'target_portal': '127.0.0.0.1:3260', - 'volume_id': 1, - } - } - """ - iser_properties = self._get_iscsi_properties(volume) - return { - 'driver_volume_type': 'iser', - 'data': iser_properties - } diff --git a/cinder/volume/targets/lio.py b/cinder/volume/targets/lio.py index 21f9b635e..43d50a900 100644 --- a/cinder/volume/targets/lio.py +++ b/cinder/volume/targets/lio.py @@ -171,14 +171,7 @@ class LioAdm(iscsi.ISCSITarget): # We make changes persistent self._persist_configuration(volume['id']) - iscsi_properties = self._get_iscsi_properties(volume, - connector.get( - 'multipath')) - - return { - 'driver_volume_type': self.iscsi_protocol, - 'data': iscsi_properties - } + return super(LioAdm, self).initialize_connection(volume, connector) def terminate_connection(self, volume, connector, **kwargs): volume_iqn = volume['provider_location'].split(' ')[1] diff --git a/cinder/volume/targets/scst.py b/cinder/volume/targets/scst.py index a262ad9aa..906713d9f 100644 --- a/cinder/volume/targets/scst.py +++ b/cinder/volume/targets/scst.py @@ -393,10 +393,3 @@ class SCSTAdm(iscsi.ISCSITarget): if tid is None: raise exception.ISCSITargetHelperCommandFailed( error_message="Target not found") - - def initialize_connection(self, volume, connector): - iscsi_properties = self._get_iscsi_properties(volume) - return { - 'driver_volume_type': 'iscsi', - 'data': iscsi_properties - } diff --git a/cinder/volume/targets/tgt.py b/cinder/volume/targets/tgt.py index 2b29536d9..0df053d6b 100644 --- a/cinder/volume/targets/tgt.py +++ b/cinder/volume/targets/tgt.py @@ -277,15 +277,6 @@ class TgtAdm(iscsi.ISCSITarget): return tid - def initialize_connection(self, volume, connector): - iscsi_properties = self._get_iscsi_properties(volume, - connector.get( - 'multipath')) - return { - 'driver_volume_type': self.iscsi_protocol, - 'data': iscsi_properties - } - def remove_iscsi_target(self, tid, lun, vol_id, vol_name, **kwargs): LOG.info(_LI('Removing iscsi_target for Volume ID: %s'), vol_id) vol_uuid_file = vol_name -- 2.45.2