blob: 988579093f05f2bcc660b228a4d8eb10e7048725 [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):
17 device The device to be passed to the hdparm and lsblk commands (e.g.
18 "/dev/sdb").
19
20 Example result:
21
22 sda_info:
23 [model_number]: MTFDDAK1T9TCB 00LY461 00LY570IBM
24 [serial_number]: 179C413F
25 [firmware_revision]: MJ06
26 [transport]: Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
27 [used]: unknown (minor revision code 0x006d)
28 [supported]: enhanced erase
29 [likely_used]: 10
30 [lba_user_addressable_sectors]: 268435455
31 [lba48_user_addressable_sectors]: 3750748848
32 [logical_sector_size]: 512 bytes
33 [physical_sector_size]: 4096 bytes
34 [logical_sector-0_offset]: 0 bytes
35 [device_size_with_m_=_1024*1024]: 1831420 MBytes
36 [device_size_with_m_=_1000*1000]: 1920383 MBytes (1920 GB)
37 [form_factor]: 2.5 inch
38 [nominal_media_rotation_rate]: Solid State Device
39 [queue_depth]: 32
40 [standby_timer_values]: spec'd by Standard, with device specific minimum
41 [r/w_multiple_sector_transfer]: Max = 16 Current = 16
42 [advanced_power_management_level]: 254
43 [dma]: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
44 [cycle_time]: no flow control=120ns IORDY flow control=120ns
45 [pio]: pio0 pio1 pio2 pio3 pio4
46 [security]:
47 [not_expired]: security count
48 [logical_unit_wwn_device_identifier]: 500a0751179c413f
49 [naa]: 5
50 [ieee_oui]: 00a075
51 [unique_id]: 1179c413f
52 [checksum]: correct
53 [name]: sda1
54 [maj:min]: 8:1
55 [rm]: 1
56 [size]: 4M
57 [ro]: 0
58 [type]: part
59 [mountpoint]:
60
61 """
62
63 cmd_buf = "hdparm -I " + device + " | egrep \":.+\" | sed -re" +\
64 " \"s/[ \t]+/ /g\""
65 stdout, stderr, rc = bsu.os_execute_command(cmd_buf)
66
67 firmware_dict = vf.key_value_outbuf_to_dict(stdout)
68
69 cmd_buf = "lsblk -P " + device + " | sed -re 's/\" /\"\\n/g'"
70 stdout, stderr, rc = bsu.os_execute_command(cmd_buf)
71 firmware_dict.update(vf.key_value_outbuf_to_dict(stdout, delim='=',
72 strip=" \""))
73
74 return firmware_dict