Skip to content

Commit 262b14c

Browse files
authored
Merge pull request #449 from grafuls/development
fix: default for custom device types on idrac_interfaces
2 parents fc5967d + 79c552a commit 262b14c

File tree

5 files changed

+166
-86
lines changed

5 files changed

+166
-86
lines changed

config/idrac_interfaces.yml

Lines changed: 70 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4,86 +4,88 @@
44
# Also see /opt/quads/quads/config.py SUPPORTED list if adding system types.
55
#
66
---
7-
director_b01_fc640_interfaces: NIC.ChassisSlot.8-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
8-
director_b02_fc640_interfaces: NIC.ChassisSlot.4-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
9-
director_b03_fc640_interfaces: NIC.ChassisSlot.6-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
10-
director_b04_fc640_interfaces: NIC.ChassisSlot.2-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
11-
director_r630_interfaces: NIC.Integrated.1-2-1,HardDisk.List.1-1,NIC.Slot.2-1-1
12-
director_r640_interfaces: NIC.Slot.1-2-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
13-
director_r650_interfaces: NIC.Slot.1-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
14-
director_r660_interfaces: NIC.PxeDevice.2-1,RAID.SL.3-2,NIC.PxeDevice.1-1
15-
director_r720xd_interfaces: NIC.Slot.4-2-1,HardDisk.List.1-1,NIC.Integrated.1-3-1
16-
director_r730xd_interfaces: NIC.Integrated.1-2-1,HardDisk.List.1-1,NIC.Integrated.1-3-1
17-
director_740xd_interfaces: NIC.Integrated.1-1-1,NIC.Integrated.1-2-1,NIC.Slot.7-2-1,NIC.Slot.7-1-1,NIC.Integrated.1-3-1,HardDisk.List.1-1
18-
director_r740xd_interfaces: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Integrated.1-3-1
19-
director_r750_interfaces: NIC.Slot.3-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
20-
director_7425_interfaces: NIC.Integrated.1-1-1,NIC.Integrated.1-2-1,NIC.Slot.7-2-1,NIC.Slot.7-1-1,NIC.Integrated.1-3-1,HardDisk.List.1-1
21-
director_7525_interfaces: NIC.Integrated.1-1-1,NIC.Integrated.1-2-1,NIC.Slot.6-1-1,NIC.Slot.6-2-1,NIC.Embedded.1-1-1,HardDisk.List.1-1
22-
director_r930_interfaces: NIC.Integrated.1-2-1,HardDisk.List.1-1,NIC.Integrated.1-3-1
23-
foreman_b01_fc640_interfaces: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.ChassisSlot.8-1-1
24-
foreman_b02_fc640_interfaces: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.ChassisSlot.4-1-1
25-
foreman_b03_fc640_interfaces: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.ChassisSlot.6-1-1
26-
foreman_b04_fc640_interfaces: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.ChassisSlot.2-1-1
27-
foreman_r630_interfaces: NIC.Slot.2-1-1,HardDisk.List.1-1,NIC.Integrated.1-2-1
28-
foreman_r640_interfaces: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Slot.1-2-1
29-
foreman_r650_interfaces: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Slot.1-1-1
30-
foreman_r660_interfaces: NIC.PxeDevice.1-1,RAID.SL.3-2,NIC.PxeDevice.2-1
31-
foreman_r720xd_interfaces: NIC.Integrated.1-3-1,HardDisk.List.1-1,NIC.Slot.4-2-1
32-
foreman_r730xd_interfaces: NIC.Integrated.1-3-1,HardDisk.List.1-1,NIC.Integrated.1-2-1
33-
foreman_740xd_interfaces: NIC.Integrated.1-3-1,NIC.Integrated.1-1-1,NIC.Slot.7-2-1,NIC.Slot.7-1-1,HardDisk.List.1-1,NIC.Integrated.1-2-1
34-
foreman_r740xd_interfaces: NIC.Integrated.1-3-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
35-
foreman_r750_interfaces: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Slot.3-1-1
36-
foreman_7425_interfaces: NIC.Integrated.1-3-1,NIC.Integrated.1-1-1,NIC.Integrated.1-2-1,NIC.Slot.7-2-1,NIC.Slot.7-1-1,HardDisk.List.1-1
37-
foreman_7525_interfaces: NIC.Embedded.1-1-1,NIC.Integrated.1-1-1,NIC.Integrated.1-2-1,NIC.Slot.6-1-1,NIC.Slot.6-2-1,HardDisk.List.1-1
38-
foreman_r930_interfaces: NIC.Integrated.1-3-1,HardDisk.List.1-1,NIC.Integrated.1-2-1
7+
director_b01_fc640: NIC.ChassisSlot.8-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
8+
director_b02_fc640: NIC.ChassisSlot.4-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
9+
director_b03_fc640: NIC.ChassisSlot.6-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
10+
director_b04_fc640: NIC.ChassisSlot.2-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
11+
director_r630: NIC.Integrated.1-2-1,HardDisk.List.1-1,NIC.Slot.2-1-1
12+
director_r640: NIC.Slot.1-2-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
13+
director_r650: NIC.Slot.1-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
14+
director_r660: NIC.PxeDevice.2-1,RAID.SL.3-2,NIC.PxeDevice.1-1
15+
director_r720xd: NIC.Slot.4-2-1,HardDisk.List.1-1,NIC.Integrated.1-3-1
16+
director_r730xd: NIC.Integrated.1-2-1,HardDisk.List.1-1,NIC.Integrated.1-3-1
17+
director_740xd: NIC.Integrated.1-1-1,NIC.Integrated.1-2-1,NIC.Slot.7-2-1,NIC.Slot.7-1-1,NIC.Integrated.1-3-1,HardDisk.List.1-1
18+
director_r740xd: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Integrated.1-3-1
19+
director_r750: NIC.Slot.3-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
20+
director_7425: NIC.Integrated.1-1-1,NIC.Integrated.1-2-1,NIC.Slot.7-2-1,NIC.Slot.7-1-1,NIC.Integrated.1-3-1,HardDisk.List.1-1
21+
director_7525: NIC.Integrated.1-1-1,NIC.Integrated.1-2-1,NIC.Slot.6-1-1,NIC.Slot.6-2-1,NIC.Embedded.1-1-1,HardDisk.List.1-1
22+
director_r930: NIC.Integrated.1-2-1,HardDisk.List.1-1,NIC.Integrated.1-3-1
23+
foreman_b01_fc640: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.ChassisSlot.8-1-1
24+
foreman_b02_fc640: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.ChassisSlot.4-1-1
25+
foreman_b03_fc640: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.ChassisSlot.6-1-1
26+
foreman_b04_fc640: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.ChassisSlot.2-1-1
27+
foreman_r630: NIC.Slot.2-1-1,HardDisk.List.1-1,NIC.Integrated.1-2-1
28+
foreman_r640: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Slot.1-2-1
29+
foreman_r650: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Slot.1-1-1
30+
foreman_r660: NIC.PxeDevice.1-1,RAID.SL.3-2,NIC.PxeDevice.2-1
31+
foreman_r720xd: NIC.Integrated.1-3-1,HardDisk.List.1-1,NIC.Slot.4-2-1
32+
foreman_r730xd: NIC.Integrated.1-3-1,HardDisk.List.1-1,NIC.Integrated.1-2-1
33+
foreman_740xd: NIC.Integrated.1-3-1,NIC.Integrated.1-1-1,NIC.Slot.7-2-1,NIC.Slot.7-1-1,HardDisk.List.1-1,NIC.Integrated.1-2-1
34+
foreman_r740xd: NIC.Integrated.1-3-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
35+
foreman_r750: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Slot.3-1-1
36+
foreman_7425: NIC.Integrated.1-3-1,NIC.Integrated.1-1-1,NIC.Integrated.1-2-1,NIC.Slot.7-2-1,NIC.Slot.7-1-1,HardDisk.List.1-1
37+
foreman_7525: NIC.Embedded.1-1-1,NIC.Integrated.1-1-1,NIC.Integrated.1-2-1,NIC.Slot.6-1-1,NIC.Slot.6-2-1,HardDisk.List.1-1
38+
foreman_r930: NIC.Integrated.1-3-1,HardDisk.List.1-1,NIC.Integrated.1-2-1
3939
# These are for EFI
4040
# Expanding rest of models as a workaround for issue #239
41-
uefi_r630_interfaces: NIC.Integrated.1-2-1,HardDisk.List.1-1,NIC.Slot.2-1-1
42-
uefi_r640_interfaces: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Slot.1-1-1
43-
uefi_b01_fc640_interfaces: NIC.ChassisSlot.8-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
44-
uefi_b02_fc640_interfaces: NIC.ChassisSlot.4-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
45-
uefi_b03_fc640_interfaces: NIC.ChassisSlot.6-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
46-
uefi_b04_fc640_interfaces: NIC.ChassisSlot.2-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
47-
uefi_r650_interfaces: NIC.Slot.1-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
41+
uefi_r630: NIC.Integrated.1-2-1,HardDisk.List.1-1,NIC.Slot.2-1-1
42+
uefi_r640: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Slot.1-1-1
43+
uefi_b01_fc640: NIC.ChassisSlot.8-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
44+
uefi_b02_fc640: NIC.ChassisSlot.4-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
45+
uefi_b03_fc640: NIC.ChassisSlot.6-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
46+
uefi_b04_fc640: NIC.ChassisSlot.2-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
47+
uefi_r650: NIC.Slot.1-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
4848
# Here we should be able to distinguish between 'foreman' and 'director'
4949
# interface layouts.
50-
uefi_r720xd_interfaces: NIC.Slot.4-2-1,HardDisk.List.1-1,NIC.Integrated.1-3-1
51-
uefi_r730xd_interfaces: NIC.Integrated.1-2-1,HardDisk.List.1-1,NIC.Integrated.1-3-1
52-
uefi_740xd_interfaces: NIC.Integrated.1-1-1,NIC.Integrated.1-2-1,NIC.Slot.7-2-1,NIC.Slot.7-1-1,NIC.Integrated.1-3-1,HardDisk.List.1-1
53-
uefi_r740xd_interfaces: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Integrated.1-3-1
54-
uefi_r750_interfaces: NIC.Slot.3-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
55-
uefi_7425_interfaces: NIC.Integrated.1-1-1,NIC.Integrated.1-2-1,NIC.Slot.7-2-1,NIC.Slot.7-1-1,NIC.Integrated.1-3-1,HardDisk.List.1-1
56-
uefi_7525_interfaces: NIC.Integrated.1-1-1,NIC.Integrated.1-2-1,NIC.Slot.6-1-1,NIC.Slot.6-2-1,NIC.Embedded.1-1-1,HardDisk.List.1-1
57-
uefi_r930_interfaces: NIC.Integrated.1-2-1,HardDisk.List.1-1,NIC.Integrated.1-3-1
58-
uefi_mx750c_interfaces: NIC.PxeDevice.1-1,RAID.SL.3-2
50+
uefi_r720xd: NIC.Slot.4-2-1,HardDisk.List.1-1,NIC.Integrated.1-3-1
51+
uefi_r730xd: NIC.Integrated.1-2-1,HardDisk.List.1-1,NIC.Integrated.1-3-1
52+
uefi_740xd: NIC.Integrated.1-1-1,NIC.Integrated.1-2-1,NIC.Slot.7-2-1,NIC.Slot.7-1-1,NIC.Integrated.1-3-1,HardDisk.List.1-1
53+
uefi_r740xd: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Integrated.1-3-1
54+
uefi_r750: NIC.Slot.3-1-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
55+
uefi_7425: NIC.Integrated.1-1-1,NIC.Integrated.1-2-1,NIC.Slot.7-2-1,NIC.Slot.7-1-1,NIC.Integrated.1-3-1,HardDisk.List.1-1
56+
uefi_7525: NIC.Integrated.1-1-1,NIC.Integrated.1-2-1,NIC.Slot.6-1-1,NIC.Slot.6-2-1,NIC.Embedded.1-1-1,HardDisk.List.1-1
57+
uefi_r930: NIC.Integrated.1-2-1,HardDisk.List.1-1,NIC.Integrated.1-3-1
58+
uefi_mx750c: NIC.PxeDevice.1-1,RAID.SL.3-2
5959

