Skip to content

Commit 0383092

Browse files
authored
Merge pull request #1087 from rackerlabs/ironic-port-names
feat: make ironic port names node-name:port-name as a standard
2 parents 90d5e36 + 1d047d4 commit 0383092

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

python/understack-workflows/tests/test_sync_interfaces.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_sync_with_no_existing_interfaces(dell_nautobot_device):
2020
"address": "14:23:f3:f5:25:f1",
2121
"uuid": "8c28941c-02cd-4aad-9e3f-93c39e08b58a",
2222
"node_uuid": "a3a2983f-d906-4663-943c-c41ab73c9b62",
23-
"name": "8c28941c-02cd-4aad-9e3f-93c39e08b58a NIC.Slot.1-2",
23+
"name": f"{dell_nautobot_device.name}:NIC.Slot.1-2",
2424
"pxe_enabled": False,
2525
"local_link_connection": {
2626
"switch_id": "9c:54:16:f5:ad:27",
@@ -36,7 +36,7 @@ def test_sync_with_no_existing_interfaces(dell_nautobot_device):
3636
"address": "d4:04:e6:4f:8d:b5",
3737
"uuid": "39d98f09-3199-40e0-87dc-e5ed6dce78e5",
3838
"node_uuid": "a3a2983f-d906-4663-943c-c41ab73c9b62",
39-
"name": "39d98f09-3199-40e0-87dc-e5ed6dce78e5 NIC.Integrated.1-2",
39+
"name": f"{dell_nautobot_device.name}:NIC.Integrated.1-2",
4040
"pxe_enabled": False,
4141
"local_link_connection": {
4242
"switch_id": "9c:54:16:f5:ac:27",
@@ -52,7 +52,7 @@ def test_sync_with_no_existing_interfaces(dell_nautobot_device):
5252
"address": "14:23:f3:f5:25:f0",
5353
"uuid": "7ac587c4-015b-4a0e-b579-91284cbd0406",
5454
"node_uuid": "a3a2983f-d906-4663-943c-c41ab73c9b62",
55-
"name": "7ac587c4-015b-4a0e-b579-91284cbd0406 NIC.Slot.1-1",
55+
"name": f"{dell_nautobot_device.name}:NIC.Slot.1-1",
5656
"pxe_enabled": False,
5757
"local_link_connection": {
5858
"switch_id": "9c:54:16:f5:ad:27",
@@ -68,7 +68,7 @@ def test_sync_with_no_existing_interfaces(dell_nautobot_device):
6868
"address": "d4:04:e6:4f:8d:b4",
6969
"uuid": "ac2f1eae-188e-4fc6-9245-f9a6cf8b4ea8",
7070
"node_uuid": "a3a2983f-d906-4663-943c-c41ab73c9b62",
71-
"name": "ac2f1eae-188e-4fc6-9245-f9a6cf8b4ea8 NIC.Integrated.1-1",
71+
"name": f"{dell_nautobot_device.name}:NIC.Integrated.1-1",
7272
"pxe_enabled": False,
7373
"local_link_connection": {
7474
"switch_id": "9c:54:16:f5:ab:27",

python/understack-workflows/understack_workflows/sync_interfaces.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,19 @@ def get_nautobot_interfaces(
6565
Excludes interfaces with no MAC address
6666
6767
"""
68-
device_id = nautobot_device.id
69-
7068
return [
71-
port_configuration(interface, pxe_interface, device_id)
69+
port_configuration(interface, pxe_interface, nautobot_device)
7270
for interface in nautobot_device.interfaces
7371
if interface_is_relevant(interface)
7472
]
7573

7674

7775
def port_configuration(
78-
interface: NautobotInterface, pxe_interface: str, device_id: str
76+
interface: NautobotInterface, pxe_interface: str, device: NautobotDevice
7977
) -> PortConfiguration:
8078
# Interface names have their UUID prepended because Ironic wants them
8179
# globally unique across all devices.
82-
name = f"{interface.id} {interface.name}"
80+
name = f"{device.name}:{interface.name}"
8381
pxe_enabled = interface.name == pxe_interface
8482

8583
if interface.neighbor_chassis_mac:
@@ -92,7 +90,7 @@ def port_configuration(
9290
local_link_connection = {}
9391

9492
return PortConfiguration(
95-
node_uuid=device_id,
93+
node_uuid=device.id,
9694
address=interface.mac_address.lower(),
9795
uuid=interface.id,
9896
name=name,

0 commit comments

Comments
 (0)