Skip to content

Commit 14ed0d5

Browse files
committed
Remove unused "pxe switch macs" option from enroll
This was used to influence the "pxe" boot configuration during enrol but we don't need it any more because we now set the "pxe" flag on all candidate interfaces during enrol, and then we set it properly once the full agent inspection data is in available.
1 parent 40f459c commit 14ed0d5

4 files changed

Lines changed: 6 additions & 65 deletions

File tree

python/understack-workflows/tests/test_enroll_server.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ def test_enrol_happy_path_uses_real_ironic_workflow(mocker):
210210
ip_address="10.0.0.10",
211211
firmware_update=False,
212212
raid_configure=True,
213-
pxe_switch_macs={"AA:BB:CC:DD:EE:FF"},
214213
old_password="old-password",
215214
external_cmdb_id="cmdb-1",
216215
)
@@ -387,7 +386,6 @@ def test_enrol_existing_failed_node_recovers_and_updates(mocker):
387386
ip_address="10.0.0.10",
388387
firmware_update=False,
389388
raid_configure=False,
390-
pxe_switch_macs={"AA:BB:CC:DD:EE:FF"},
391389
old_password=None,
392390
external_cmdb_id="cmdb-1",
393391
)
@@ -520,9 +518,7 @@ def test_guess_pxe_interface_unknown_name_avoids_bmc_interface():
520518
],
521519
)
522520

523-
assert enroll_server.guess_pxe_interfaces(device_info, {"AA:BB:CC:DD:EE:FF"}) == [
524-
"NIC.Custom.9-1"
525-
]
521+
assert enroll_server.guess_pxe_interfaces(device_info) == ["NIC.Custom.9-1"]
526522

527523

528524
def test_get_node_interfaces_parses_inventory(mocker):

python/understack-workflows/tests/test_pxe_port_heuristic.py

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ def test_connected_is_better():
9292

9393
def test_connected_macs_picks_first():
9494
any_mac = "00:00:00:00:00:00"
95-
pxe_mac = "11:22:33:44:55:66"
9695
x = "test"
9796
device_info = ChassisInfo(
9897
manufacturer=x,
@@ -117,44 +116,9 @@ def test_connected_macs_picks_first():
117116
InterfaceInfo("NIC.Slot.1-2", x, x, remote_switch_mac_address=any_mac),
118117
],
119118
)
120-
assert guess_pxe_interfaces(device_info, {pxe_mac}) == [
119+
assert guess_pxe_interfaces(device_info) == [
121120
"NIC.Integrated.1-1",
122121
"NIC.Slot.1-1",
123122
"NIC.Integrated.1-2",
124123
"NIC.Slot.1-2",
125124
]
126-
127-
128-
def test_connected_to_known_pxe_is_best():
129-
any_mac = "00:00:00:00:00:00"
130-
pxe_mac = "11:22:33:44:55:66"
131-
x = "test"
132-
device_info = ChassisInfo(
133-
manufacturer=x,
134-
model_number=x,
135-
serial_number=x,
136-
bmc_ip_address=x,
137-
bios_version=x,
138-
power_on=False,
139-
memory_gib=0,
140-
cpu=x,
141-
interfaces=[
142-
InterfaceInfo("iDRAC", x, x, remote_switch_mac_address=x),
143-
InterfaceInfo("NIC.Embedded.1-1", x, x, remote_switch_mac_address=None),
144-
InterfaceInfo("NIC.Embedded.1-1", x, x, remote_switch_mac_address=any_mac),
145-
InterfaceInfo(
146-
"NIC.Integrated.1-1", x, x, remote_switch_mac_address=any_mac
147-
),
148-
InterfaceInfo(
149-
"NIC.Integrated.1-2", x, x, remote_switch_mac_address=any_mac
150-
),
151-
InterfaceInfo("NIC.Slot.1-1", x, x, remote_switch_mac_address=pxe_mac),
152-
InterfaceInfo("NIC.Slot.1-2", x, x, remote_switch_mac_address=pxe_mac),
153-
],
154-
)
155-
assert guess_pxe_interfaces(device_info, {pxe_mac}) == [
156-
"NIC.Slot.1-1",
157-
"NIC.Slot.1-2",
158-
"NIC.Integrated.1-1",
159-
"NIC.Integrated.1-2",
160-
]

python/understack-workflows/understack_workflows/main/enroll_server.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def main() -> None:
6060
ip_address=args.ip_address,
6161
old_password=args.old_password,
6262
firmware_update=args.firmware_update,
63-
pxe_switch_macs=parse_maclist(str(args.pxe_switch_macs)),
6463
raid_configure=args.raid_configure,
6564
external_cmdb_id=args.external_cmdb_id,
6665
)
@@ -74,12 +73,10 @@ def enrol(
7473
ip_address: str,
7574
firmware_update: bool,
7675
raid_configure: bool,
77-
pxe_switch_macs: set[str],
7876
old_password: str | None,
7977
external_cmdb_id: str | None = None,
8078
) -> None:
8179
logger.info("Starting enrol workflow for bmc_ip_address=%s", ip_address)
82-
logger.info(" pxe_switch_macs=%s", pxe_switch_macs)
8380

