-
Notifications
You must be signed in to change notification settings - Fork 7
feat: understack trunk #668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
13d8f25
to
67be9ec
Compare
67be9ec
to
4b302b9
Compare
4b302b9
to
3e8df8d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, but have a few minor suggestions for potential improvements (comments inline).
Also the UnderStackTrunkDriver
class could really use some docstrings, at least on the public methods with a high level explanation of why we react to certain events and what we intend to do.
Another potential refactoring opportunity is in how the configure_tenant_vlan_id and _subports_added are split, consider something similar to this:
def _configure_subports(self, subports: list[SubPort]) -> None:
for subport in subports:
network_id = utils.fetch_subport_network_id(subport_id=subport.port_id)
tenant_vid = self.nb.fetch_tenant_vid(
network_id=network_id
)
if tenant_vid:
self._update_vni(tvid, subport)
elif tenant_vid != subport.segmentation_id:
self._handle_mismatch(tenant_vid, subport, network_id)
def _update_vni(tvid, subport):
ucvni_uuid = utils.fetch_subport_network_id(subport_id=subport.port_id)
self.nb.add_tenant_vlan_tag_to_ucvni(
network_uuid=ucvni_uuid, vlan_tag=subport.segmentation_id
)
LOG.info(
"Segmentation ID: %(seg_id)s is now set on Nautobot's UCVNI "
"UUID: %(ucvni_uuid)s in the tenant_vlan_id custom field",
{"seg_id": subport.segmentation_id, "ucvni_uuid": ucvni_uuid},
)
def _handle_mismatch(tenant_vlan_id, subport, subport_network_id):
if tenant_vlan_id != subport.segmentation_id:
err = SubportSegmentationIDError(
seg_id=subport.segmentation_id,
net_id=subport_network_id,
nb_seg_id=tenant_vlan_id,
subport_id=subport.port_id,
)
subport.delete()
raise err
^ untested
This PR will enable us to set "tenant_vlan_id" on UCVNI in Nautobot when first subport is added to neutron trunk and user specifies the "segmentation_id" when adding the subport. The idea is that we will use the "tenant_vlan_id" as mapped VLAN that is local to the switchport during server provisioning.
This PR covers only the trunk driver part and there will be another one where we will adjust the understack mechanism driver, so when server will go through provisioning, we will detect the trunk_details on the port attached and do the needful to configure our network.