6060
# To understand how custom overrides and hierarchy work please see https://github.com/redhat-performance/badfish#host-type-overrides
6161
# PerfLab Entries
62-
foreman_cc37_r750_interfaces: NIC.Embedded.1-1-1,HardDisk.List.1-1,NIC.Slot.3-1-1
63-
director_cc37_r750_interfaces: NIC.Slot.3-1-1,HardDisk.List.1-1,NIC.Embedded.1-1-1
64-
foreman_bb37_r750_interfaces: NIC.Embedded.1-1-1,HardDisk.List.1-1,NIC.Slot.3-1-1
65-
director_bb37_r750_interfaces: NIC.Slot.3-1-1,HardDisk.List.1-1,NIC.Embedded.1-1-1
66-
foreman_r760_interfaces: NIC.PxeDevice.1-1,RAID.SL.3-2
67-
director_r760_interfaces: RAID.SL.3-2,NIC.PxeDevice.1-1
68-
foreman_mx750c_interfaces: NIC.PxeDevice.1-1,RAID.SL.3-2
69-
director_mx750c_interfaces: RAID.SL.3-2,NIC.PxeDevice.1-1
62+
foreman_cc37_r750: NIC.Embedded.1-1-1,HardDisk.List.1-1,NIC.Slot.3-1-1
63+
director_cc37_r750: NIC.Slot.3-1-1,HardDisk.List.1-1,NIC.Embedded.1-1-1
64+
foreman_bb37_r750: NIC.Embedded.1-1-1,HardDisk.List.1-1,NIC.Slot.3-1-1
65+
director_bb37_r750: NIC.Slot.3-1-1,HardDisk.List.1-1,NIC.Embedded.1-1-1
66+
foreman_r760: NIC.PxeDevice.1-1,RAID.SL.3-2
67+
director_r760: RAID.SL.3-2,NIC.PxeDevice.1-1
68+
foreman_mx750c: NIC.PxeDevice.1-1,RAID.SL.3-2
69+
director_mx750c: RAID.SL.3-2,NIC.PxeDevice.1-1
7070

