2020-02-16 20:24:40 +01:00
|
|
|
import netbox_agent.dmidecode as dmidecode
|
2019-08-02 18:39:05 +02:00
|
|
|
from netbox_agent.server import ServerBase
|
2022-02-21 18:12:16 +01:00
|
|
|
from netbox_agent.inventory import Inventory
|
2019-08-02 18:39:05 +02:00
|
|
|
|
2019-08-04 00:00:22 +02:00
|
|
|
|
2019-08-03 15:46:21 +02:00
|
|
|
class HPHost(ServerBase):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(HPHost, self).__init__(*args, **kwargs)
|
2020-08-20 18:03:36 +02:00
|
|
|
self.manufacturer = "HP"
|
|
|
|
self.product = self.get_product_name()
|
2019-08-03 15:46:21 +02:00
|
|
|
if self.is_blade():
|
|
|
|
self.hp_rack_locator = self._find_rack_locator()
|
|
|
|
|
|
|
|
def is_blade(self):
|
2020-09-18 12:29:17 +02:00
|
|
|
blade = self.product.startswith("ProLiant BL")
|
2021-05-18 13:59:04 +02:00
|
|
|
blade |= self.product.startswith("ProLiant m") and \
|
|
|
|
self.product.endswith("Server Cartridge")
|
2020-09-18 12:29:17 +02:00
|
|
|
return blade
|
2019-08-03 15:46:21 +02:00
|
|
|
|
|
|
|
def _find_rack_locator(self):
|
2019-08-04 00:00:22 +02:00
|
|
|
"""
|
2019-08-03 15:46:21 +02:00
|
|
|
Depending on the server, the type of the `HP ProLiant System/Rack Locator`
|
|
|
|
can change.
|
|
|
|
So we need to find it every time
|
2019-08-04 00:00:22 +02:00
|
|
|
"""
|
2019-08-03 15:46:21 +02:00
|
|
|
# FIXME: make a dmidecode function get_by_dminame() ?
|
|
|
|
if self.is_blade():
|
2020-02-16 20:24:40 +01:00
|
|
|
locator = dmidecode.get_by_type(self.dmi, 204)
|
2020-09-18 12:29:17 +02:00
|
|
|
if self.product.startswith("ProLiant BL460c Gen10"):
|
2020-08-20 18:03:36 +02:00
|
|
|
locator = locator[0]["Strings"]
|
2019-08-21 16:17:01 +02:00
|
|
|
return {
|
2020-08-20 18:03:36 +02:00
|
|
|
"Enclosure Model": locator[2].strip(),
|
|
|
|
"Enclosure Name": locator[0].strip(),
|
|
|
|
"Server Bay": locator[3].strip(),
|
|
|
|
"Enclosure Serial": locator[4].strip(),
|
2020-02-02 20:08:56 +01:00
|
|
|
}
|
2020-08-20 18:03:36 +02:00
|
|
|
|
|
|
|
# HP ProLiant m750, m710x, m510 Server Cartridge
|
|
|
|
if self.product.startswith("ProLiant m") and self.product.endswith("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(),
|
|
|
|
}
|
|
|
|
|
2019-08-21 16:17:01 +02:00
|
|
|
return locator[0]
|
2019-08-03 15:46:21 +02:00
|
|
|
|
|
|
|
def get_blade_slot(self):
|
|
|
|
if self.is_blade():
|
2020-08-20 18:03:36 +02:00
|
|
|
return "Bay {}".format(str(self.hp_rack_locator["Server Bay"].strip()))
|
2019-08-03 15:46:21 +02:00
|
|
|
return None
|
|
|
|
|
|
|
|
def get_chassis(self):
|
|
|
|
if self.is_blade():
|
2020-08-20 18:03:36 +02:00
|
|
|
return self.hp_rack_locator["Enclosure Model"].strip()
|
2019-08-03 15:46:21 +02:00
|
|
|
return self.get_product_name()
|
|
|
|
|
2019-08-08 14:37:02 +02:00
|
|
|
def get_chassis_name(self):
|
|
|
|
if not self.is_blade():
|
|
|
|
return None
|
2020-08-20 18:03:36 +02:00
|
|
|
return self.hp_rack_locator["Enclosure Name"].strip()
|
2019-08-08 14:37:02 +02:00
|
|
|
|
2019-08-03 15:46:21 +02:00
|
|
|
def get_chassis_service_tag(self):
|
|
|
|
if self.is_blade():
|
2020-08-20 18:03:36 +02:00
|
|
|
return self.hp_rack_locator["Enclosure Serial"].strip()
|
2019-08-03 15:46:21 +02:00
|
|
|
return self.get_service_tag()
|
2020-09-18 12:29:17 +02:00
|
|
|
|
Manage blade expansions as independent devices
This patch adds the ability to detect and manage GPU and Disk expansion
bays, and either add their internal components into the device
corresponding to the blade server, or into a dedicated device.
It takes advantage of the work made by @cyrinux on GPU bays management, and
applies the same principle to the external disk bays, but harmonize the
inventory management:
- If no argument is specified on the command line, the GPU cards, RAID
controllers and their attached disks are added in the blade device,
and the device corresponding to an expansion device is deleted.
- If the `--expansion-as-device` option is specified on the command
line, a dedicated device corresponding to the expansion bay is
created, and the GPUs, RAID card and attached disks are removed from
the blade device and added to the expansion device.
2022-02-11 18:22:13 +01:00
|
|
|
def get_blade_expansion_slot(self):
|
|
|
|
"""
|
|
|
|
Expansion slot are always the compute bay number + 1
|
|
|
|
"""
|
|
|
|
if self.is_blade() and self.own_gpu_expansion_slot() or \
|
|
|
|
self.own_disk_expansion_slot() or True:
|
|
|
|
return 'Bay {}'.format(
|
|
|
|
str(int(self.hp_rack_locator['Server Bay'].strip()) + 1)
|
|
|
|
)
|
|
|
|
return None
|
|
|
|
|
2020-09-18 12:29:17 +02:00
|
|
|
def get_expansion_product(self):
|
|
|
|
"""
|
|
|
|
Get the extension slot that is on a pair slot number
|
|
|
|
next to the compute slot that is on an odd slot number
|
|
|
|
I only know on model of slot GPU extension card that.
|
|
|
|
"""
|
Manage blade expansions as independent devices
This patch adds the ability to detect and manage GPU and Disk expansion
bays, and either add their internal components into the device
corresponding to the blade server, or into a dedicated device.
It takes advantage of the work made by @cyrinux on GPU bays management, and
applies the same principle to the external disk bays, but harmonize the
inventory management:
- If no argument is specified on the command line, the GPU cards, RAID
controllers and their attached disks are added in the blade device,
and the device corresponding to an expansion device is deleted.
- If the `--expansion-as-device` option is specified on the command
line, a dedicated device corresponding to the expansion bay is
created, and the GPUs, RAID card and attached disks are removed from
the blade device and added to the expansion device.
2022-02-11 18:22:13 +01:00
|
|
|
if self.own_gpu_expansion_slot():
|
2020-09-18 12:29:17 +02:00
|
|
|
return "ProLiant BL460c Graphics Expansion Blade"
|
Manage blade expansions as independent devices
This patch adds the ability to detect and manage GPU and Disk expansion
bays, and either add their internal components into the device
corresponding to the blade server, or into a dedicated device.
It takes advantage of the work made by @cyrinux on GPU bays management, and
applies the same principle to the external disk bays, but harmonize the
inventory management:
- If no argument is specified on the command line, the GPU cards, RAID
controllers and their attached disks are added in the blade device,
and the device corresponding to an expansion device is deleted.
- If the `--expansion-as-device` option is specified on the command
line, a dedicated device corresponding to the expansion bay is
created, and the GPUs, RAID card and attached disks are removed from
the blade device and added to the expansion device.
2022-02-11 18:22:13 +01:00
|
|
|
elif self.own_disk_expansion_slot():
|
|
|
|
return "ProLiant BL460c Disk Expansion Blade"
|
2020-09-18 12:29:17 +02:00
|
|
|
return None
|
|
|
|
|
Manage blade expansions as independent devices
This patch adds the ability to detect and manage GPU and Disk expansion
bays, and either add their internal components into the device
corresponding to the blade server, or into a dedicated device.
It takes advantage of the work made by @cyrinux on GPU bays management, and
applies the same principle to the external disk bays, but harmonize the
inventory management:
- If no argument is specified on the command line, the GPU cards, RAID
controllers and their attached disks are added in the blade device,
and the device corresponding to an expansion device is deleted.
- If the `--expansion-as-device` option is specified on the command
line, a dedicated device corresponding to the expansion bay is
created, and the GPUs, RAID card and attached disks are removed from
the blade device and added to the expansion device.
2022-02-11 18:22:13 +01:00
|
|
|
def own_expansion_slot(self):
|
2020-09-18 12:29:17 +02:00
|
|
|
"""
|
2022-02-21 18:12:16 +01:00
|
|
|
Indicates if the device hosts an expension card
|
2020-09-18 12:29:17 +02:00
|
|
|
"""
|
Manage blade expansions as independent devices
This patch adds the ability to detect and manage GPU and Disk expansion
bays, and either add their internal components into the device
corresponding to the blade server, or into a dedicated device.
It takes advantage of the work made by @cyrinux on GPU bays management, and
applies the same principle to the external disk bays, but harmonize the
inventory management:
- If no argument is specified on the command line, the GPU cards, RAID
controllers and their attached disks are added in the blade device,
and the device corresponding to an expansion device is deleted.
- If the `--expansion-as-device` option is specified on the command
line, a dedicated device corresponding to the expansion bay is
created, and the GPUs, RAID card and attached disks are removed from
the blade device and added to the expansion device.
2022-02-11 18:22:13 +01:00
|
|
|
return self.own_gpu_expansion_slot() or self.own_disk_expansion_slot()
|
2020-09-18 12:29:17 +02:00
|
|
|
|
Manage blade expansions as independent devices
This patch adds the ability to detect and manage GPU and Disk expansion
bays, and either add their internal components into the device
corresponding to the blade server, or into a dedicated device.
It takes advantage of the work made by @cyrinux on GPU bays management, and
applies the same principle to the external disk bays, but harmonize the
inventory management:
- If no argument is specified on the command line, the GPU cards, RAID
controllers and their attached disks are added in the blade device,
and the device corresponding to an expansion device is deleted.
- If the `--expansion-as-device` option is specified on the command
line, a dedicated device corresponding to the expansion bay is
created, and the GPUs, RAID card and attached disks are removed from
the blade device and added to the expansion device.
2022-02-11 18:22:13 +01:00
|
|
|
def own_gpu_expansion_slot(self):
|
2020-09-18 12:29:17 +02:00
|
|
|
"""
|
2022-02-21 18:12:16 +01:00
|
|
|
Indicates if the device hosts a GPU expansion card based
|
Manage blade expansions as independent devices
This patch adds the ability to detect and manage GPU and Disk expansion
bays, and either add their internal components into the device
corresponding to the blade server, or into a dedicated device.
It takes advantage of the work made by @cyrinux on GPU bays management, and
applies the same principle to the external disk bays, but harmonize the
inventory management:
- If no argument is specified on the command line, the GPU cards, RAID
controllers and their attached disks are added in the blade device,
and the device corresponding to an expansion device is deleted.
- If the `--expansion-as-device` option is specified on the command
line, a dedicated device corresponding to the expansion bay is
created, and the GPUs, RAID card and attached disks are removed from
the blade device and added to the expansion device.
2022-02-11 18:22:13 +01:00
|
|
|
on the product name
|
2020-09-18 12:29:17 +02:00
|
|
|
"""
|
Manage blade expansions as independent devices
This patch adds the ability to detect and manage GPU and Disk expansion
bays, and either add their internal components into the device
corresponding to the blade server, or into a dedicated device.
It takes advantage of the work made by @cyrinux on GPU bays management, and
applies the same principle to the external disk bays, but harmonize the
inventory management:
- If no argument is specified on the command line, the GPU cards, RAID
controllers and their attached disks are added in the blade device,
and the device corresponding to an expansion device is deleted.
- If the `--expansion-as-device` option is specified on the command
line, a dedicated device corresponding to the expansion bay is
created, and the GPUs, RAID card and attached disks are removed from
the blade device and added to the expansion device.
2022-02-11 18:22:13 +01:00
|
|
|
return self.get_product_name().endswith('Graphics Exp')
|
2020-09-18 12:29:17 +02:00
|
|
|
|
Manage blade expansions as independent devices
This patch adds the ability to detect and manage GPU and Disk expansion
bays, and either add their internal components into the device
corresponding to the blade server, or into a dedicated device.
It takes advantage of the work made by @cyrinux on GPU bays management, and
applies the same principle to the external disk bays, but harmonize the
inventory management:
- If no argument is specified on the command line, the GPU cards, RAID
controllers and their attached disks are added in the blade device,
and the device corresponding to an expansion device is deleted.
- If the `--expansion-as-device` option is specified on the command
line, a dedicated device corresponding to the expansion bay is
created, and the GPUs, RAID card and attached disks are removed from
the blade device and added to the expansion device.
2022-02-11 18:22:13 +01:00
|
|
|
def own_disk_expansion_slot(self):
|
2020-09-18 12:29:17 +02:00
|
|
|
"""
|
2022-02-21 18:12:16 +01:00
|
|
|
Indicates if the device hosts a drive expansion card based
|
|
|
|
on raid card attributes.
|
2020-09-18 12:29:17 +02:00
|
|
|
"""
|
2022-02-21 18:12:16 +01:00
|
|
|
# Uses already parsed inventory if available
|
|
|
|
# parses it otherwise
|
|
|
|
inventory = getattr(self, "inventory", None)
|
|
|
|
if inventory is None:
|
|
|
|
inventory = Inventory(self)
|
|
|
|
for raid_card in inventory.get_raid_cards():
|
Manage blade expansions as independent devices
This patch adds the ability to detect and manage GPU and Disk expansion
bays, and either add their internal components into the device
corresponding to the blade server, or into a dedicated device.
It takes advantage of the work made by @cyrinux on GPU bays management, and
applies the same principle to the external disk bays, but harmonize the
inventory management:
- If no argument is specified on the command line, the GPU cards, RAID
controllers and their attached disks are added in the blade device,
and the device corresponding to an expansion device is deleted.
- If the `--expansion-as-device` option is specified on the command
line, a dedicated device corresponding to the expansion bay is
created, and the GPUs, RAID card and attached disks are removed from
the blade device and added to the expansion device.
2022-02-11 18:22:13 +01:00
|
|
|
if self.is_blade() and raid_card.is_external():
|
|
|
|
return True
|
|
|
|
return False
|