Handle FC LUN IDs greater 255 correctly on s390x architectures

FC LUN IDs betfeen 100 hex and ffff hex need to be formatted correctly
for the unit_add command. Otherwise, the volume will not be added to the
hypervisor configuration and the hypervisor will not be able to perform
I/O to it.

Closes-Bug: #1488233

Change-Id: Iaa0ead59132d6baf8bcb9e3dd95d4839c26e93ea
This commit is contained in:
Stefan Amann 2015-08-24 22:19:18 +02:00
parent bc5d18f234
commit 75d1f38e3b
2 changed files with 16 additions and 2 deletions

View File

@ -1065,8 +1065,8 @@ class FibreChannelConnectorS390X(FibreChannelConnector):
def _get_lun_string(self, lun):
target_lun = 0
if lun < 256:
target_lun = "0x00%02x000000000000" % lun
if lun <= 0xffff:
target_lun = "0x%04x000000000000" % lun
elif lun <= 0xffffffff:
target_lun = "0x%08x00000000" % lun
return target_lun

View File

@ -1002,6 +1002,20 @@ class FibreChannelConnectorS390XTestCase(ConnectorTestCase):
device_path = "/dev/disk/by-path/ccw-3-zfcp-5:0x0002000000000000"
self.assertEqual(devices[0], device_path)
def test_get_lun_string(self):
lun = 1
lunstring = self.connector._get_lun_string(lun)
self.assertEqual(lunstring, "0x0001000000000000")
lun = 0xff
lunstring = self.connector._get_lun_string(lun)
self.assertEqual(lunstring, "0x00ff000000000000")
lun = 0x101
lunstring = self.connector._get_lun_string(lun)
self.assertEqual(lunstring, "0x0101000000000000")
lun = 0x4020400a
lunstring = self.connector._get_lun_string(lun)
self.assertEqual(lunstring, "0x4020400a00000000")
@mock.patch.object(connector.FibreChannelConnectorS390X,
'_get_possible_devices', return_value=[(3, 5), ])
@mock.patch.object(linuxfc.LinuxFibreChannelS390X, 'get_fc_hbas_info',