7171
# Custom Rack F04
72-
director_f18_r640_interfaces: NIC.Slot.3-2,HardDisk.List.1-1,NIC.Slot.3-1,NIC.Slot.2-1,NIC.Slot.2-2,NIC.Integrated.1-1-1
73-
foreman_f18_r640_interfaces: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Slot.3-1,NIC.Slot.3-2,NIC.Slot.2-1,NIC.Slot.2-2
72+
director_f18_r640: NIC.Slot.3-2,HardDisk.List.1-1,NIC.Slot.3-1,NIC.Slot.2-1,NIC.Slot.2-2,NIC.Integrated.1-1-1
73+
foreman_f18_r640: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Slot.3-1,NIC.Slot.3-2,NIC.Slot.2-1,NIC.Slot.2-2
7474

7575
# Custom Rack E27 and E28 for Dell R750
76-
director_e27_r750_interfaces: NIC.Slot.3-1-1,NIC.Slot.3-2-1,NIC.Slot.6-1-1,NIC.Slot.6-2-1,NIC.Embedded.1-1-1,HardDisk.List.1-1
77-
director_e28_r750_interfaces: NIC.Slot.3-1-1,NIC.Slot.3-2-1,NIC.Slot.6-1-1,NIC.Slot.6-2-1,NIC.Embedded.1-1-1,HardDisk.List.1-1
78-
foreman_e27_r750_interfaces: NIC.Embedded.1-1-1,NIC.Slot.3-1-1,NIC.Slot.3-2-1,NIC.Slot.6-1-1,NIC.Slot.6-2-1,HardDisk.List.1-1
79-
foreman_e28_r750_interfaces: NIC.Embedded.1-1-1,NIC.Slot.3-1-1,NIC.Slot.3-2-1,NIC.Slot.6-1-1,NIC.Slot.6-2-1,HardDisk.List.1-1
80-
uefi_e27_r750_interfaces: NIC.Slot.3-1-1,HardDisk.List.1-1,NIC.Embedded.1-1-1
81-
uefi_e28_r750_interfaces: NIC.Slot.3-1-1,HardDisk.List.1-1,NIC.Embedded.1-1-1
76+
director_e27_r750: NIC.Slot.3-1-1,NIC.Slot.3-2-1,NIC.Slot.6-1-1,NIC.Slot.6-2-1,NIC.Embedded.1-1-1,HardDisk.List.1-1
77+
director_e28_r750: NIC.Slot.3-1-1,NIC.Slot.3-2-1,NIC.Slot.6-1-1,NIC.Slot.6-2-1,NIC.Embedded.1-1-1,HardDisk.List.1-1
78+
foreman_e27_r750: NIC.Embedded.1-1-1,NIC.Slot.3-1-1,NIC.Slot.3-2-1,NIC.Slot.6-1-1,NIC.Slot.6-2-1,HardDisk.List.1-1
79+
foreman_e28_r750: NIC.Embedded.1-1-1,NIC.Slot.3-1-1,NIC.Slot.3-2-1,NIC.Slot.6-1-1,NIC.Slot.6-2-1,HardDisk.List.1-1
80+
uefi_e27_r750: NIC.Slot.3-1-1,HardDisk.List.1-1,NIC.Embedded.1-1-1
81+
uefi_e28_r750: NIC.Slot.3-1-1,HardDisk.List.1-1,NIC.Embedded.1-1-1
8282

