'Storwize driver delete vdisk copy error')
self._delete_volume(volume)
+ def test_storwize_initiator_target_map(self):
+ # Create two volumes to be used in mappings
+ ctxt = context.get_admin_context()
+
+ # Generate us a test volume
+ volume = self._generate_vol_info(None, None)
+ self.driver.create_volume(volume)
+
+ # FIbre Channel volume type
+ vol_type = volume_types.create(ctxt, 'FC', {'protocol': 'FC'})
+
+ volume['volume_type_id'] = vol_type['id']
+
+ # Make sure that the volumes have been created
+ self._assert_vol_exists(volume['name'], True)
+
+ wwpns = ['ff00000000000000', 'ff00000000000001']
+ connector = {'host': 'storwize-svc-test', 'wwpns': wwpns}
+
+ # Initialise the connection
+ init_ret = self.driver.initialize_connection(volume, connector)
+
+ # Check that the initiator_target_map is as expected
+ init_data = {'driver_volume_type': 'fibre_channel',
+ 'data': {'initiator_target_map':
+ {'ff00000000000000': ['AABBCCDDEEFF0011'],
+ 'ff00000000000001': ['AABBCCDDEEFF0011']},
+ 'target_discovered': False,
+ 'target_lun': '0',
+ 'target_wwn': 'AABBCCDDEEFF0011',
+ 'volume_id': volume['id']
+ }
+ }
+
+ self.assertEqual(init_data, init_ret)
+
+ # Terminate connection
+ term_ret = self.driver.terminate_connection(volume, connector)
+
+ # Check that the initiator_target_map is as expected
+ term_data = {'driver_volume_type': 'fibre_channel',
+ 'data': {'initiator_target_map':
+ {'ff00000000000000': ['AABBCCDDEEFF0011'],
+ 'ff00000000000001': ['AABBCCDDEEFF0011']}
+ }
+ }
+
+ self.assertEqual(term_data, term_ret)
+
class CLIResponseTestCase(test.TestCase):
def test_empty(self):
properties['target_wwn'] = conn_wwpns[0]
else:
properties['target_wwn'] = conn_wwpns
+
+ i_t_map = self._make_initiator_target_map(connector['wwpns'],
+ conn_wwpns)
+ properties['initiator_target_map'] = i_t_map
except Exception:
with excutils.save_and_reraise_exception():
self.terminate_connection(volume, connector)
return {'driver_volume_type': type_str, 'data': properties, }
+ def _make_initiator_target_map(self, initiator_wwpns, target_wwpns):
+ """Build a simplistic all-to-all mapping."""
+ i_t_map = {}
+ for i_wwpn in initiator_wwpns:
+ i_t_map[str(i_wwpn)] = []
+ for t_wwpn in target_wwpns:
+ i_t_map[i_wwpn].append(t_wwpn)
+
+ return i_t_map
+
@utils.synchronized('storwize-host', external=True)
def terminate_connection(self, volume, connector, **kwargs):
"""Cleanup after an iSCSI connection has been terminated.
# See bug #1244257
host_name = None
+ info = {}
+ if 'wwpns' in connector and host_name:
+ target_wwpns = self._helpers.get_conn_fc_wwpns(host_name)
+ init_targ_map = self._make_initiator_target_map(connector['wwpns'],
+ target_wwpns)
+ info = {'driver_volume_type': 'fibre_channel',
+ 'data': {'initiator_target_map': init_targ_map}}
+
self._helpers.unmap_vol_from_host(vol_name, host_name)
LOG.debug(_('leave: terminate_connection: volume %(vol)s with '
'connector %(conn)s') % {'vol': str(volume),
'conn': str(connector)})
+ return info
+
def create_volume(self, volume):
opts = self._get_vdisk_params(volume['volume_type_id'])
pool = self.configuration.storwize_svc_volpool_name