Skip to content
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

Add config option to assign VLANs to VLAN groups #373

Open
KPTheProf opened this issue Feb 22, 2024 Discussed in #372 · 16 comments
Open

Add config option to assign VLANs to VLAN groups #373

KPTheProf opened this issue Feb 22, 2024 Discussed in #372 · 16 comments
Labels
enhancement New feature or request
Milestone

Comments

@KPTheProf
Copy link

Discussed in #372

Originally posted by KPTheProf February 22, 2024
Hi

I have a large number of VLAN's and multiple VLAN Groups configured in Netbox.
I have a VLAN Group for VMware VLAN's but when I import the data, it is imported into the same VLAN number but in a different group.
Is there a way to configure the settings.ini to specify which VLAN group I want the VLAN's added to or updated?

If possible, could I suggest that the currect VLAN options be extended to include a VLAN group or groups based on regex key / value pair similar to the tenant information.

vlan_group_relation_by_name = London/Vlan_.* = VLAN Group 1, Tokio/Vlan_.* = VLAN Group 2
vlan_group_relation_by_id = 1023-1042 = VLAN Group 1

@bb-Ricardo
Copy link
Owner

Mmhhh, this looks quite nice.

Thabk you. Will try to add it.

@thuguet
Copy link

thuguet commented Apr 18, 2024

We also would need that!
Also i could be extra nice to define VLAN based on the vSwitch name but if necessary we can do that using the portgroup name too

@KPTheProf
Copy link
Author

Hi @bb-Ricardo, is there any progress with this update for multiple VLAN's and VLAN groups please?

@bb-Ricardo
Copy link
Owner

Hi @KPTheProf,

sorry for the delay, didn't had time the last few weeks to work on this project.

@bb-Ricardo bb-Ricardo added the enhancement New feature or request label May 14, 2024
@Croes1
Copy link

Croes1 commented Nov 4, 2024

Hi!

Are you working on this enhancement? It would be great to have this option to add VLANs to a group.

The script is really great and saved us a lot of time when importing data from vcenter!

@bb-Ricardo
Copy link
Owner

Just had a look at it and it seems a bit strange API wise. Maybe someone else can have a look as well.

I just tested it with NetBox 4.1.6. The UI specifies a VLAN ID's range but the API specification does not mention a VLAN ID. but when you request the object via API, it returns a vid_ranges

POST reuest schema:
Bildschirmfoto 2024-11-20 um 23 32 08

GET response schema:
Bildschirmfoto 2024-11-20 um 23 19 39

GET result on a test group:
Bildschirmfoto 2024-11-20 um 23 20 18

What do you think?

@bb-Ricardo
Copy link
Owner

Ok, it's a known issue: netbox-community/netbox#17488

@Croes1
Copy link

Croes1 commented Nov 21, 2024

Ah.. then there’s not much to do than wait until it’s fixed.

@bb-Ricardo
Copy link
Owner

I believe it still can be added.

Just wondering what's the expectation here.

  • The VLAN groups exist in NetBox before and just get assigned to the VLAN according to the config
  • Does the VLAN group need to be created as well?

Because there exists a discrepancy between the API and the UI.

When creating an VLAN group via UI, the VLAN ID range is mandatory. Creating a VLAN Group via API only requires a name and a slug.

What do you think?

@KPTheProf
Copy link
Author

From my perspective, I would expect the VLAN group to already exist because I want to ensure that the VLAN's are only added to that group and not to another group that might have the same VLAN ID.

@bb-Ricardo
Copy link
Owner

Hi @Croes1, @KPTheProf, @thuguet,

I finally (sorry for this long wait) got some time to implement this feature. I pushed a new commit to the devlopment branch. Would you be able to test this?

@bb-Ricardo bb-Ricardo changed the title VLAN's Not Importing Into Correct VLAN Group Add config option to assign VLANs to VLAN groups Nov 22, 2024
@bb-Ricardo bb-Ricardo added this to the v1.8.0 milestone Nov 22, 2024
@KPTheProf
Copy link
Author

Hi @bb-Ricardo
I normally run netbox-sync using the docker image as I'm using the docker version of Netbox on Windows for testing.
I've tried to run the development branch using Python on Windows, but I'm getting strange errors.

File " ... \pyVmomi\SoapAdapter.py", line 1003, in <module>
    _SocketWrapper = ssl.wrap_socket
                     ^^^^^^^^^^^^^^^
AttributeError: module 'ssl' has no attribute 'wrap_socket'

Do have a docker development version that I can test against?

@KPTheProf
Copy link
Author

Hi @bb-Ricardo
Don't worry, I've got it to work now.
I'm using Anaconda to setup my Python env and the latest version of pyvmomi was 7.0
I updated to version 8.0.3.0.1 using pip instead and I'm now able to run it.

@KPTheProf
Copy link
Author

KPTheProf commented Nov 27, 2024

Hi @bb-Ricardo
Looks like I spoke too soon. It was running for quite some time, but then failed near the end.

Traceback (most recent call last):
  File "\netbox-sync\netbox-sync.py", line 146, in <module>
    main()
  File "\netbox-sync\netbox-sync.py", line 117, in main
    inventory.query_ptr_records_for_all_ips()
  File "\netbox-sync\module\netbox\inventory.py", line 426, in query_ptr_records_for_all_ips
    records = perform_ptr_lookups(data.get("ips"), data.get("servers"))

This is the only change I've made to my settings.ini for the test

vlan_group_relation_by_id = 1-4094 = Company CCS

@bb-Ricardo
Copy link
Owner

Hey,

thank you for the effort. I just created an beta image with the latest code changes here: docker pull bbricardo/netbox-sync:1.7.1-beta.1

@Croes1
Copy link

Croes1 commented Nov 27, 2024

Thank you for working on this!

I agree, I expect the vlan group to already exist.

I’ll try to do some tests next week! Got some other stuff at work I have to complete first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants