Skip to content

Commit

Permalink
Have Enroll set physical network when creating ironic baremetal ports
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Keay committed Jan 14, 2025
1 parent 36ae6db commit 42247ba
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 86 deletions.
5 changes: 5 additions & 0 deletions python/understack-workflows/tests/fixture_nautobot_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
neighbor_chassis_mac="9C:54:16:F5:AB:27",
neighbor_location_name="IAD3",
neighbor_rack_name="F20-2",
ucvni_group_name="spine402-1.iad3",
),
NautobotInterface(
id="39d98f09-3199-40e0-87dc-e5ed6dce78e5",
Expand All @@ -40,6 +41,7 @@
neighbor_chassis_mac="9C:54:16:F5:AC:27",
neighbor_location_name="IAD3",
neighbor_rack_name="F20-2",
ucvni_group_name="spine402-1.iad3",
),
NautobotInterface(
id="7ac587c4-015b-4a0e-b579-91284cbd0406",
Expand All @@ -56,6 +58,7 @@
neighbor_chassis_mac="9C:54:16:F5:AD:27",
neighbor_location_name="IAD3",
neighbor_rack_name="F20-2",
ucvni_group_name="spine402-1.iad3",
),
NautobotInterface(
id="8c28941c-02cd-4aad-9e3f-93c39e08b58a",
Expand All @@ -72,6 +75,7 @@
neighbor_chassis_mac="9C:54:16:F5:AD:27",
neighbor_location_name="IAD3",
neighbor_rack_name="F20-2",
ucvni_group_name="spine402-1.iad3",
),
NautobotInterface(
id="60d880c7-8618-414e-b4b4-fb6ac448c992",
Expand All @@ -88,6 +92,7 @@
neighbor_chassis_mac="9C:54:16:F5:AE:27",
neighbor_location_name="IAD3",
neighbor_rack_name="F20-2",
ucvni_group_name=None,
),
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,10 @@
"id": "1ccd4b4a-7ba3-4557-b1ad-1ba87aee96a6",
"name": "F20-2"
},
"rel_vlan_group_to_devices": {
"rel_vlan_group_to_devices": [
{
"id": "275ef491-2b27-4d1b-bd45-330bd6b7e0cf",
"name": "f20-2-1.iad3.rackspace.net"
},
{
"id": "05f6715a-4dbe-4fd6-af20-1e73adb285c2",
"name": "f20-2-2.iad3.rackspace.net"
}
]
"vlan_group": {
"ucvni_group": {
"name": "spine402-1.iad3"
}
}
}
},
Expand Down Expand Up @@ -77,17 +70,10 @@
"id": "1ccd4b4a-7ba3-4557-b1ad-1ba87aee96a6",
"name": "F20-2"
},
"rel_vlan_group_to_devices": {
"rel_vlan_group_to_devices": [
{
"id": "275ef491-2b27-4d1b-bd45-330bd6b7e0cf",
"name": "f20-2-1.iad3.rackspace.net"
},
{
"id": "05f6715a-4dbe-4fd6-af20-1e73adb285c2",
"name": "f20-2-2.iad3.rackspace.net"
}
]
"vlan_group": {
"ucvni_group": {
"name": "spine402-1.iad3"
}
}
}
},
Expand Down Expand Up @@ -117,17 +103,10 @@
"id": "1ccd4b4a-7ba3-4557-b1ad-1ba87aee96a6",
"name": "F20-2"
},
"rel_vlan_group_to_devices": {
"rel_vlan_group_to_devices": [
{
"id": "275ef491-2b27-4d1b-bd45-330bd6b7e0cf",
"name": "f20-2-1.iad3.rackspace.net"
},
{
"id": "05f6715a-4dbe-4fd6-af20-1e73adb285c2",
"name": "f20-2-2.iad3.rackspace.net"
}
]
"vlan_group": {
"ucvni_group": {
"name": "spine402-1.iad3"
}
}
}
},
Expand Down Expand Up @@ -157,17 +136,10 @@
"id": "1ccd4b4a-7ba3-4557-b1ad-1ba87aee96a6",
"name": "F20-2"
},
"rel_vlan_group_to_devices": {
"rel_vlan_group_to_devices": [
{
"id": "275ef491-2b27-4d1b-bd45-330bd6b7e0cf",
"name": "f20-2-1.iad3.rackspace.net"
},
{
"id": "05f6715a-4dbe-4fd6-af20-1e73adb285c2",
"name": "f20-2-2.iad3.rackspace.net"
}
]
"vlan_group": {
"ucvni_group": {
"name": "spine402-1.iad3"
}
}
}
},
Expand Down Expand Up @@ -197,7 +169,7 @@
"id": "1ccd4b4a-7ba3-4557-b1ad-1ba87aee96a6",
"name": "F20-2"
},
"rel_vlan_group_to_devices": null
"vlan_group": null
}
},
"ip_addresses": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,10 @@
"rack": {
"id": "1ccd4b4a-7ba3-4557-b1ad-1ba87aee96a6"
},
"rel_vlan_group_to_devices": {
"rel_vlan_group_to_devices": [
{
"id": "275ef491-2b27-4d1b-bd45-330bd6b7e0cf",
"name": "f20-2-1.iad3.rackspace.net"
},
{
"id": "05f6715a-4dbe-4fd6-af20-1e73adb285c2",
"name": "f20-2-2.iad3.rackspace.net"
"vlan_group": {
"ucvni_group": {
"name": "spine402-1.iad3"
}
]
}
},
"id": "f9a5cc87-d10a-4827-99e8-48961fd1d773",
Expand All @@ -49,17 +42,10 @@
"rack": {
"id": "1ccd4b4a-7ba3-4557-b1ad-1ba87aee96a6"
},
"rel_vlan_group_to_devices": {
"rel_vlan_group_to_devices": [
{
"id": "275ef491-2b27-4d1b-bd45-330bd6b7e0cf",
"name": "f20-2-1.iad3.rackspace.net"
},
{
"id": "05f6715a-4dbe-4fd6-af20-1e73adb285c2",
"name": "f20-2-2.iad3.rackspace.net"
"vlan_group": {
"ucvni_group": {
"name": "spine402-1.iad3"
}
]
}
},
"id": "2148cf50-f70e-42c9-9f68-8ce98d61498c",
Expand All @@ -86,17 +72,10 @@
"rack": {
"id": "1ccd4b4a-7ba3-4557-b1ad-1ba87aee96a6"
},
"rel_vlan_group_to_devices": {
"rel_vlan_group_to_devices": [
{
"id": "275ef491-2b27-4d1b-bd45-330bd6b7e0cf",
"name": "f20-2-1.iad3.rackspace.net"
},
{
"id": "05f6715a-4dbe-4fd6-af20-1e73adb285c2",
"name": "f20-2-2.iad3.rackspace.net"
"vlan_group": {
"ucvni_group": {
"name": "spine402-1.iad3"
}
]
}
},
"id": "f72bb830-3f3c-4aba-b7d5-9680ea4d358e",
Expand All @@ -123,17 +102,10 @@
"rack": {
"id": "1ccd4b4a-7ba3-4557-b1ad-1ba87aee96a6"
},
"rel_vlan_group_to_devices": {
"rel_vlan_group_to_devices": [
{
"id": "275ef491-2b27-4d1b-bd45-330bd6b7e0cf",
"name": "f20-2-1.iad3.rackspace.net"
},
{
"id": "05f6715a-4dbe-4fd6-af20-1e73adb285c2",
"name": "f20-2-2.iad3.rackspace.net"
"vlan_group": {
"ucvni_group": {
"name": "spine402-1.iad3"
}
]
}
},
"id": "c210be75-1038-4ba3-9923-60050e1c5362",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class NautobotInterface:
neighbor_chassis_mac: str | None
neighbor_location_name: str | None
neighbor_rack_name: str | None
ucvni_group_name: str | None = None


@dataclass
Expand Down Expand Up @@ -252,6 +253,9 @@ def nautobot_server(nautobot, serial: str) -> NautobotDevice | None:
mac: cf_chassis_mac_address
location { id name }
rack { id name }
vlan_group: rel_vlan_group_to_devices {
ucvni_group: rel_ucvnigroup_vlangroup { name }
}
}
}
ip_addresses {
Expand Down Expand Up @@ -291,8 +295,12 @@ def parse_device(data: dict) -> NautobotDevice:


def parse_interface(data: dict) -> NautobotInterface:
connected = data["connected_interface"]
ip_address = data["ip_addresses"][0] if data["ip_addresses"] else None
connected = data["connected_interface"]
connected_device = connected and connected.get("device")
vlan_group = connected_device and connected_device.get("vlan_group")
ucvni_group = vlan_group and vlan_group.get("ucvni_group")

return NautobotInterface(
id=data["id"],
name=data["name"],
Expand All @@ -308,6 +316,7 @@ def parse_interface(data: dict) -> NautobotInterface:
neighbor_chassis_mac=connected and connected["device"]["mac"],
neighbor_location_name=connected and connected["device"]["location"]["name"],
neighbor_rack_name=connected and connected["device"]["rack"]["name"],
ucvni_group_name=ucvni_group and ucvni_group["name"]
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ class PortConfiguration(BaseModel):
name: str # port name
pxe_enabled: bool
local_link_connection: dict
physical_network: str | None
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def port_configuration(
name=name,
pxe_enabled=pxe_enabled,
local_link_connection=local_link_connection,
physical_network=interface.ucvni_group_name,
)


Expand Down

0 comments on commit 42247ba

Please sign in to comment.