fix ugly supermicro blade support (#178)

This commit is contained in:
Solvik 2020-12-15 11:32:11 +01:00 committed by GitHub
parent 0f2cb531ae
commit 77a84b365f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View file

@ -21,7 +21,7 @@ class SupermicroHost(ServerBase):
self.manufacturer = 'Supermicro'
def is_blade(self):
product_name = self.get_product_name()
product_name = self.system[0]['Product Name'].strip()
# Blades
blade = product_name.startswith('SBI')
blade |= product_name.startswith('SBA')
@ -44,19 +44,23 @@ class SupermicroHost(ServerBase):
return None
def get_service_tag(self):
if self.is_blade():
return self.baseboard[0]['Serial Number'].strip()
return self.system[0]['Serial Number'].strip()
def get_product_name(self):
if self.is_blade():
return self.baseboard[0]['Product Name'].strip()
return self.system[0]['Product Name'].strip()
def get_chassis(self):
if self.is_blade():
return self.chassis[0]['Product Name'].strip()
return self.system[0]['Product Name'].strip()
return self.get_product_name()
def get_chassis_service_tag(self):
if self.is_blade():
return self.chassis[0]['Serial Number'].strip()
return self.system[0]['Serial Number'].strip()
return self.get_service_tag()
def get_chassis_name(self):

View file

@ -49,6 +49,7 @@ def test_supermicro_blade(fixture):
server = SupermicroHost(dmi)
assert server.get_service_tag() == 'E235735X6B01665'
assert server.get_chassis_service_tag() == 'C9390AF40A20098'
assert server.get_chassis() == 'SYS-5039MS-H12TRF-OS012'
assert server.is_blade() is True
@ -60,6 +61,7 @@ def test_supermicro_pizza(fixture):
dmi = parse(fixture)
server = SupermicroHost(dmi)
assert server.get_service_tag() == 'A177950X7709591'
assert server.get_chassis() == 'SYS-6018R-TDTPR'
assert server.is_blade() is False