2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-13 11:17:47 +00:00

Get UUID of ThinkSystem D2 enclosures

If a ThinkSystem server is in a D2 enclosure, get
the UUID of the enclosure.

Change-Id: I3e2cf4b76306a2a7fce4fb655fc14c4c38306e84
This commit is contained in:
Jarrod Johnson 2017-09-13 11:49:39 -04:00
parent a676ff3bef
commit 40af456196
2 changed files with 13 additions and 1 deletions

View File

@ -21,11 +21,20 @@ import pyghmi.ipmi.private.session as ipmisession
import pyghmi.ipmi.private.util as util
import pyghmi.util.webclient as webclient
import random
import struct
import threading
import urllib
import weakref
def fixup_uuid(uuidprop):
baduuid = ''.join(uuidprop.split())
uuidprefix = (baduuid[:8], baduuid[8:12], baduuid[12:16])
a = struct.pack('<IHH', *[int(x, 16) for x in uuidprefix]).encode('hex')
uuid = (a[:8], a[8:12], a[12:16], baduuid[16:20], baduuid[20:])
return '-'.join(uuid).upper()
class FileUploader(threading.Thread):
def __init__(self, webclient, url, filename, data):
@ -293,6 +302,9 @@ class IMMClient(object):
if hwmap:
return hwmap
hwmap = {}
enclosureuuid = self.get_property('/v2/ibmc/smm/chassis/uuid')
if enclosureuuid:
hwmap['Enclosure'] = {'UUID': fixup_uuid(enclosureuuid)}
adapterdata = self.get_cached_data('lenovo_cached_adapters')
if not adapterdata:
if self.wc:

View File

@ -16,7 +16,7 @@ sitepackages = True
[testenv:pep8]
whitelist_externals = bash
commands = bash -c 'flake8 pyghmi bin/*'
commands = bash -c 'pep8 pyghmi bin/*'
[testenv:cover]
setenv = VIRTUAL_ENV={envdir}