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

Set primary ip to always triggers http patch even without differences #172

Closed
rizlas opened this issue Apr 8, 2022 · 3 comments
Closed
Labels
bug Something isn't working
Milestone

Comments

@rizlas
Copy link
Contributor

rizlas commented Apr 8, 2022

Hi,
as stated in this discussion #164 the param set_primary_ip setted to always will trigger an http patch even when the primary ip is not changed.

Some clarification logs:

2022-04-08 10:44:32,539 - DEBUG2: Trying to find prefix for IP: 192.168.9.9/24
2022-04-08 10:44:32,568 - DEBUG2: No matching NetBox prefix for '192.168.9.9/24' found
2022-04-08 10:44:32,615 - DEBUG2: Found existing NetBox IP address object: 192.168.9.9/24
2022-04-08 10:44:32,616 - DEBUG2: Parsing 'IP address' data structure: 192.168.9.9/24
2022-04-08 10:44:32,640 - DEBUG: Setting IP '192.168.9.9/24' as primary IPv4 for 'some_fqdn_machine'
2022-04-08 10:44:32,641 - DEBUG2: Parsing 'virtual machine' data structure: some_fqdn_machine
netbox-sync_1 | 2022-04-08 10:44:32,641 - INFO: Virtual machine 'some_fqdn_machine' attribute 'primary_ip4' changed from '{'id': 846, 'url': 'http://netbox:8080/api/ipam/ip-addresses/846/', 'display': '192.168.9.9/24', 'family': 4, 'address': '192.168.9.9/24'}' to '192.168.9.9/24'
2022-04-08 10:47:50,694 - INFO: Updating NetBox 'virtual machine' object 'some_fqdn_machine' with data: {'primary_ip4': 846}
2022-04-08 10:47:50,694 - DEBUG2: Sending PATCH to 'http://netbox:8080/api/virtualization/virtual-machines/22/' with data 'b'{"primary_ip4": 846}''.
2022-04-08 10:47:50,868 - DEBUG2: Received HTTP Status 200

@rizlas rizlas changed the title Set primary ip triggers http patch even without differences Set primary ip to always triggers http patch even without differences Apr 8, 2022
@bb-Ricardo bb-Ricardo added the bug Something isn't working label Apr 9, 2022
@bb-Ricardo bb-Ricardo added this to the 1.2.3 milestone Apr 9, 2022
@bb-Ricardo
Copy link
Owner

Again, great find thank you. I must have been sleeping when refactoring the data model initialisation last year.

in the VM data model the primary_ip4 and the primary_ip6 fields were not assigned the proper NBIPAddress. This way it was not resolved properly as a NetBox object. And when the comparing happened between the old and the new value they of course looked different which lead to the "issue".

It's fixed now in development.

@bb-Ricardo
Copy link
Owner

fixed in version 1.2.3

@rizlas
Copy link
Contributor Author

rizlas commented Apr 15, 2022

Thank you Ricardo, working beautifully now!

dupondje pushed a commit to dupondje/netbox-sync that referenced this issue May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants