bb-Ricardo/netbox-sync

VRF assignment

Closed this issue ยท 10 comments

rizlas commented

I wanted to ask how netbox-sync assigns VRF to ip address. We are encountering some problem and in settings we only found mentions about VRF in the comments for cluster_site_relation setting.

Can you shine some light please?

Hi @rizlas:

The VRF is "graded" from the prefix which matches the IP (search for possible_ip_vrf): https://github.com/bb-Ricardo/netbox-sync/blob/main/module/sources/common/source_base.py

Hi,
thank you for pointing me out. I'll have a look. Currently the assigned vrf seems to be wrong but "I need to go deeper" ๐Ÿ˜„

I'll continue here and not via email.

I think that the problem is here.
https://github.com/bb-Ricardo/netbox-sync/blob/main/module/sources/common/source_base.py#L198

Currently we are using the concept of stretched vlans, so the prefix has no site set cause the prefix is in more than one site.
Stretched vlans are implemented using vlan groups that enforce uniqueness (https://docs.netbox.dev/en/stable/models/ipam/vlangroup/).

Dunno how to proceed here ๐Ÿ˜•

Edit: I've also to clean my data so don't take it as granted.

Hi,
i think that the entire function return_longest_matching_prefix_for_ip needs a rework and I'll try to propose an alternative in the next days. Currently I've this questions in my mind:

  • Why not using native library ip_addresses to calculate an IP prefix
  • Why tenant is not considered
  • Why looking for the biggest/longest prefix

The statement about site in #357 (comment) is wrong, cause prefix are firstly filtered by site and then without it (all prefixes).

Hi @rizlas,

finally got around to add a warning regarding possible wrongly assigned VRF to an IP address.

can you test it out and see if it shows the conflicts?

Thank you

Traceback (most recent call last):
  File "/app/netbox-sync/./netbox-sync.py", line 146, in <module>
    main()
  File "/app/netbox-sync/./netbox-sync.py", line 111, in main
    source.apply()
  File "/app/netbox-sync/module/sources/vmware/connection.py", line 393, in apply
    view_details.get("view_handler")(obj)
  File "/app/netbox-sync/module/sources/vmware/connection.py", line 2383, in add_virtual_machine
    self.add_device_vm_to_inventory(NBVM, object_data=vm_data, vnic_data=nic_data,
  File "/app/netbox-sync/module/sources/vmware/connection.py", line 1121, in add_device_vm_to_inventory
    nic_object, ip_address_objects = self.add_update_interface(nic_object_dict.get(int_name), device_vm_object,
  File "/app/netbox-sync/module/sources/common/source_base.py", line 417, in add_update_interface
    log.warning(f"Possibly wrongly assigned VRF for {current_ip_nic.get_display_name()} IP "
AttributeError: 'NoneType' object has no attribute 'get_display_name'

You need another check for current_ip_nic

oh, damn it. sorry. I just pushed another commit which should fixes this.

Yeah working now. Thank you

Awesome. Can we close the issue or is still something missing?

Yes we can close it, thank you