Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Fix sg_inq parsing the WWN during the device discovery. #195

Merged
merged 5 commits into from
Mar 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions remote/mounter/block_device_utils/block_device_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,26 @@ mpathhb (36001738cfc9035eb0000000000cea###) dm-3 ##,##
Expect(cmd).To(Equal("sg_inq"))
Expect(args).To(Equal([]string{"-p", "0x83", dev}))
})
It("should return wwn for mpath device on zLinux output", func() {
dev := "dev"
expecedWwn := "0x6001738cfc9035eb0000000000AAAAAA"
result := fmt.Sprintf(`VPD INQUIRY: Device Identification page
Designation descriptor number 1, descriptor length: 20
designator_type: NAA, code_set: Binary
associated with the addressed logical unit
NAA 6, IEEE Company_id: 0x1738
Vendor Specific Identifier: 0xcfc9035eb
Vendor Specific Extension Identifier: 0xcea5f6
[%s]`, expecedWwn)
fakeExec.ExecuteWithTimeoutReturns([]byte(fmt.Sprintf("%s", result)), nil)
wwn, err := bdUtils.GetWwnByScsiInq(dev)
Expect(err).ToNot(HaveOccurred())
Expect(wwn).To(Equal(strings.TrimPrefix(expecedWwn, "0x")))
Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(1))
_, cmd, args := fakeExec.ExecuteWithTimeoutArgsForCall(0)
Expect(cmd).To(Equal("sg_inq"))
Expect(args).To(Equal([]string{"-p", "0x83", dev}))
})
It("should not find wwn for device", func() {
dev := "dev"
expecedWwn := "6001738cfc9035eb0000000000AAAAAA"
Expand Down
6 changes: 5 additions & 1 deletion remote/mounter/block_device_utils/mpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ func (b *blockDeviceUtils) GetWwnByScsiInq(dev string) (string, error) {
if err != nil {
return "", b.logger.ErrorRet(err, "failed")
}
pattern := "(?i)" + "Vendor Specific Identifier Extension:"
/*
sg_inq on device NAA6 returns "Vendor Specific Identifier Extension"
sg_inq on device EUI-64 returns "Vendor Specific Extension Identifier".
*/
pattern := "(?i)" + "Vendor Specific (Identifier Extension|Extension Identifier):"
scanner := bufio.NewScanner(strings.NewReader(string(outputBytes[:])))
regex, err := regexp.Compile(pattern)
if err != nil {
Expand Down