From f8636888590ddb3339eafad9c00e4806df486238 Mon Sep 17 00:00:00 2001 From: Yucong Feng Date: Fri, 19 Feb 2016 22:25:19 +0100 Subject: [PATCH] Return all target_wwpns for FC storwize Storwize FC terminate_connection was using 'lsfabric' to lookup target_wwpns, active on the fabric, to be used to terminate the connection. However during a delete of a NPIV VM, the target_wwpns is no longer active, it is not logged onto the fabric. The target list will return empty. Fix is to return all the available wwpns from 'storage_nodes'. Change-Id: I39897f5583c878cc6243683d4bd60f800ea588af Closes-Bug: #1546281 --- cinder/tests/unit/test_storwize_svc.py | 24 ++++++++++++++++--- .../ibm/storwize_svc/storwize_svc_fc.py | 7 +++++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/cinder/tests/unit/test_storwize_svc.py b/cinder/tests/unit/test_storwize_svc.py index f510da8cf..013bdfa25 100644 --- a/cinder/tests/unit/test_storwize_svc.py +++ b/cinder/tests/unit/test_storwize_svc.py @@ -2292,12 +2292,30 @@ class StorwizeSVCFcDriverTestCase(test.TestCase): # Check that the initiator_target_map is as expected term_data = {'driver_volume_type': 'fibre_channel', 'data': {'initiator_target_map': - {'ff00000000000000': ['AABBCCDDEEFF0011'], - 'ff00000000000001': ['AABBCCDDEEFF0011']} + {'ff00000000000000': ['5005076802432ADE', + '5005076802332ADE', + '5005076802532ADE', + '5005076802232ADE', + '5005076802132ADE', + '5005086802132ADE', + '5005086802332ADE', + '5005086802532ADE', + '5005086802232ADE', + '5005086802432ADE'], + 'ff00000000000001': ['5005076802432ADE', + '5005076802332ADE', + '5005076802532ADE', + '5005076802232ADE', + '5005076802132ADE', + '5005086802132ADE', + '5005086802332ADE', + '5005086802532ADE', + '5005086802232ADE', + '5005086802432ADE']} } } - self.assertEqual(term_data, term_ret) + self.assertItemsEqual(term_data, term_ret) def test_storwize_svc_fc_host_maps(self): # Create two volumes to be used in mappings diff --git a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_fc.py b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_fc.py index d9f163eeb..762c98cc1 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_fc.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_fc.py @@ -291,7 +291,12 @@ class StorwizeSVCFCDriver(storwize_common.StorwizeSVCCommonDriver): "target map.")) # Build info data structure for zone removing if 'wwpns' in connector and host_name: - target_wwpns = self._helpers.get_conn_fc_wwpns(host_name) + target_wwpns = [] + # Returning all target_wwpns in storage_nodes, since + # we cannot determine which wwpns are logged in during + # a VM deletion. + for node in self._state['storage_nodes'].values(): + target_wwpns.extend(node['WWPN']) init_targ_map = (self._make_initiator_target_map (connector['wwpns'], target_wwpns)) -- 2.45.2