8383
## Custom F04 specific overrides (examples)
8484
## h34 (should resemble other r640 hosts)
85-
# director_f04_h34_r640_interfaces: NIC.Slot.1-2-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
86-
# foreman_f04_h34_r640_interfaces: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Slot.1-2-1
85+
# director_f04_h34_r640: NIC.Slot.1-2-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
86+
# foreman_f04_h34_r640: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Slot.1-2-1
8787
# h35 (should resemble other r640 hosts)
88-
# director_f04_h35_r640_interfaces: NIC.Slot.1-2-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
89-
# foreman_f04_h35_r640_interfaces: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Slot.1-2-1
88+
# director_f04_h35_r640: NIC.Slot.1-2-1,HardDisk.List.1-1,NIC.Integrated.1-1-1
89+
# foreman_f04_h35_r640: NIC.Integrated.1-1-1,HardDisk.List.1-1,NIC.Slot.1-2-1
90+
91+
custom: NIC.Integrated.1-2-1,HardDisk.List.1-1,NIC.Slot.2-1-1

src/badfish/helpers/logger.py

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,52 @@ def parse(self):
5353
try:
5454
if self.host:
5555
host_name = self.host.strip().split(".")[0]
56-
new_dict = yaml.safe_load(self.messages[host_name])
56+
# Ensure the message is properly formatted as YAML by wrapping values in quotes
57+
message = self.messages[host_name]
58+
# Try to parse as is first
59+
try:
60+
new_dict = yaml.safe_load(message)
61+
except yaml.YAMLError:
62+
# If parsing fails, try to format the value as a quoted string
63+
lines = message.strip().split('\n')
64+
formatted_lines = []
65+
for line in lines:
66+
if ':' in line:
67+
key, value = line.split(':', 1)
68+
value = value.strip()
69+
# If value contains spaces or special characters, wrap in quotes
70+
if ' ' in value or any(c in value for c in '{}[](),:#'):
71+
value = f'"{value}"'
72+
formatted_lines.append(f"{key}: {value}")
73+
else:
74+
formatted_lines.append(line)
75+
formatted_message = '\n'.join(formatted_lines)
76+
new_dict = yaml.safe_load(formatted_message)
77+
5778
self.output_dict.update({self.host: new_dict.copy()})
5879
self.host = None
5980
else:
60-
new_dict = yaml.safe_load(self.messages["badfish.helpers.logger"])
81+
message = self.messages["badfish.helpers.logger"]
82+
# Apply the same formatting logic for non-host messages
83+
try:
84+
new_dict = yaml.safe_load(message)
85+
except yaml.YAMLError:
86+
lines = message.strip().split('\n')
87+
formatted_lines = []
88+
for line in lines:
89+
if ':' in line:
90+
key, value = line.split(':', 1)
91+
value = value.strip()
92+
if ' ' in value or any(c in value for c in '{}[](),:#'):
93+
value = f'"{value}"'
94+
formatted_lines.append(f"{key}: {value}")
95+
else:
96+
formatted_lines.append(line)
97+
formatted_message = '\n'.join(formatted_lines)
98+
new_dict = yaml.safe_load(formatted_message)
99+
61100
self.output_dict.update(new_dict.copy())
62-
except yaml.YAMLError:
101+
except yaml.YAMLError as ex:
63102
self.output_dict = {"unsupported_command": True}
64103

