From 00b03b90cc460215c2e9f2aac107e362955320e2 Mon Sep 17 00:00:00 2001 From: Tomoki Sekiyama Date: Wed, 7 Jan 2015 17:39:33 -0500 Subject: [PATCH] LVM: Add terminate_connection call for Target Objects terminate_connection should be redirected from LVM driver to targets object. Especially this is required in LioAdm to remove an initiator from a target. This also fixes some mismatch of method arguments and remove unused methods in target objects. Change-Id: Ic42836e995bbdaad92e355b94cb2d7b45d8fdb60 Partial-Bug: #1408443 --- cinder/tests/targets/test_base_iscsi_driver.py | 2 +- cinder/volume/drivers/lvm.py | 3 ++- cinder/volume/targets/driver.py | 9 ++------- cinder/volume/targets/fake.py | 12 ++---------- cinder/volume/targets/iet.py | 12 +----------- cinder/volume/targets/iscsi.py | 5 +---- cinder/volume/targets/lio.py | 2 +- 7 files changed, 10 insertions(+), 35 deletions(-) diff --git a/cinder/tests/targets/test_base_iscsi_driver.py b/cinder/tests/targets/test_base_iscsi_driver.py index 2608e5be3..4777e2f9a 100644 --- a/cinder/tests/targets/test_base_iscsi_driver.py +++ b/cinder/tests/targets/test_base_iscsi_driver.py @@ -127,7 +127,7 @@ class TestBaseISCSITargetDriver(test.TestCase): expected = {'driver_volume_type': 'iscsi', 'data': self.expected_iscsi_properties} self.assertEqual(expected, - self.target.initialize_connection(self.testvol_1)) + self.target.initialize_connection(self.testvol_1, {})) def test_validate_connector(self): bad_connector = {'no_initiator': 'nada'} diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py index 1ae7ce292..b0409a7c0 100644 --- a/cinder/volume/drivers/lvm.py +++ b/cinder/volume/drivers/lvm.py @@ -572,7 +572,8 @@ class LVMVolumeDriver(driver.VolumeDriver): return self.target_driver.validate_connector(connector) def terminate_connection(self, volume, connector, **kwargs): - pass + return self.target_driver.terminate_connection(volume, connector, + **kwargs) class LVMISCSIDriver(LVMVolumeDriver): diff --git a/cinder/volume/targets/driver.py b/cinder/volume/targets/driver.py index bfa636d55..0e55932d9 100644 --- a/cinder/volume/targets/driver.py +++ b/cinder/volume/targets/driver.py @@ -58,15 +58,10 @@ class Target(object): pass @abc.abstractmethod - def detach_volume(self, context, volume): - """Callback for volume detached from instance or host.""" - pass - - @abc.abstractmethod - def initialize_connection(self, volume, **kwargs): + def initialize_connection(self, volume, connector): """Allow connection to connector and return connection info.""" pass - def terminate_connection(self, volume, **kwargs): + def terminate_connection(self, volume, connector, **kwargs): """Disallow connection from connector.""" pass diff --git a/cinder/volume/targets/fake.py b/cinder/volume/targets/fake.py index 9f6c8bb9e..d1bcbe9e0 100644 --- a/cinder/volume/targets/fake.py +++ b/cinder/volume/targets/fake.py @@ -33,16 +33,8 @@ class FakeTarget(iscsi.ISCSITarget): def remove_export(self, context, volume): pass - def attach_volume(self, context, - volume, instance_uuid, - host_name, mountpoint): + def initialize_connection(self, volume, connector): pass - def detach_volume(self, context, volume): - pass - - def initialize_connection(self, volume, **kwargs): - pass - - def terminate_connection(self, volume, **kwargs): + def terminate_connection(self, volume, connector, **kwargs): pass diff --git a/cinder/volume/targets/iet.py b/cinder/volume/targets/iet.py index 71214866d..6c3f5e6d1 100644 --- a/cinder/volume/targets/iet.py +++ b/cinder/volume/targets/iet.py @@ -28,15 +28,5 @@ class IetAdm(object): def remove_export(self, context, volume): pass - def attach_volume(self, context, volume, - instance_uuid, host_name, mountpoint): - pass - - def detach_volume(self, context, volume): - pass - - def initialize_connection(self, volume, **kwargs): - pass - - def terminate_connection(self, volume, **kwargs): + def initialize_connection(self, volume, connector): pass diff --git a/cinder/volume/targets/iscsi.py b/cinder/volume/targets/iscsi.py index 0ae0a4512..d1c7fc6c7 100644 --- a/cinder/volume/targets/iscsi.py +++ b/cinder/volume/targets/iscsi.py @@ -156,10 +156,7 @@ class ISCSITarget(driver.Target): """Get the current chap auth username and password.""" return None - def detach_volume(self, context, volume): - self._get_iscsi_properties(volume) - - def initialize_connection(self, volume, **kwargs): + def initialize_connection(self, volume, connector): """Initializes the connection and returns connection info. The iscsi driver returns a driver_volume_type of 'iscsi'. diff --git a/cinder/volume/targets/lio.py b/cinder/volume/targets/lio.py index 3f38dacd2..4aecde344 100644 --- a/cinder/volume/targets/lio.py +++ b/cinder/volume/targets/lio.py @@ -178,7 +178,7 @@ class LioAdm(TgtAdm): 'data': iscsi_properties } - def terminate_connection(self, volume, connector): + def terminate_connection(self, volume, connector, **kwargs): volume_iqn = volume['provider_location'].split(' ')[1] # Delete initiator iqns from target ACL -- 2.45.2