Closed dietybright closed 8 months ago
I would like to delete arp entry one by one and make a test on netdoc but seem no delete option on GUI/API
when trying to run report/script by python cli, I am getting below output, not sure where is the source issue from netdoc arp table
ubuntu@netbox:~$ sudo /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py runscript --loglevel debug netdoc_scripts.IPAMFromARP
[2024-01-03 10:39:47,889][INFO] - Running script (commit=False)
[2024-01-03 10:39:47,899][ERROR] - An exception occurred: AttributeError: 'NoneType' object has no attribute 'address'
Traceback (most recent call last):
File "/opt/netbox/netbox/extras/management/commands/runscript.py", line 45, in _run_script
script.output = script.run(data=data, commit=commit)
File "/opt/netbox/netbox/scripts/netdoc_scripts.py", line 443, in run
.address.prefixlen
AttributeError: 'NoneType' object has no attribute 'address'
[2024-01-03 10:39:47,899][INFO] - Database changes have been reverted due to error. [2024-01-03 10:39:47,900][ERROR] - Exception raised during script execution: 'NoneType' object has no attribute 'address' [2024-01-03 10:39:47,907][INFO] - Script completed in 0 minutes, 0.01 seconds
ubuntu@netbox:~$ sudo /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py runreport netdoc_reports.IPAMFromARP
[03:40:27] Running netdoc_reports.IPAMFromARP...
Traceback (most recent call last):
File "/opt/netbox/netbox/manage.py", line 10, in
Hi! Sorry for the delay.
In the first message you are writing about report, on the second one you are writing about script. On my small lab both are working fine, so I need additional help from you.
I think you are using an old version of netbox. 2 months ago I fixed a bug (maybe the one you are encountering) and current source file looks different from yours (https://github.com/dainok/netdoc/blob/master/netdoc/jobs/netdoc_scripts.py see line 443)
Hi @dainok ,
Actually I used to new version 3.5.15, netdoc_scripts.py is the same on my env but not sure why when running the script it showing the error on row 443.
Can you have a look on the error log when run report as above message
@dietybright can you verify the md5?
md5sum /opt/netbox/netbox/scripts/netdoc_scripts.py
You should get 8f67adee4364f8a997feefa8ac90daf9
. If not please overwrite with the one in the netdoc repository.
I was the same with original one
8f67adee4364f8a997feefa8ac90daf9 /opt/netbox/netbox/scripts/netdoc_scripts.py
@dietybright can you please check if you have ARP entries without IP address? It should not happen, but this could be the cause.
All arp entries have IP address, some entry having mac-address 00:00:00:00:00:00, do you think this is the cause?
No, 0 should be supported even if I don't expect it. Can you put a print before the failing line and check which entry is failing?
I tried to add print(address) under line446 opt/netbox/netbox/scripts/netdoc_scripts.py, but whenever excute command "sudo /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py runscript --loglevel debug netdoc_scripts.IPAMFromARP" it will override all the change
Better if you use logging.error(item)
Hi @dainok , could you share more specific where should I put logging.error(item) to find down the issue, I tried to put logging.error(address) at line 446 but still not able to show up the detail debug
Try the following:
# IP address with prefixlen built from ARP table and associated interface
logging.error(arptableentry_o) # <- ADD THIS LINE
address = str(arptableentry_o.ip_address.ip)
prefixlen = (
arptableentry_o.interface.ip_addresses.filter(
address__net_contains_or_equals=address
)
.first()
.address.prefixlen
)
ip_address = f"{address}/{prefixlen}"
Hi @dainok ,
It still same, everytime I run command "sudo /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py runscript --loglevel debug netdoc_scripts.IPAMFromARP", the added command under /opt/netbox/netbox/scripts/netdoc_scripts.py gone, any idea?
yes, you have to modify the script in the netdoc folder, not in netbox. This happens because every time netbox is started (server or rq) scripts are updated from netdoc folder.
Got the cause now,
[2024-01-29 17:43:19,886][INFO] - Running script (commit=False)
ERROR:root:0.0.0.0/32 has AA:AE:20:11:04:38 at ae1.2011 (ae1.2011)
[2024-01-29 17:43:20,760][ERROR] - An exception occurred: AttributeError: 'NoneType' object has no attribute 'address'
@dainok can we ignore 0.0.0.0/32 ?
That's interesting you have an ARP for 0.0.0.0 :) Let me think about how to avoid this.
@dainok anyway we can delete netdoc arp entry manually? I will try to delete those 0.0.0.0 and try again
Yes, using netbox shell
from netdoc import models
models.ArpTableEntry.objects.filter(...your filter...).delete()
It worked, thank @dainok
when running report IPAMFromARP, it is showing error without any other message, not sure where is the issue
Check corrispondence between ARP table and IPAM
Started: 2024-01-02 18:00 Duration: 0 minutes, 0.10 seconds Errored Report Methods Report Results Time Level