2020-02-02 20:08:56 +01:00
|
|
|
from netbox_agent.raid.base import Raid, RaidController
|
2022-02-25 18:43:09 +01:00
|
|
|
from netbox_agent.misc import get_vendor
|
|
|
|
from netbox_agent.config import config
|
|
|
|
import subprocess
|
|
|
|
import logging
|
|
|
|
import re
|
2019-08-26 16:54:48 +02:00
|
|
|
|
|
|
|
REGEXP_CONTROLLER_HP = re.compile(r'Smart Array ([a-zA-Z0-9- ]+) in Slot ([0-9]+)')
|
|
|
|
|
2022-03-11 15:55:07 +01:00
|
|
|
class HPRaidControllerError(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def ssacli(sub_command):
|
|
|
|
command = ["ssacli"]
|
|
|
|
command.extend(sub_command.split())
|
|
|
|
p = subprocess.Popen(
|
|
|
|
command,
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.STDOUT
|
|
|
|
)
|
2022-12-13 17:26:45 +01:00
|
|
|
stdout, stderr = p.communicate()
|
|
|
|
stdout = stdout.decode("utf-8")
|
|
|
|
if p.returncode != 0:
|
2022-03-11 15:55:07 +01:00
|
|
|
mesg = "Failed to execute command '{}':\n{}".format(
|
|
|
|
" ".join(command), stdout
|
|
|
|
)
|
|
|
|
raise HPRaidControllerError(mesg)
|
2022-12-13 17:26:45 +01:00
|
|
|
|
|
|
|
if 'does not have any physical' in stdout:
|
|
|
|
return list()
|
2022-04-04 09:05:42 +02:00
|
|
|
else:
|
2022-12-13 17:26:45 +01:00
|
|
|
lines = stdout.split('\n')
|
|
|
|
lines = list(filter(None, lines))
|
|
|
|
return lines
|
2022-02-25 18:43:09 +01:00
|
|
|
|
2022-11-16 15:46:57 +01:00
|
|
|
def _test_if_valid_line(line):
|
2022-12-02 12:28:47 +01:00
|
|
|
ignore_patterns = ['Note:', 'Error:', 'is not loaded', 'README', ' failure', ' cache']
|
2022-11-16 15:46:57 +01:00
|
|
|
for pattern in ignore_patterns:
|
|
|
|
if not line or pattern in line:
|
|
|
|
return None
|
|
|
|
return line
|
|
|
|
|
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 _parse_ctrl_output(lines):
|
|
|
|
controllers = {}
|
|
|
|
current_ctrl = None
|
2022-11-16 15:46:57 +01: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
|
|
|
for line in lines:
|
2022-11-16 15:46:57 +01:00
|
|
|
line = line.strip()
|
|
|
|
line = _test_if_valid_line(line)
|
|
|
|
if line is 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
|
|
|
continue
|
|
|
|
ctrl = REGEXP_CONTROLLER_HP.search(line)
|
|
|
|
if ctrl is not None:
|
2023-01-13 17:12:25 +01:00
|
|
|
slot = ctrl.group(2)
|
|
|
|
current_ctrl = "{} - Slot {}".format(ctrl.group(1), slot)
|
|
|
|
controllers[current_ctrl] = {'Slot': slot}
|
2022-02-25 18:43:09 +01:00
|
|
|
if 'Embedded' not in line:
|
|
|
|
controllers[current_ctrl]['External'] = True
|
2022-11-16 15:46:57 +01:00
|
|
|
continue
|
|
|
|
if ': ' not in line:
|
2020-06-10 15:24:43 +02:00
|
|
|
continue
|
2022-11-16 15:46:57 +01:00
|
|
|
|
2022-02-25 18:43:09 +01:00
|
|
|
attr, val = line.split(': ', 1)
|
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
|
|
|
attr = attr.strip()
|
|
|
|
val = val.strip()
|
|
|
|
controllers[current_ctrl][attr] = val
|
|
|
|
return controllers
|
2020-06-10 15:24:43 +02:00
|
|
|
|
2019-08-26 16:54:48 +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 _parse_pd_output(lines):
|
|
|
|
drives = {}
|
|
|
|
current_array = None
|
|
|
|
current_drv = None
|
2019-08-26 16:54:48 +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
|
|
|
for line in lines:
|
|
|
|
line = line.strip()
|
2022-11-16 15:46:57 +01:00
|
|
|
line = _test_if_valid_line(line)
|
|
|
|
if line is None:
|
fix: hp inventory crash is controller return some warning
about the cache to be re-enable for example
```
DEBUG:urllib3.connectionpool:https://netbox.local:443 "GET /api/dcim/inventory-items/?device_id=9&tag=hw-disk&limit=0 HTTP/1.1" 200 52
('A cache backup failure has occurred. Please execute the "reenablecache" '
'command')
Traceback (most recent call last):
File "/usr/bin/netbox_agent", line 33, in <module>
sys.exit(load_entry_point('netbox-agent==0.7.1', 'console_scripts', 'netbox_agent')())
File "/opt/netbox-agent/lib/python3.6/site-packages/netbox_agent/cli.py", line 50, in main
return run(config)
File "/opt/netbox-agent/lib/python3.6/site-packages/netbox_agent/cli.py", line 43, in run
server.netbox_create_or_update(config)
File "/opt/netbox-agent/lib/python3.6/site-packages/netbox_agent/server.py", line 417, in netbox_create_or_update
self.inventory.create_or_update()
File "/opt/netbox-agent/lib/python3.6/site-packages/netbox_agent/inventory.py", line 547, in create_or_update
self.do_netbox_disks()
File "/opt/netbox-agent/lib/python3.6/site-packages/netbox_agent/inventory.py", line 417, in do_netbox_disks
disks = self.get_hw_disks()
File "/opt/netbox-agent/lib/python3.6/site-packages/netbox_agent/inventory.py", line 332, in get_hw_disks
for raid_card in self.get_raid_cards(filter_cards=True):
File "/opt/netbox-agent/lib/python3.6/site-packages/netbox_agent/inventory.py", line 242, in get_raid_cards
self.raid = raid_class()
File "/opt/netbox-agent/lib/python3.6/site-packages/netbox_agent/raid/hp.py", line 180, in __init__
self.convert_to_dict()
File "/opt/netbox-agent/lib/python3.6/site-packages/netbox_agent/raid/hp.py", line 185, in convert_to_dict
controllers = _parse_ctrl_output(lines)
File "/opt/netbox-agent/lib/python3.6/site-packages/netbox_agent/raid/hp.py", line 34, in _parse_ctrl_output
attr, val = line.split(': ', 1)
```
2022-11-10 15:33:04 +01:00
|
|
|
continue
|
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
|
|
|
# Parses the Array the drives are in
|
2022-02-25 18:43:09 +01:00
|
|
|
if line.startswith('Array'):
|
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
|
|
|
current_array = line.split(None, 1)[1]
|
|
|
|
# Detects new physical drive
|
2022-02-25 18:43:09 +01:00
|
|
|
if line.startswith('physicaldrive'):
|
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
|
|
|
current_drv = line.split(None, 1)[1]
|
|
|
|
drives[current_drv] = {}
|
|
|
|
if current_array is not None:
|
2022-02-25 18:43:09 +01:00
|
|
|
drives[current_drv]['Array'] = current_array
|
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
|
|
|
continue
|
2022-02-25 18:43:09 +01:00
|
|
|
if ': ' not in line:
|
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
|
|
|
continue
|
2022-02-25 18:43:09 +01:00
|
|
|
attr, val = line.split(': ', 1)
|
2022-11-16 15:46:57 +01:00
|
|
|
attr = attr.strip()
|
|
|
|
val = val.strip()
|
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
|
|
|
drives.setdefault(current_drv, {})[attr] = val
|
|
|
|
return drives
|
2019-08-26 16:54:48 +02:00
|
|
|
|
|
|
|
|
2022-11-16 15:46:57 +01:00
|
|
|
|
2022-02-25 18:43:09 +01:00
|
|
|
def _parse_ld_output(lines):
|
|
|
|
drives = {}
|
|
|
|
current_array = None
|
|
|
|
current_drv = None
|
|
|
|
|
|
|
|
for line in lines:
|
|
|
|
line = line.strip()
|
2022-11-16 15:46:57 +01:00
|
|
|
line = _test_if_valid_line(line)
|
|
|
|
if line is None:
|
2022-02-25 18:43:09 +01:00
|
|
|
continue
|
|
|
|
# Parses the Array the drives are in
|
|
|
|
if line.startswith('Array'):
|
|
|
|
current_array = line.split(None, 1)[1]
|
|
|
|
drives[current_array] = {}
|
|
|
|
# Detects new physical drive
|
|
|
|
if line.startswith('Logical Drive'):
|
|
|
|
current_drv = line.split(': ', 1)[1]
|
|
|
|
drives.setdefault(current_array, {})['LogicalDrive'] = current_drv
|
|
|
|
continue
|
|
|
|
if ': ' not in line:
|
|
|
|
continue
|
|
|
|
attr, val = line.split(': ', 1)
|
|
|
|
drives.setdefault(current_array, {})[attr] = val
|
|
|
|
return drives
|
|
|
|
|
|
|
|
|
2019-08-26 16:54:48 +02:00
|
|
|
class HPRaidController(RaidController):
|
|
|
|
def __init__(self, controller_name, data):
|
|
|
|
self.controller_name = controller_name
|
|
|
|
self.data = data
|
2022-02-25 18:43:09 +01:00
|
|
|
self.pdrives = self._get_physical_disks()
|
2022-03-11 15:55:07 +01:00
|
|
|
arrays = [d['Array'] for d in self.pdrives.values() if d.get('Array')]
|
|
|
|
if arrays:
|
|
|
|
self.ldrives = self._get_logical_drives()
|
|
|
|
self._get_virtual_drives_map()
|
2019-08-26 16:54:48 +02:00
|
|
|
|
|
|
|
def get_product_name(self):
|
|
|
|
return self.controller_name
|
|
|
|
|
|
|
|
def get_manufacturer(self):
|
|
|
|
return 'HP'
|
|
|
|
|
|
|
|
def get_serial_number(self):
|
|
|
|
return self.data['Serial Number']
|
|
|
|
|
|
|
|
def get_firmware_version(self):
|
|
|
|
return self.data['Firmware Version']
|
|
|
|
|
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 is_external(self):
|
|
|
|
return self.data.get('External', False)
|
|
|
|
|
|
|
|
def _get_physical_disks(self):
|
2022-02-25 18:43:09 +01:00
|
|
|
lines = ssacli('ctrl slot={} pd all show detail'.format(self.data['Slot']))
|
|
|
|
pdrives = _parse_pd_output(lines)
|
|
|
|
ret = {}
|
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
|
|
|
|
2022-02-25 18:43:09 +01:00
|
|
|
for name, attrs in pdrives.items():
|
|
|
|
array = attrs.get('Array', '')
|
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
|
|
|
model = attrs.get('Model', '').strip()
|
|
|
|
vendor = None
|
|
|
|
if model.startswith('HP'):
|
|
|
|
vendor = 'HP'
|
|
|
|
elif len(model.split()) > 1:
|
|
|
|
vendor = get_vendor(model.split()[1])
|
|
|
|
else:
|
|
|
|
vendor = get_vendor(model)
|
|
|
|
|
2022-02-25 18:43:09 +01:00
|
|
|
ret[name] = {
|
|
|
|
'Array': array,
|
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
|
|
|
'Model': model,
|
|
|
|
'Vendor': vendor,
|
|
|
|
'SN': attrs.get('Serial Number', '').strip(),
|
|
|
|
'Size': attrs.get('Size', '').strip(),
|
|
|
|
'Type': 'SSD' if attrs.get('Interface Type') == 'Solid State SATA'
|
|
|
|
else 'HDD',
|
|
|
|
'_src': self.__class__.__name__,
|
2022-12-13 17:27:35 +01:00
|
|
|
'custom_fields': {
|
|
|
|
'pd_identifier': name,
|
2022-12-14 09:00:37 +01:00
|
|
|
'mount_point': attrs.get('Mount Points', '').strip(),
|
|
|
|
'vd_device': attrs.get('Disk Name', '').strip(),
|
|
|
|
'vd_size': attrs.get('Size', '').strip(),
|
2022-12-13 17:27:35 +01:00
|
|
|
}
|
2022-02-25 18:43:09 +01:00
|
|
|
}
|
2019-08-26 16:54:48 +02:00
|
|
|
return ret
|
|
|
|
|
2022-02-25 18:43:09 +01:00
|
|
|
def _get_logical_drives(self):
|
|
|
|
lines = ssacli('ctrl slot={} ld all show detail'.format(self.data['Slot']))
|
|
|
|
ldrives = _parse_ld_output(lines)
|
|
|
|
ret = {}
|
|
|
|
|
|
|
|
for array, attrs in ldrives.items():
|
|
|
|
ret[array] = {
|
|
|
|
'vd_array': array,
|
2022-12-14 09:00:37 +01:00
|
|
|
'vd_size': attrs.get('Size', '').strip(),
|
|
|
|
'vd_consistency': attrs.get('Status', '').strip(),
|
|
|
|
'vd_raid_type': 'RAID {}'.format(attrs.get('Fault Tolerance', 'N/A').strip()),
|
|
|
|
'vd_device': attrs.get('LogicalDrive', '').strip(),
|
|
|
|
'mount_point': attrs.get('Mount Points', '').strip()
|
2022-02-25 18:43:09 +01:00
|
|
|
}
|
|
|
|
return ret
|
|
|
|
|
|
|
|
def _get_virtual_drives_map(self):
|
|
|
|
for name, attrs in self.pdrives.items():
|
|
|
|
array = attrs["Array"]
|
|
|
|
ld = self.ldrives.get(array)
|
|
|
|
if ld is None:
|
|
|
|
logging.error(
|
|
|
|
"Failed to find array information for physical drive {}."
|
|
|
|
" Ignoring.".format(name)
|
|
|
|
)
|
|
|
|
continue
|
2022-03-11 15:55:07 +01:00
|
|
|
attrs['custom_fields'].update(ld)
|
2022-02-25 18:43:09 +01: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_physical_disks(self):
|
2022-02-25 18:43:09 +01:00
|
|
|
return list(self.pdrives.values())
|
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
|
|
|
|
2019-08-26 16:54:48 +02:00
|
|
|
|
|
|
|
class HPRaid(Raid):
|
|
|
|
def __init__(self):
|
|
|
|
self.output = subprocess.getoutput('ssacli ctrl all show detail')
|
|
|
|
self.controllers = []
|
|
|
|
self.convert_to_dict()
|
|
|
|
|
|
|
|
def convert_to_dict(self):
|
|
|
|
lines = self.output.split('\n')
|
|
|
|
lines = list(filter(None, lines))
|
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
|
|
|
controllers = _parse_ctrl_output(lines)
|
|
|
|
for controller, attrs in controllers.items():
|
|
|
|
self.controllers.append(
|
|
|
|
HPRaidController(controller, attrs)
|
|
|
|
)
|
2019-08-26 16:54:48 +02:00
|
|
|
|
|
|
|
def get_controllers(self):
|
|
|
|
return self.controllers
|