Openstack get mac external dhcp#16
Merged
Merged
Conversation
… DHCP OpenStack assigns the mac at the platform level, so get_mac must read it from the API. With external DHCP the server 'addresses' field comes back empty, leaving unique_id blank: cache machines never reached "valid" and the actor reported "Unmanaged host". - Fall back to the Neutron port mac (mac_address is always present, regardless of DHCP/IP allocation) when 'addresses' is empty. - Tolerate not-yet-created (404) and policy/transient errors (403/...) by degrading to '' so the state checker retries instead of forcing the userservice to ERROR. - Apply the same fix to the fixed service (also fixes an IndexError on addresses[0] under external DHCP). - Add list_ports() + PortInfo to the OpenStack client/types. - Cover both services with tests (live + fixed).
op_create_checker bypassed the guarded get_mac/get_ip and read server_info.addresses[0] directly. Under external DHCP, Nova leaves 'addresses' empty, so addresses[0] raised IndexError and pushed the userservice to ERROR. Reuse the guarded service methods instead: get_mac resolves the mac via the Neutron port and get_ip returns '' (the real ip is learned later from the actor).
dkmstr
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements and refactorings to the OpenStack service integration, focusing on more robust MAC address retrieval, support for external DHCP environments, and modernizing type annotations. The most significant changes include the addition of a new
PortInfotype, aget_server_macmethod that can retrieve MAC addresses even when Nova'saddressesfield is empty, and a general migration to Python 3.10+ union type syntax. These changes enhance reliability in diverse OpenStack network configurations and improve code clarity.OpenStack MAC Address Handling and External DHCP Support:
PortInfodataclass inopenstack/types.pyto represent Neutron port information, including MAC addresses and fixed IPs. ([src/uds/services/OpenStack/openstack/types.pyR248-R271](https://github.com/VirtualCable/broker/pull/16/files#diff-fb2f112db2b28da61a16af9b168ee4fa051d5373f453378fb50c3d59413c2133R248-R271))get_server_macinOpenStackClient, which attempts to retrieve the MAC address from Nova server info and, if unavailable (e.g., due to external DHCP), queries Neutron ports as a fallback. This prevents errors when the MAC is temporarily unavailable. ([src/uds/services/OpenStack/openstack/client.pyR615-R636](https://github.com/VirtualCable/broker/pull/16/files#diff-c0480f8af38b2e89a44f5280fcd1bef82024145e3bae832fc49b37273eff4bd8R615-R636))get_mac,get_ip, etc.) inservice.pyandservice_fixed.pyto use the newget_server_macmethod, improving reliability when dealing with external DHCP setups. ([[1]](https://github.com/VirtualCable/broker/pull/16/files#diff-e4398775b85f8b64749496e908ea090e4eb367d72c1c418e5cfe36d19e994a78L254-R281),[[2]](https://github.com/VirtualCable/broker/pull/16/files#diff-5017c1760c5d340a51243d50042a1c32feb4385c57ea9a4c520765885bb1b980L199-R201),[[3]](https://github.com/VirtualCable/broker/pull/16/files#diff-eb9a50ffe95cc963b15364929e45b332d1ac1bfdb632640d333c27bedb28a3e3L172-R176))API and Type Annotation Modernization:
X | Yunion syntax instead oftyping.Optionalandtyping.Union. ([[1]](https://github.com/VirtualCable/broker/pull/16/files#diff-c0480f8af38b2e89a44f5280fcd1bef82024145e3bae832fc49b37273eff4bd8L109-R122),[[2]](https://github.com/VirtualCable/broker/pull/16/files#diff-c0480f8af38b2e89a44f5280fcd1bef82024145e3bae832fc49b37273eff4bd8L138-R141),[[3]](https://github.com/VirtualCable/broker/pull/16/files#diff-c0480f8af38b2e89a44f5280fcd1bef82024145e3bae832fc49b37273eff4bd8L292-R292),[[4]](https://github.com/VirtualCable/broker/pull/16/files#diff-c0480f8af38b2e89a44f5280fcd1bef82024145e3bae832fc49b37273eff4bd8L479-R479),[[5]](https://github.com/VirtualCable/broker/pull/16/files#diff-c0480f8af38b2e89a44f5280fcd1bef82024145e3bae832fc49b37273eff4bd8L618-R663),[[6]](https://github.com/VirtualCable/broker/pull/16/files#diff-c0480f8af38b2e89a44f5280fcd1bef82024145e3bae832fc49b37273eff4bd8L836-R882),[[7]](https://github.com/VirtualCable/broker/pull/16/files#diff-c0480f8af38b2e89a44f5280fcd1bef82024145e3bae832fc49b37273eff4bd8L865-R910),[[8]](https://github.com/VirtualCable/broker/pull/16/files#diff-a17350e2ba6601a4ba8b2a333351f4a959f6385c6968e0f8d5533c6e863953a3L205-R205),[[9]](https://github.com/VirtualCable/broker/pull/16/files#diff-a17350e2ba6601a4ba8b2a333351f4a959f6385c6968e0f8d5533c6e863953a3L223-R223),[[10]](https://github.com/VirtualCable/broker/pull/16/files#diff-c11cfa39f16f066ce38b75c9a31cf7cba8c444cbbb82e7f5bf5861fae14bc546L178-R178),[[11]](https://github.com/VirtualCable/broker/pull/16/files#diff-c11cfa39f16f066ce38b75c9a31cf7cba8c444cbbb82e7f5bf5861fae14bc546L190-R192),[[12]](https://github.com/VirtualCable/broker/pull/16/files#diff-e4398775b85f8b64749496e908ea090e4eb367d72c1c418e5cfe36d19e994a78L57-R57),[[13]](https://github.com/VirtualCable/broker/pull/16/files#diff-e4398775b85f8b64749496e908ea090e4eb367d72c1c418e5cfe36d19e994a78L189-R189),[[14]](https://github.com/VirtualCable/broker/pull/16/files#diff-e4398775b85f8b64749496e908ea090e4eb367d72c1c418e5cfe36d19e994a78L321-R320),[[15]](https://github.com/VirtualCable/broker/pull/16/files#diff-5017c1760c5d340a51243d50042a1c32feb4385c57ea9a4c520765885bb1b980L51-R51),[[16]](https://github.com/VirtualCable/broker/pull/16/files#diff-5017c1760c5d340a51243d50042a1c32feb4385c57ea9a4c520765885bb1b980L108-R108),[[17]](https://github.com/VirtualCable/broker/pull/16/files#diff-5017c1760c5d340a51243d50042a1c32feb4385c57ea9a4c520765885bb1b980L167-R167))Neutron Port Query Support:
list_portsmethod toOpenStackClientto allow querying Neutron for ports by network or device ID, supporting the new MAC address retrieval logic. ([src/uds/services/OpenStack/openstack/client.pyR567-R589](https://github.com/VirtualCable/broker/pull/16/files#diff-c0480f8af38b2e89a44f5280fcd1bef82024145e3bae832fc49b37273eff4bd8R567-R589))General Code Quality Improvements:
[src/uds/services/OpenStack/openstack/client.pyR615-R636](https://github.com/VirtualCable/broker/pull/16/files#diff-c0480f8af38b2e89a44f5280fcd1bef82024145e3bae832fc49b37273eff4bd8R615-R636))[[1]](https://github.com/VirtualCable/broker/pull/16/files#diff-a9299b29c8d705ff40152bc547657c14a722ceca19677fc6bafa32e84e78ab4cL51-R51),[[2]](https://github.com/VirtualCable/broker/pull/16/files#diff-e4398775b85f8b64749496e908ea090e4eb367d72c1c418e5cfe36d19e994a78L293-R298))These changes make the OpenStack integration more robust in real-world network environments and prepare the codebase for future Python enhancements.