os-brick _get_hba_channel_scsi_target always return empty

Bug #1684996 reported by Chhavi Agarwal
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
os-brick
Fix Released
Undecided
Unassigned

Bug Description

Existing code of
https://github.com/openstack/os-brick/blob/master/os_brick/initiator/linuxfc.py#L52
cmd = 'grep %(wwnn)s %(path)s*/node_name' % {'wwnn': hba['node_name'],
                                                     'path': path}

cmd output will return the matching wwnn
[~]# grep 5005076802232ade /sys/class/fc_transport/target1:*/node_name
0x5005076802232ade

But the expected output is the matching file path returned, to get the clt.
return [line.split('/')[4].split(':')[1:]
                    for line in out.split('\n') if line.startswith(path)]

Proposed fix:
cmd should be executed using grep -l instead of grep
[ ~]# grep -l 5005076802232ade /sys/class/fc_transport/target1:*/node_name
/sys/class/fc_transport/target1:0:0/node_name
[~]#

Used the master branch of os-brick.

affects: cinder → os-brick
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to os-brick (master)

Reviewed: https://review.openstack.org/520052
Committed: https://git.openstack.org/cgit/openstack/os-brick/commit/?id=4ee404466d3f2ced8bfdfb18927ef19a27967952
Submitter: Zuul
Branch: master

commit 4ee404466d3f2ced8bfdfb18927ef19a27967952
Author: Gorka Eguileor <email address hidden>
Date: Wed Nov 8 21:03:08 2017 +0100

    Fixing FC scanning

    Current FC tries to limit the scanning range by detecting the target and
    channel, unfortunately this code has a good number of implementation
    issues:

    - Matching uses local WWNN instead of target's WWPN.
    - Not using a shell to run the command, so the * glob won't expand.
    - Not using -l on grep command to list file names instead of contents.
    - Not making the search case insensitive.

    This patch fixes all these issues by using the target's WWPNs instead
    -taking into account FC Zone/Access control information if present- and
    supporting both possible connection information formats for the WWPNs
    (single value or list of values).

    Rescan tests have been modified to adhere to unit tests best practices,
    where each test case only tests the specific code in the method under
    test and mocks everything else.

    Closes-Bug: #1664653
    Closes-Bug: #1684996
    Closes-Bug: #1687607
    Change-Id: Ib539f6a3652bab4399c30cd90f326829e839ec02

Changed in os-brick:
status: New → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/os-brick 2.3.0

This issue was fixed in the openstack/os-brick 2.3.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to os-brick (stable/pike)

Fix proposed to branch: stable/pike
Review: https://review.openstack.org/622348

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to os-brick (stable/pike)

Reviewed: https://review.openstack.org/622348
Committed: https://git.openstack.org/cgit/openstack/os-brick/commit/?id=f821a87ef0fd59cb1b48a85eed16b1f3f16e7467
Submitter: Zuul
Branch: stable/pike

commit f821a87ef0fd59cb1b48a85eed16b1f3f16e7467
Author: Gorka Eguileor <email address hidden>
Date: Wed Nov 8 21:03:08 2017 +0100

    Fixing FC scanning

    Current FC tries to limit the scanning range by detecting the target and
    channel, unfortunately this code has a good number of implementation
    issues:

    - Matching uses local WWNN instead of target's WWPN.
    - Not using a shell to run the command, so the * glob won't expand.
    - Not using -l on grep command to list file names instead of contents.
    - Not making the search case insensitive.

    This patch fixes all these issues by using the target's WWPNs instead
    -taking into account FC Zone/Access control information if present- and
    supporting both possible connection information formats for the WWPNs
    (single value or list of values).

    Rescan tests have been modified to adhere to unit tests best practices,
    where each test case only tests the specific code in the method under
    test and mocks everything else.

    Closes-Bug: #1664653
    Closes-Bug: #1684996
    Closes-Bug: #1687607
    Change-Id: Ib539f6a3652bab4399c30cd90f326829e839ec02
    (cherry picked from commit 4ee404466d3f2ced8bfdfb18927ef19a27967952)

tags: added: in-stable-pike
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/os-brick 1.15.7

This issue was fixed in the openstack/os-brick 1.15.7 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.