65104
def diff(self):

src/badfish/main.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -211,26 +211,34 @@ async def get_interfaces_by_type(self, host_type, _interfaces_path):
211211
definitions = await self.read_yaml(_interfaces_path)
212212

213213
host_name_split = self.host.split(".")[0].split("-")
214-
host_model = host_name_split[-1]
215-
rack = host_name_split[1]
216-
uloc = host_name_split[2]
214+
host_model = None
215+
rack = None
216+
uloc = None
217+
host_blade = None
218+
prefix = [host_type]
219+
if len(host_name_split) > 1:
220+
host_model = host_name_split[-1]
221+
rack = host_name_split[1]
222+
uloc = host_name_split[2]
223+
prefix.extend([rack, uloc])
217224

218-
host_blade = "000"
219225
if len(host_name_split) > 4:
220226
host_blade = host_name_split[3]
227+
prefix.append(host_blade)
221228

222-
prefix = [host_type, rack, uloc, host_blade]
223-
224-
key = f"{host_type}_{host_blade}_{host_model}_interfaces"
225-
interfaces_string = definitions.get(key)
226-
if interfaces_string:
227-
return interfaces_string.split(",")
229+
if host_blade:
230+
key = f"{host_type}_{host_blade}_{host_model}"
231+
interfaces_string = definitions.get(key)
232+
if interfaces_string:
233+
return interfaces_string.split(",")
228234