8481
if external_cmdb_id:
8582
logger.info(" external_cmdb_id=%s", external_cmdb_id)
@@ -90,7 +87,7 @@ def enrol(
9087
if insufficient_lldp_data(device_info):
9188
device_info = power_on_and_wait(bmc, device_info)
9289

93-
pxe_interfaces = guess_pxe_interfaces(device_info, pxe_switch_macs)
90+
pxe_interfaces = guess_pxe_interfaces(device_info)
9491
logger.info("Selected %s as PXE interfaces", pxe_interfaces)
9592

9693
node = ironic_node.create_or_update(
@@ -341,12 +338,6 @@ def argument_parser():
341338
default="",
342339
help="External CMDB ID for RXDB integration",
343340
)
344-
parser.add_argument(
345-
"--pxe-switch-macs",
346-
required=False,
347-
default="",
348-
help="Chassis MAC address of switches providing PXE network",
349-
)
350341
return parser
351342

352343

python/understack-workflows/understack_workflows/pxe_port_heuristic.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,15 @@
99
DISQUALIFIED = ["DRAC", "ILO", "NIC.EMBEDDED"]
1010

1111

12-
def guess_pxe_interfaces(
13-
device_info: ChassisInfo, pxe_switch_macs: set[str] | None = None
14-
) -> list[str]:
12+
def guess_pxe_interfaces(device_info: ChassisInfo) -> list[str]:
1513
"""First 8 interface names, most probable PXE interfaces first."""
16-
if pxe_switch_macs is None:
17-
pxe_switch_macs = set()
18-
1914
candidate_interfaces = {i for i in device_info.interfaces if not disqualified(i)}
2015

2116
names = [
2217
i.name
2318
for i in sorted(
2419
candidate_interfaces,
25-
key=lambda i: likelihood(i, pxe_switch_macs),
20+
key=lambda i: likelihood(i),
2621
)
2722
]
2823

@@ -33,21 +28,16 @@ def disqualified(interface: InterfaceInfo) -> bool:
3328
return any(x in interface.name.upper() for x in DISQUALIFIED)
3429

3530

36-
def likelihood(interface: InterfaceInfo, pxe_switch_macs: set[str]) -> list[bool | str]:
31+
def likelihood(interface: InterfaceInfo) -> list[bool | str]:
3732
"""A value that is sortable. Lower is better."""
3833
return [
3934
# python sort order: false is "better" than true
40-
not connected_to_known_pxe_switch(interface, pxe_switch_macs),
4135
not connected_to_any_switch(interface),
4236
nic_port_number(interface),
4337
interface.name, # tiebreaker
4438
]
4539

4640

47-
def connected_to_known_pxe_switch(interface: InterfaceInfo, pxe_switch_macs) -> bool:
48-
return interface.remote_switch_mac_address in pxe_switch_macs
49-
50-
5141
def connected_to_any_switch(interface: InterfaceInfo) -> bool:
5242
return interface.remote_switch_mac_address is not None
5343

0 commit comments

Comments
 (0)