Netbox Plugin: Error: ipaddr: the address has neither IPv6 nor IPv4 format
-
@olivierlambert Yes but that's not going to tell me what the netbox plugin is erroring on. That command returns data which looks correctly formatted with no issue but there is something somewhere in it which is causing a problem.
I meant is there a way for me to run the netbox plugin sync by hand in cli or VM by VM to see where the problem occurs.
Or, barring that, a way to increase the logging level so that I can see with more detail what uuid at least, it's failing on and debug from there.
-
I'm not sure we can get more, it might be the way some IP are parsed. Pinging @pdonias
-
@olivierlambert I did some digging and just added some extra logging to the script file and found the culprit:
2021-07-27T09:03:46.545Z xo:netbox INFO Parsing IP: 10.44.254.253 10.44.254.254
It's in interface that's listing two IPs together with a space between.
I've tried a couple of things to get it to ignore any like those that it finds but haven't been successful yet. You have already closed/fixed an issue I raised about this about a month ago so I'm not sure why I'm seeing it in this one, now. It's the 5.80 server.
-
@pdonias does it sound to be the problem?
-
@olivierlambert Most likely, yes. But it shouldn't be an issue anymore after this change (XO 5.60) so I don't understand why the error is still happening.
@notscottsmith Do you see those space-delimited IPs in the UI too?
-
@pdonias Yea, it shows up like this:
-
@notscottsmith Ok, could you run this inside XO's directory with the VM's host and its password:
./packages/xen-api/dist/cli.js --au <HOST> root <HOST ROOT PASSWORD>
It should start a CLI. And then run this with the VM's UUID:
> find({ uuid: '<VM UUID>' }).$guest_metrics.networks
-
{ '2/ip': '10.44.254.253 10.44.254.254', '2/ipv4/0': '10.44.254.253 10.44.254.254', '1/ip': '172.16.130.25', '1/ipv4/0': '172.16.130.25', '0/ip': '10.1.254.238', '0/ipv4/0': '10.1.254.238' }
-
@notscottsmith So apparently, the old protocol also adds
x/ipv4/x
fields with space-delimited IPs. That's what causing the issue, so we'll have to handle them too. Thanks! -
So I've dug into the issue and written a few workarounds which will tide me over until a fix comes out - appreciate your work on this.
I've added a few features in, too. The plugin now:
- Allows the choice of whether IPv4, IPv6 or Both types of IPs are synchronised
- Allows you to enter in tags which will deem a VM to be "ignored" if they have one of these tags
- Allows you to enter in text which if the name label contains it, it will also be ignored (we have a use case where we have several VMs which are decommissioned but are kept in XCP for various reasons as well as our backup process which maintains a series of VMs with the prefix XCP-BACKUP, which we don't want kept in Netbox)
- Allows you to configure the ID of the configured VRF in Netbox (if needed) that the particular IP ranges relate to
- Synchronises the platform that the VM is running
- Brings across all the tags and puts them into Netbox (this is for our monitoring solution, OpenNMS, which uses Netbox to generate its requisitions and categories to automate the provisioning process)
I will submit these changes back into the Git repo tomorrow when I'm back in the office and you can have a look and see what you want to use.
-
any updates on this? Currently running into this error myself.
-
Are you up to date? I think we fixed that already
-
I think so? Unless my script isn't updating the plugins, which is totally possible.
edit: quick look at github says my plugins are fine
-
Not the latest commit but I don't think it matters in your case. @pdonias any idea?
-
Its the 5.66.1 release commit-so its damn close.
-
Hi @theaeon, this should already be fixed, could you check the full log for that error in Settings > Logs? It should give you more details.
-
Same as the OP.
netbox.synchronize { "pools": [ "582481e9-4e61-a060-6c09-530e35606504" ] } { "message": "ipaddr: the address has neither IPv6 nor IPv4 format", "name": "Error", "stack": "Error: ipaddr: the address has neither IPv6 nor IPv4 format at Object.parse (/opt/xo/xo-builds/xen-orchestra-202112260451/packages/xo-server-netbox/node_modules/ipaddr.js/lib/ipaddr.js:929:19) at Netbox.#synchronize (/opt/xo/xo-builds/xen-orchestra-202112260451/packages/xo-server-netbox/src/index.js:560:35) at Api.callApiMethod (file:///opt/xo/xo-builds/xen-orchestra-202112260451/packages/xo-server/src/xo-mixins/api.mjs:307:20)" }
-
Thanks @theaeon. Could you check if some of your VMs on that pool have invalid IP addresses? You can do that from the home page by filtering only the VMs on that pool (Pools selector at the top of the page) and expanding the details for all the VMs to show the IP addresses (hamburger button at the top right hand corner). Each IP address must be in its own blue rectangle and with the correct format for either IPv4 or IPv6. Let me know if this is too hard to check, we'll find another way.
-
@pdonias One of my VMs isn't reporting an IP address. Do you think that could do it?
-
@theaeon No, that's a normal case and it's handled properly. The issue would be if one of the IPs has 2 IPs in the same field separated by a white space like: "x.x.x.x y.y.y.y", or if the field is just empty or anything else that doesn't look like a proper IP address.
If you want to check the addresses more thoroughly, you can install
xo-cli
withnpm i -g xo-cli
, log into your XO withxo-cli --register <XO-Server URL> <username> <password>
and then runxo-cli --list-objects --addresses type=VM \$pool=<pool ID>
.