229235
len_prefix = len(prefix)
230236
key = "None"
231237
for _ in range(len_prefix):
232238
prefix_string = "_".join(prefix)
233-
key = "%s_%s_interfaces" % (prefix_string, host_model)
239+
key = prefix_string
240+
if host_model:
241+
key = "_".join([prefix_string, host_model])
234242
interfaces_string = definitions.get(key)
235243
if interfaces_string:
236244
return interfaces_string.split(",")
@@ -451,7 +459,10 @@ async def get_host_type(self, _interfaces_path):
451459
host_types = await self.get_host_types_from_yaml(_interfaces_path)
452460
for host_type in host_types:
453461
match = True
454-
interfaces = await self.get_interfaces_by_type(host_type, _interfaces_path)
462+
try:
463+
interfaces = await self.get_interfaces_by_type(host_type, _interfaces_path)
464+
except BadfishException as e:
465+
continue
455466

456467
for device in sorted(self.boot_devices[: len(interfaces)], key=lambda x: x["Index"]):
457468
if device["Name"] == interfaces[device["Index"]]:

tests/config.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ def render_device_dict(index, device):
9797
f"- WARNING - Job queue already cleared for iDRAC {MOCK_HOST}, DELETE command will not execute.\n"
9898
"- INFO - Command passed to set BIOS attribute pending values.\n"
9999
)
100-
RESPONSE_BOOT_TO_BAD_TYPE = "- ERROR - Expected values for -t argument are: ['director', 'foreman', 'uefi']\n"
100+
RESPONSE_BOOT_TO_CUSTOM = (
101+
f"- WARNING - Job queue already cleared for iDRAC host01.example.com, DELETE command will not execute.\n"
102+
"- INFO - Command passed to set BIOS attribute pending values.\n"
103+
)
104+
RESPONSE_BOOT_TO_BAD_TYPE = "- ERROR - Expected values for -t argument are: ['custom', 'director', 'foreman', 'uefi']\n"
101105
RESPONSE_BOOT_TO_SERVICE_UNAVAILABLE = (
102106
f"- WARNING - Job queue already cleared for iDRAC {MOCK_HOST}, DELETE command will not execute.\n"
103107
"- ERROR - Command failed, error code is: 503.\n"
@@ -216,7 +220,7 @@ def render_device_dict(index, device):
216220
"- INFO - Polling for host state: Not Down\n"
217221
"- INFO - Command passed to On server, code return is 200.\n"
218222
)
219-
RESPONSE_CHANGE_BAD_TYPE = "- ERROR - Expected values for -t argument are: ['director', 'foreman', 'uefi']\n"
223+
RESPONSE_CHANGE_BAD_TYPE = "- ERROR - Expected values for -t argument are: ['custom', 'director', 'foreman', 'uefi']\n"
220224
RESPONSE_CHANGE_TO_SAME = "- WARNING - No changes were made since the boot order already matches the requested.\n"
221225
RESPONSE_CHANGE_NO_INT = "- ERROR - You must provide a path to the interfaces yaml via `-i` optional argument.\n"
222226

0 commit comments

Comments
 (0)