Add HP Moonshot 1500 support #161

Merged
cyrinux merged 3 commits from add_moonshot_1500_bis into master 2020-08-20 18:03:37 +02:00
2 changed files with 25 additions and 14 deletions
Showing only changes of commit 80eb08e672 - Show all commits

View file

@ -202,6 +202,7 @@ Tested on:
* HP ProLiant BL460c Gen8
* HP ProLiant BL460c Gen9
* HP ProLiant BL460c Gen10
* HP Moonshot 1500 Enclosure (your `DeviceType` should have slots batch create with `Bay c[1-45n1]`) with HP ProLiant m710x Server Cartridge
### Pizzas

View file

@ -7,10 +7,11 @@ class HPHost(ServerBase):
super(HPHost, self).__init__(*args, **kwargs)
if self.is_blade():
self.hp_rack_locator = self._find_rack_locator()
self.manufacturer = 'HP'
self.manufacturer = "HP"
def is_blade(self):
return self.get_product_name().startswith('ProLiant BL')
products = ("ProLiant BL", "ProLiant m710x")
return self.get_product_name().startswith(products)
def _find_rack_locator(self):
"""
@ -21,34 +22,43 @@ class HPHost(ServerBase):
# FIXME: make a dmidecode function get_by_dminame() ?
if self.is_blade():
locator = dmidecode.get_by_type(self.dmi, 204)
if self.get_product_name() == 'ProLiant BL460c Gen10':
locator = locator[0]['Strings']
if self.get_product_name() == "ProLiant BL460c Gen10":
locator = locator[0]["Strings"]
return {
'Enclosure Model': locator[2].strip(),
'Enclosure Name': locator[0].strip(),
'Server Bay': locator[3].strip(),
'Enclosure Serial': locator[4].strip(),
"Enclosure Model": locator[2].strip(),
"Enclosure Name": locator[0].strip(),
"Server Bay": locator[3].strip(),
"Enclosure Serial": locator[4].strip(),
}
if self.get_product_name() == "ProLiant m710x Server Cartridge":
locator = dmidecode.get_by_type(self.dmi, 2)
chassis = dmidecode.get_by_type(self.dmi, 3)
return {
"Enclosure Model": "Moonshot 1500 Chassis",
"Enclosure Name": "Unknown",
"Server Bay": locator[0]["Location In Chassis"].strip(),
"Enclosure Serial": chassis[0]["Serial Number"].strip(),
}
return locator[0]
def get_blade_slot(self):
if self.is_blade():
return 'Bay {}'.format(
int(self.hp_rack_locator['Server Bay'].strip())
)
return "Bay {}".format(str(self.hp_rack_locator["Server Bay"].strip()))
return None
def get_chassis(self):
if self.is_blade():
return self.hp_rack_locator['Enclosure Model'].strip()
return self.hp_rack_locator["Enclosure Model"].strip()
return self.get_product_name()
def get_chassis_name(self):
if not self.is_blade():
return None
return self.hp_rack_locator['Enclosure Name'].strip()
return self.hp_rack_locator["Enclosure Name"].strip()
def get_chassis_service_tag(self):
if self.is_blade():
return self.hp_rack_locator['Enclosure Serial'].strip()
return self.hp_rack_locator["Enclosure Serial"].strip()
return self.get_service_tag()