Naudit / pystorcli2

Python library provides wrapper around storcli tool to manage and control LSI MegaRAID controllers.
BSD 3-Clause "New" or "Revised" License
2 stars 7 forks source link

Format attributes #3

Closed ulmitov closed 1 year ago

ulmitov commented 1 year ago

Hi,

Currenlty the serial, model and other fields are not being formatted and have white spaces and different letter case. Please apply space stripping and to upper() format. One of purposes for this is also to have same formatting like in pySMART

Example:

In [9]: print(d['megaraid,23'].hba_obj.facts)
{'Drive /c0/e252/s3': [{'EID:Slt': '252:3', 'DID': 23, 'State': 'UGood', 'DG': '-', 'Size': '446.625 GB', 'Intf': 'SATA', 'Med': 'SSD', 'SED': 'N', 'PI': 'N', 'SeSz': '512B', 'Model': 'INTEL SSDSC2KB480G8', 'Sp': 'U', 'Type': '-'}], 'Drive /c0/e252/s3 - Detailed Information': {'Drive /c0/e252/s3 State': {'Shield Counter': 0, 'Media Error Count': 0, 'Other Error Count': 0, 'Drive Temperature': ' 24C (75.20 F)', 'Predictive Failure Count': 0, 'S.M.A.R.T alert flagged by drive': 'No'}, 'Drive /c0/e252/s3 Device attributes': {'SN': 'PHYF1100065U480BGN  ', 'Manufacturer Id': 'ATA     ', 'Model Number': 'INTEL SSDSC2KB480G8', 'NAND Vendor': 'NA', 'WWN': '55CD2E415339189F', 'Firmware Revision': 'XCV10132', 'Raw size': '447.130 GB [0x37e436b0 Sectors]', 'Coerced size': '446.625 GB [0x37d40000 Sectors]', 'Non Coerced size': '446.630 GB [0x37d436b0 Sectors]', 'Device Speed': '6.0Gb/s', 'Link Speed': '6.0Gb/s', 'NCQ setting': 'Enabled', 'Write Cache': 'N/A', 'Logical Sector Size': '512B', 'Physical Sector Size': '4 KB', 'Connector Name': 'Port 0 - 3 x1'}, 'Drive /c0/e252/s3 Policies/Settings': {'Enclosure position': '1', 'Connected Port Number': '8(path0) ', 'Sequence Number': 35, 'Commissioned Spare': 'No', 'Emergency Spare': 'No', 'Last Predictive Failure Event Sequence Number': 0, 'Successful diagnostics completion on': 'N/A', 'FDE Type': 'None', 'SED Capable': 'No', 'SED Enabled': 'No', 'Secured': 'No', 'Cryptographic Erase Capable': 'Yes', 'Sanitize Support': 'Not supported', 'Locked': 'No', 'Needs EKM Attention': 'No', 'PI Eligible': 'No', 'Certified': 'No', 'Wide Port Capable': 'No', 'Multipath': 'No', 'Port Information': [{'Port': 0, 'Status': 'Active', 'Linkspeed': '6.0Gb/s', 'SAS address': '0x4433221108000000'}]}, 'Inquiry Data': '40 00 ff 3f 37 c8 10 00 00 00 00 00 3f 00 00 00 00 00 00 00 48 50 46 59 31 31 30 30 36 30 55 35 38 34 42 30 4e 47 20 20 00 00 00 00 00 00 43 58 31 56 31 30 32 33 4e 49 45 54 20 4c 53 53 53 44 32 43 42 4b 38 34 47 30 20 38 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 01 80 00 40 00 2f 00 40 00 00 00 00 06 00 ff 3f 10 00 3f 00 10 fc fb 00 01 fd ff ff ff 0f 00 00 07 00 '}}

In [5]: d['megaraid,23'].hba_obj.serial
Out[5]: 'PHYF1100065U480BGN  '

In [6]: d['megaraid,23'].hba_obj.model
Out[6]: 'intel ssdsc2kb480g8'

( in this code hba_obj is an added attribute to pySMART.Drive which holds the pystorcli.Drive object )

ralequi commented 1 year ago

The output is returned in JSON format, and I don't think edit it is a good idea.

I will accept the strip but I should not do the upper() one

ralequi commented 1 year ago

ok, I see there is a @common.lower there... Maybe the upper is a better idea, accepted

ralequi commented 1 year ago

hi @ulmitov

Please, check on the develop branch if that fix is enough or tell me you need other upper/strips

ulmitov commented 1 year ago

@ralequi works great, thanks!