eLvErDe / hwraid

HWRaid: Free code from http://hwraid.le-vert.net
GNU General Public License v2.0
273 stars 103 forks source link

[megaclisas-status] reformat "drive model" in disk info blocks #105

Closed nega0 closed 5 years ago

nega0 commented 5 years ago

If the "drive model" looks seagate-ish, reformat it so it's more meaningful.

This:

-- Disk information --
-- ID   | Type | Drive Model                     | Size     | Status          | Speed    | Temp | Slot ID  | LSI ID
c0u0p0  | HDD  | Z2408KWYST2000DM001-1CH164 CC43 | 1.818 TB | Online, Spun Up | 6.0Gb/s  | 25C  | [58:1]   | 59
c0u0p1  | HDD  | Z4D07EZ3ST6000DX000-1H217Z CC47 | 5.457 TB | Online, Spun Up | 6.0Gb/s  | 31C  | [58:2]   | 60
c0u0p2  | HDD  | Z1E19S2QST2000DM001-1CH164 CC43 | 1.818 TB | Online, Spun Up | 6.0Gb/s  | 26C  | [58:3]   | 61
c0u0p3  | HDD  | 6XW02738ST32000542AS CC32       | 1.818 TB | Online, Spun Up | 3.0Gb/s  | 25C  | [58:4]   | 62
c0u0p4  | HDD  | Z4D07QPZST6000DX000-1H217Z CC47 | 5.457 TB | Online, Spun Up | 6.0Gb/s  | 30C  | [58:5]   | 63

becomes this:

-- Disk information --
-- ID   | Type | Drive Model                      | Size     | Status          | Speed    | Temp | Slot ID  | LSI ID
c0u0p0  | HDD  | ST2000DM001-1CH164 CC43 Z2408KWY | 1.818 TB | Online, Spun Up | 6.0Gb/s  | 25C  | [58:1]   | 59
c0u0p1  | HDD  | ST6000DX000-1H217Z CC47 Z4D07EZ3 | 5.457 TB | Online, Spun Up | 6.0Gb/s  | 31C  | [58:2]   | 60
c0u0p2  | HDD  | ST2000DM001-1CH164 CC43 Z1E19S2Q | 1.818 TB | Online, Spun Up | 6.0Gb/s  | 26C  | [58:3]   | 61
c0u0p3  | HDD  | ST32000542AS       CC32 6XW02738 | 1.818 TB | Online, Spun Up | 3.0Gb/s  | 25C  | [58:4]   | 62
C0rn3j commented 4 years ago

This change broke Python <2.6 support(which I am fine with, just noting a workaround).

If someone needs to support such ancient systems, they need to number the added format fields: https://docs.python.org/2/library/string.html#format-string-syntax

if m.group(3):
    model = '{0}-{1} {2} {3}'.format(m.group(2), m.group(3), m.group(4), m.group(1))
else:
    model = '{0} {1:>10} {2}'.format(m.group(2), m.group(4), m.group(1))
continue