self.data.test_volume['volume_type_id'] = None
self.driver.create_volume(self.data.test_volume)
- output = {'driver_volume_type': 'fibre_channel',
- 'data': {'target_lun': 0,
- 'target_wwn': ['1234567890123', '0987654321321'],
- 'target_discovered': True}}
+ output = {
+ 'driver_volume_type': 'fibre_channel',
+ 'data': {
+ 'target_lun': 0,
+ 'target_wwn': ['1234567890123', '0987654321321'],
+ 'target_discovered': True,
+ 'initiator_target_map': {'123456789012345':
+ ['1234567890123', '0987654321321'],
+ '123456789054321':
+ ['1234567890123', '0987654321321'],
+ }}}
+
connection_info = self.driver.initialize_connection(
self.data.test_volume,
self.data.connector)
self.assertEqual(connection_info, output)
- self.driver.terminate_connection(self.data.test_volume,
- self.data.connector)
+ connection_info = self.driver.terminate_connection(
+ self.data.test_volume,
+ self.data.connector)
+
+ # Verify calls in terminate_connection are executed
+ conf_service = {}
+ conf_service['SystemName'] = self.data.storage_system
+ conf_service['CreationClassName'] =\
+ self.data.ctrlconf_service_creationclass
+
+ vol_instance = self.driver.common._find_lun(self.data.test_volume)
+
+ expected = [
+ mock.call._get_ecom_connection(),
+ mock.call.find_device_number(self.data.test_volume),
+ mock.call._find_lun(self.data.test_volume),
+ mock.call.self._find_controller_configuration_service(
+ self.data.storage_system),
+ mock.call._remove_members(conf_service, vol_instance),
+ mock.call.get_target_wwns(
+ self.data.storage_system,
+ self.data.connector)]
+
+ output = {
+ 'driver_volume_type': 'fibre_channel',
+ 'data': {
+ 'target_wwn': ['1234567890123', '0987654321321'],
+ 'initiator_target_map': {'123456789012345':
+ ['1234567890123', '0987654321321'],
+ '123456789054321':
+ ['1234567890123', '0987654321321'],
+ }}}
+
+ self.assertEqual(connection_info, output)
+
self.driver.delete_volume(self.data.test_volume)
def test_create_volume_failed(self):
connector)
device_number = device_info['hostlunid']
storage_system = device_info['storagesystem']
- ports = self.common.get_target_wwns(storage_system, connector)
+ target_wwns, init_targ_map = self._build_initiator_target_map(
+ storage_system, connector)
data = {'driver_volume_type': 'fibre_channel',
'data': {'target_lun': device_number,
'target_discovered': True,
- 'target_wwn': ports}}
+ 'target_wwn': target_wwns,
+ 'initiator_target_map': init_targ_map}}
LOG.debug(_('Return FC data: %(data)s.')
% {'data': data})
"""Disallow connection from connector."""
self.common.terminate_connection(volume, connector)
+ loc = volume['provider_location']
+ name = eval(loc)
+ storage_system = name['keybindings']['SystemName']
+ target_wwns, init_targ_map = self._build_initiator_target_map(
+ storage_system, connector)
+ data = {'driver_volume_type': 'fibre_channel',
+ 'data': {'target_wwn': target_wwns,
+ 'initiator_target_map': init_targ_map}}
+
+ LOG.debug(_('Return FC data: %(data)s.')
+ % {'data': data})
+
+ return data
+
+ def _build_initiator_target_map(self, storage_system, connector):
+ """Build the target_wwns and the initiator target map."""
+
+ target_wwns = self.common.get_target_wwns(storage_system, connector)
+
+ initiator_wwns = connector['wwpns']
+
+ init_targ_map = {}
+ for initiator in initiator_wwns:
+ init_targ_map[initiator] = target_wwns
+
+ return target_wwns, init_targ_map
+
def extend_volume(self, volume, new_size):
"""Extend an existing volume."""
self.common.extend_volume(volume, new_size)