2

How do I retrieve dmidecode (type 204) information using Python dmidecode module?

I'm using Linux Redhat on HP Hardware.

Here's what I'm looking for (except that I want it via Python):

> dmidecode --type 204

# dmidecode 2.11
SMBIOS 2.7 present.

Handle 0xCC00, DMI type 204, 20 bytes
HP ProLiant System/Rack Locator
        Rack Name: UnnamedRack
        Enclosure Name: encdrp5
        Enclosure Model: BladeSystem c7000 Enclosure G3
        Enclosure Serial: xxxxxxxxx
        Enclosure Bays: 16
        Server Bay: 6
        Bays Filled: 1

I've tried this:

import dmidecode

dmidecode.type(204)

But I've got {}

Wandering Fool
  • 2,170
  • 3
  • 18
  • 48
tomikos
  • 51
  • 2
  • for dmidecode you need read permission on /dev/mem. does your user have that? – meuh Aug 14 '15 at 16:02
  • I'm using root, but anyway it's not a permission issue because i can fetch the information using "dmidecode" from the cli. it's more like unfeatured from python side. – tomikos Aug 14 '15 at 16:09
  • looks like it will only decode types it can convert to xml using the file `/usr/share/python-dmidecode/pymap.xml` (on my setup). – meuh Aug 14 '15 at 16:27
  • Dmidecode has a dict that maps type to name and drops all sections that are not in the map. That seams bizarre to me. 204 is an hp specific section so I can't test it but the offending line in parse_dmi is pretty obvious. Try removing it to see how it goes. – tdelaney Aug 14 '15 at 19:14
  • Can you give an example for how to do that? – tomikos Aug 15 '15 at 09:01
  • Actually my final goal is to obtain HP Facts like "Enclosure Name" and "Server Bay" via [tag:Ansible]. Any suggestions? – tomikos Aug 16 '15 at 15:52

0 Answers0