blob: 99ad7c6acd1190d01b33895d722e21abdcc85707 [file] [log] [blame]
Michael Walsh17007272018-02-09 15:01:12 -06001#!/usr/bin/env python
2
3r"""
4This module contains functions which pertain to firmware.
5"""
6
7import bmc_ssh_utils as bsu
8import var_funcs as vf
9
10
11def get_hard_disk_info(device="/dev/sdb"):
Michael Walsh17007272018-02-09 15:01:12 -060012 r"""
13 Get firmware information for the given device on the OS and return it as a
14 dictionary.
15
16 Description of argument(s):
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050017 device The device to be passed to the hdparm and
18 lsblk commands (e.g. "/dev/sdb").
Michael Walsh17007272018-02-09 15:01:12 -060019
20 Example result:
21
22 sda_info:
George Keishing19700762020-01-22 12:32:53 -060023 [model_number]: MTFDDAK1T9TCB 00LY461 00LY570XXX
Michael Walsh17007272018-02-09 15:01:12 -060024 [serial_number]: 179C413F
25 [firmware_revision]: MJ06
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050026 [transport]: Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5,
27 SATA Rev 2.6, SATA Rev 3.0
Michael Walsh17007272018-02-09 15:01:12 -060028 [used]: unknown (minor revision code 0x006d)
29 [supported]: enhanced erase
30 [likely_used]: 10
31 [lba_user_addressable_sectors]: 268435455
32 [lba48_user_addressable_sectors]: 3750748848
33 [logical_sector_size]: 512 bytes
34 [physical_sector_size]: 4096 bytes
35 [logical_sector-0_offset]: 0 bytes
36 [device_size_with_m_=_1024*1024]: 1831420 MBytes
37 [device_size_with_m_=_1000*1000]: 1920383 MBytes (1920 GB)
38 [form_factor]: 2.5 inch
39 [nominal_media_rotation_rate]: Solid State Device
40 [queue_depth]: 32
41 [standby_timer_values]: spec'd by Standard, with device specific minimum
42 [r/w_multiple_sector_transfer]: Max = 16 Current = 16
43 [advanced_power_management_level]: 254
44 [dma]: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
45 [cycle_time]: no flow control=120ns IORDY flow control=120ns
46 [pio]: pio0 pio1 pio2 pio3 pio4
47 [security]:
48 [not_expired]: security count
49 [logical_unit_wwn_device_identifier]: 500a0751179c413f
50 [naa]: 5
51 [ieee_oui]: 00a075
52 [unique_id]: 1179c413f
53 [checksum]: correct
54 [name]: sda1
55 [maj:min]: 8:1
56 [rm]: 1
57 [size]: 4M
58 [ro]: 0
59 [type]: part
60 [mountpoint]:
61
62 """
63
64 cmd_buf = "hdparm -I " + device + " | egrep \":.+\" | sed -re" +\
65 " \"s/[ \t]+/ /g\""
66 stdout, stderr, rc = bsu.os_execute_command(cmd_buf)
67
68 firmware_dict = vf.key_value_outbuf_to_dict(stdout)
69
70 cmd_buf = "lsblk -P " + device + " | sed -re 's/\" /\"\\n/g'"
71 stdout, stderr, rc = bsu.os_execute_command(cmd_buf)
72 firmware_dict.update(vf.key_value_outbuf_to_dict(stdout, delim='=',
73 strip=" \""))
74
75 return firmware_dict