s390 FC device path fix for Ubuntu

This fix solves a LUN attachment error for Ubuntu on s390 host setups. Fiber
Channel requires a path for discovery of new devices, and Ubuntu uses a
different format than previously assumed. This can be solved by simply adding
the Ubuntu-style path to the list of possible paths, since they get quietly
dropped if they lead nowhere in FibreChannelConnector._get_possible_volume_paths
anyways.

Change-Id: I0b07572903263122213f2ea5dc42151a7b69d99f
Closes-Bug: #1655047
This commit is contained in:
Andreas Scheuring 2016-12-21 16:21:52 +01:00 committed by Arne Recknagel
parent 58956d7c86
commit df634a5fde
2 changed files with 20 additions and 10 deletions

View File

@ -49,14 +49,16 @@ class FibreChannelConnectorS390X(fibre_channel.FibreChannelConnector):
def _get_host_devices(self, possible_devs, lun):
host_devices = []
for pci_num, target_wwn in possible_devs:
target_lun = self._get_lun_string(lun)
host_device = self._get_device_file_path(
pci_num,
target_wwn,
target_lun)
lun)
# NOTE(arne_r)
# LUN driver path is the same on all distros, so no need to have
# multiple calls here
self._linuxfc.configure_scsi_device(pci_num, target_wwn,
target_lun)
host_devices.append(host_device)
self._get_lun_string(lun))
host_devices.extend(host_device)
return host_devices
def _get_lun_string(self, lun):
@ -67,11 +69,17 @@ class FibreChannelConnectorS390X(fibre_channel.FibreChannelConnector):
target_lun = "0x%08x00000000" % lun
return target_lun
def _get_device_file_path(self, pci_num, target_wwn, target_lun):
host_device = "/dev/disk/by-path/ccw-%s-zfcp-%s:%s" % (
pci_num,
target_wwn,
target_lun)
def _get_device_file_path(self, pci_num, target_wwn, lun):
# NOTE(arne_r)
# Need to add two possible ways to resolve device paths,
# depending on OS. Since it gets passed to '_get_possible_volume_paths'
# having a mismatch is not a problem
host_device = [
"/dev/disk/by-path/ccw-%s-zfcp-%s:%s" % (
pci_num, target_wwn, self._get_lun_string(lun)),
"/dev/disk/by-path/ccw-%s-fc-%s-lun-%s" % (
pci_num, target_wwn, lun),
]
return host_device
def _remove_devices(self, connection_properties, devices):

View File

@ -37,9 +37,11 @@ class FibreChannelConnectorS390XTestCase(test_connector.ConnectorTestCase):
devices = self.connector._get_host_devices(possible_devs, lun)
mock_configure_scsi_device.assert_called_with(3, 5,
"0x0002000000000000")
self.assertEqual(1, len(devices))
self.assertEqual(2, len(devices))
device_path = "/dev/disk/by-path/ccw-3-zfcp-5:0x0002000000000000"
self.assertEqual(devices[0], device_path)
device_path = "/dev/disk/by-path/ccw-3-fc-5-lun-2"
self.assertEqual(devices[1], device_path)
def test_get_lun_string(self):
lun = 1