Merge "LIO: Fix terminate_connection AttributeError"
This commit is contained in:
commit
a1214ada6b
@ -10,6 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
@ -55,6 +56,9 @@ class TargetDriverFixture(test.TestCase):
|
||||
'created_at': timeutils.utcnow(),
|
||||
'host': 'fake_host@lvm#lvm'}
|
||||
|
||||
self.testvol_no_prov_loc = copy.copy(self.testvol)
|
||||
self.testvol_no_prov_loc['provider_location'] = None
|
||||
|
||||
self.iscsi_target_prefix = 'iqn.2010-10.org.openstack:'
|
||||
self.target_string = ('127.0.0.1:3260,1 ' +
|
||||
self.iscsi_target_prefix +
|
||||
|
@ -283,6 +283,23 @@ class TestLioAdmDriver(tf.TargetDriverFixture):
|
||||
mock_execute.assert_called_once_with(*expected_args, run_as_root=True)
|
||||
mpersist_cfg.assert_called_once_with(self.fake_volume_id)
|
||||
|
||||
@mock.patch.object(lio.LioAdm, '_execute', side_effect=lio.LioAdm._execute)
|
||||
@mock.patch.object(lio.LioAdm, '_persist_configuration')
|
||||
@mock.patch('cinder.utils.execute')
|
||||
def test_terminate_connection_no_prov_loc(self,
|
||||
mock_execute,
|
||||
mpersist_cfg,
|
||||
mlock_exec):
|
||||
"""terminate_connection does nothing if provider_location is None"""
|
||||
|
||||
connector = {'initiator': 'fake_init'}
|
||||
self.target.terminate_connection(self.testvol_no_prov_loc,
|
||||
connector)
|
||||
|
||||
mlock_exec.assert_not_called()
|
||||
mock_execute.assert_not_called()
|
||||
mpersist_cfg.assert_not_called()
|
||||
|
||||
@mock.patch.object(lio.LioAdm, '_execute', side_effect=lio.LioAdm._execute)
|
||||
@mock.patch.object(lio.LioAdm, '_persist_configuration')
|
||||
@mock.patch('cinder.utils.execute')
|
||||
|
@ -186,6 +186,11 @@ class LioAdm(iscsi.ISCSITarget):
|
||||
return super(LioAdm, self).initialize_connection(volume, connector)
|
||||
|
||||
def terminate_connection(self, volume, connector, **kwargs):
|
||||
if volume['provider_location'] is None:
|
||||
LOG.debug('No provider_location for volume %s.',
|
||||
volume['id'])
|
||||
return
|
||||
|
||||
volume_iqn = volume['provider_location'].split(' ')[1]
|
||||
|
||||
# Delete initiator iqns from target ACL
|
||||
|
Loading…
Reference in New Issue
Block a user