Perform port_rescan on s390x platforms

When adding Fibre-Channel block storage on Linux on System z and
auto-port scanning has been turned off, Fibre-channel target ports need
to be added explicitely by OpenStack. If this is not done, OpenStack
will fail to add volumes.

Closes-Bug: #1475648

Change-Id: I4a8c9ee256add1ddd27359f42f4a97b45aebebcd
This commit is contained in:
Stefan Amann
2015-07-17 15:25:48 +02:00
parent e43d08006c
commit c10751acb1
2 changed files with 23 additions and 3 deletions

View File

@@ -15,6 +15,7 @@
"""Generic linux Fibre Channel utilities."""
import errno
import os
from oslo_concurrency import processutils as putils
from oslo_log import log as logging
@@ -169,6 +170,9 @@ class LinuxFibreChannelS390X(LinuxFibreChannel):
def configure_scsi_device(self, device_number, target_wwn, lun):
"""Write the LUN to the port's unit_add attribute.
If auto-discovery of Fibre-Channel target ports is
disabled on s390 platforms, ports need to be added to
the configuration.
If auto-discovery of LUNs is disabled on s390 platforms
luns need to be added to the configuration through the
unit_add interface
@@ -178,6 +182,19 @@ class LinuxFibreChannelS390X(LinuxFibreChannel):
{'device_num': device_number,
'target_wwn': target_wwn,
'target_lun': lun})
filepath = ("/sys/bus/ccw/drivers/zfcp/%s/%s" %
(device_number, target_wwn))
if not (os.path.exists(filepath)):
zfcp_device_command = ("/sys/bus/ccw/drivers/zfcp/%s/port_rescan" %
(device_number))
LOG.debug("port_rescan call for s390: %s", zfcp_device_command)
try:
self.echo_scsi_command(zfcp_device_command, "1")
except putils.ProcessExecutionError as exc:
LOG.warning(_LW("port_rescan call for s390 failed exit"
" %(code)s, stderr %(stderr)s"),
{'code': exc.exit_code, 'stderr': exc.stderr})
zfcp_device_command = ("/sys/bus/ccw/drivers/zfcp/%s/%s/unit_add" %
(device_number, target_wwn))
LOG.debug("unit_add call for s390 execute: %s", zfcp_device_command)

View File

@@ -195,13 +195,16 @@ class LinuxFCS390XTestCase(LinuxFCTestCase):
'port_name': 'c05076ffe680a960'}]
self.assertEqual(expected, hbas_info)
def test_configure_scsi_device(self):
@mock.patch.object(os.path, 'exists', return_value=False)
def test_configure_scsi_device(self, mock_execute):
device_number = "0.0.2319"
target_wwn = "0x50014380242b9751"
lun = 1
self.lfc.configure_scsi_device(device_number, target_wwn, lun)
expected_commands = [('tee -a /sys/bus/ccw/drivers/zfcp/'
'0.0.2319/0x50014380242b9751/unit_add')]
expected_commands = [('tee -a /sys/bus/ccw/drivers/zfcp/0.0.2319/'
'port_rescan'),
('tee -a /sys/bus/ccw/drivers/zfcp/0.0.2319/'
'0x50014380242b9751/unit_add')]
self.assertEqual(expected_commands, self.cmds)
def test_deconfigure_scsi_device(self):