Skip to content
This repository has been archived by the owner on Jan 8, 2021. It is now read-only.

Add Support for NetBox API version 2.9 #132

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Open

Add Support for NetBox API version 2.9 #132

wants to merge 14 commits into from

Conversation

bb-Ricardo
Copy link

@bb-Ricardo bb-Ricardo commented Sep 23, 2020

This adds support for NetBox 2.9 API changes. It is not backwards compatible with older NetBox API Versions.

Also adds some minor code improvements.

Refs: #129

Haeki and others added 14 commits June 23, 2020 16:07
vm.config.annotation is synced as comment to netbox
Tags use a description field instead of a comments field. This Field is also limited to 200 characters
same log statement already present at the start of the loop
Sometimes vCenter returns asset tags with a leading whitespace. Instead of adding a second version with a whitespace to the banned tags list we use the strip() method to remove the whitespace bevore checking
Strip whitespaces when checking if asset tag is banned
…ces/vms

* after NetBox changed the API 2.9 this assignment process was broken
@bb-Ricardo bb-Ricardo changed the title Develop Add Support for NetBox API version 2.9 Sep 23, 2020
@jozefrebjak
Copy link

Thank you. For me it's work. Netbox (v2.9.4).

@bb-Ricardo
Copy link
Author

Great.

I just started a complete reimplementation of this whole project.

Hope to finish it next week.

Would also need some testers 😀

@gstorme
Copy link

gstorme commented Oct 4, 2020

Also using it here, thank you.
Sign me up to test your future improvements 🤘

@fjasboka
Copy link

fjasboka commented Oct 5, 2020

We are using it and have a non production environment where I would be more then happy yo help test the reimplementation

@Haeki
Copy link

Haeki commented Oct 6, 2020

Thanks for the update I haven't noticed any problems so far.
Also looking forward to any news on the reimplementation.

@duviful
Copy link

duviful commented Oct 6, 2020

I'm also using it here, thank you Ricardo!

@OBenned
Copy link

OBenned commented Oct 6, 2020

Sign me up for testing too

@josephcouture
Copy link

Thanks! This almost works for us. There seems to be an issue where it the check for the the type of vCenter platform exists or not. When the initial check for it occurs Netbox responds that it does not exist. However, when vcenter-netbox-sync attempts to create the platform, Netbox now responds that it does exist.

This ultimately prevents the vCenter appliance from being created.

2020-10-29 20:36:13,997 [DEBUG] Sending GET to 'https://netbox.redacted.com/api/dcim/platforms/?name=Linux 4.4.221-3.ph1 VMware Photon 1.0 Photon VMware Photon 1.0 ' with data 'None'. 2020-10-29 20:36:14,042 [DEBUG] Received HTTP Status 200. 2020-10-29 20:36:14,043 [DEBUG] NetBox GET request OK; returned 200 status. 2020-10-29 20:36:14,043 [INFO] Netbox platforms 'Linux 4.4.221-3.ph1 VMware Photon 1.0 Photon VMware Photon 1.0 ' object not found. Requesting creation. 2020-10-29 20:36:14,044 [DEBUG] Sending POST to 'https://netbox.redacted.com/api/dcim/platforms/' with data '{'name': 'Linux 4.4.221-3.ph1 VMware Photon 1.0 Photon VMware Photon 1.0 ', 'slug': 'linux-4-4-221-3-ph1-vmware-photon-1-0-photon-vmware-photon-1-0-'}'. 2020-10-29 20:36:14,061 [DEBUG] Received HTTP Status 400. 2020-10-29 20:36:14,061 [WARNING] NetBox failed to create platforms object. A duplicate record may exist or the data sent is not acceptable. 2020-10-29 20:36:14,062 [DEBUG] NetBox 400 status reason: {"name":["platform with this name already exists."],"slug":["platform with this slug already exists."]} 2020-10-29 20:36:14,062 [DEBUG] Unaccepted request data: {'name': 'Linux 4.4.221-3.ph1 VMware Photon 1.0 Photon VMware Photon 1.0 ', 'slug': #'linux-4-4-221-3-ph1-vmware-photon-1-0-photon-vmware-photon-1-0-'}

@bb-Ricardo
Copy link
Author

It seems the platform name has a white space at the end. And NetBox probably strips the white space and finds a platform with exactly that name and refuses the recreation of the same name.

The mentioned rewrite is coming along well and I hope to have a basic fully functionality version by the end of next week.

@gstorme
Copy link

gstorme commented Oct 30, 2020

@josephcouture I had the same problem, see #127

@bb-Ricardo
Copy link
Author

I went down a rabbit hole and finally can see the light at the end of the tunnel again. This took way longer then expected (as usual).

Here you go: https://github.com/bb-Ricardo/netbox-sync

please test as much as you can: Debug logs are very welcome.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants