-
Notifications
You must be signed in to change notification settings - Fork 8
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
[Bug] VLAN is assigned to group Default netbox-ssot vlan group (scope: None); cannot also assign to site Foo. #358
Comments
Actually Example : Vlan{ID: 90, Name: VM Network, Vid: 10, Status: active, Site: 13}
Vlan{ID: 96, Name: VM Network, Vid: 10, Status: active, Site: 14} From |
@bb-Ricardo can you please confirm this is the current implementation in |
It seems to come from here https://github.com/bl4ko/netbox-ssot/blob/main/internal/netbox/inventory/add_items.go#L695 IMHO |
Oh, I see this is a limitation on the netbox's side. If a vlan is assigned to vlangroup, and vlangroup is not assigned to a site, this vlan can't be assigned a site, because site isn't the same as vlangroup's one. So I guess to implement this feature, I need to change the logic of assigning vlangroup to vlans. If vlan is a assigned a site than the vlangroup for this vlan should also be part of the site... |
Hi, indeed, the Interface, IP and VLAN syncing is not trivial for vCenter objects: The logic is implemented here: https://github.com/bb-Ricardo/netbox-sync/blob/3c07a4c001443f50d95ae4668c931599e41efeae/module/sources/common/source_base.py#L234 this function is used on each interface of a Host or VM:
This has been done to comply to the object relations and constrains within NetBox |
Yes, the VLAN Group needs to be defined with the site constrain and matched accordingly. To give the user the flexibility to configure this, these config options have been added: |
And I forgot: After all sources are synced, then the IP address assignment for active and non active interfaces are reevaluated and set accordingly. Only after you have discovered all objects and interfaces you are able to tell for sure if an IP address has been moved from one object/interface to another. And if this was the primary IP then this primary IP has to be first removed from the object, then the IP needs to be assigned to the new object interface and then the primary can be defined to the newly assigned object. Otherwise NetBox will complain all the time. |
Hi, thanks for all of the resources. I see this is a quite complex problem. And this logic must not only be implemented for vcenter, but also for other sources, so I will try to create common functions that can be shared. I will dive into it. |
I know, this took a lot of iterations to get to this state (still believe it's missing some edge cases). I also moved this to the common source section as it is indeed, a common concept of assigning relations. |
@bl4ko Hi there! Any news? Let me know if you need something to get this done 😏 Thank you! |
I have added option to tackle this problem in the following way: vlanGroupRelations:
- .* = FooVlanGroup
vlanSiteRelations:
- .* = Foo
vlanGroupSiteRelations:
- .* = Foo |
@bl4ko thanks for working on this! your solution seems reasonable but I still have issues during synchronization : 2025/01/15 16:03:19 add_items.go:714 DEBUG (inventory): Vlan VM Network does not exist in Netbox. Creating it...
2025/01/15 16:03:19 rest.go:137 DEBUG (inventory): Creating objects.Vlan with path /api/ipam/vlans/ with data: Vlan{ID: 96, Name: VM Network, Vid: 10, Status: active, Site: Site{Name: Bar}}
2025/01/15 16:03:19 main.go:69 ERROR (main): unexpected status code: 400: {"__all__":["VLAN is assigned to group Default netbox-ssot vlan group (scope: None); cannot also assign to site Bar."]}: initVlans Vlans are wrongly scoped to |
Oh, yeah I see... |
I have pushed another commit, i think this should work now... |
@bl4ko I've just tested your patch and it still doesn't work 😢 2025/01/17 01:21:35 add_items.go:714 DEBUG (inventory): Vlan VM Network does not exist in Netbox. Creating it...
2025/01/17 01:21:35 rest.go:137 DEBUG (inventory): Creating objects.Vlan with path /api/ipam/vlans/ with data: Vlan{ID: 96, Name: VM Network, Vid: 10, Status: active}
2025/01/17 01:21:36 main.go:69 ERROR (main): unexpected status code: 400: {"__all__":["VLAN is assigned to group BarDefaultVlanGroup (scope: None); cannot also assign to site Bar."]}: initVlans "VLAN is assigned to group BarDefaultVlanGroup (scope: None); cannot also assign to site Bar." It seems that A VLAN either belongs to a In our case we only use |
Ok, thanks for the report. It is possible that both VlanGroup and Site are assigned if VlanGroup is scoped to Site. I will fix this again, since I missed it here:
|
I have added another commit. Now I am pretty confident this should work... @n-rodriguez does it work now? |
The vlan part has worked but I had another issue with the vmware cluster part. Let me retry on monday. Thank you! |
Is this urgent?
Yes, it's critical
How are you running netbox-ssot?
From source (Go)
What is the version of netbox-ssot
Running version unknown built on unknown (commit unknown)
Which module has the issue?
General (not module-specific)
Share your configuration
What is the problem?
VLAN is not created in Netbox.
Steps to reproduce
netbox-ssot -config ./config.yml
What did you expect to happen?
It should work
What actually happened?
Share DEBUG-level logs (remove sensitive information)
Share your environment details
No response
The text was updated successfully, but these errors were encountered: