dainok / netdoc

Automatic Network Documentation plugin for NetBox
GNU General Public License v3.0
84 stars 14 forks source link

pyVmomi ingest vm ip address - followup #94 #96

Closed dietybright closed 8 months ago

dietybright commented 9 months ago

I tried to customizing script to ingest vm ip address but having issue.

Discover script:

Investor script:

When trying to run discovery/ingest, there is an issue "unexpected keyword arguments: 'address'".

Seem address of vm interface need to ingest under IPAM or something

dainok commented 9 months ago

You should not customize Netdoc scripts, you should create one that help you. BTW a better solution is:

  1. ingest ARP from your L3 devices
  2. run the Netdoc job to sync IPAM from ARP
  3. develop a new script to update IPAM from vCenter info (you don't need netmask because you already have in IPAM)

The (3) could be a script to be added in Netdoc.

dietybright commented 8 months ago

Hi @dainok ,

I am able develop a python script to get ip address/mask from pyvmomi, compare with current vm ip address via netbox api, then create/up ip address, primary ip4.

For netdoc sync ipam from arp, I am encountering error message as below, any idea?

An exception occurred: AttributeError: 'NoneType' object has no attribute 'address'

Traceback (most recent call last): File "/opt/netbox/netbox/extras/scripts.py", line 504, in _run_script script.output = script.run(data=data, commit=commit) File "/opt/netbox/netbox/scripts/netdoc_scripts.py", line 439, in run .address.prefixlen AttributeError: 'NoneType' object has no attribute 'address'

dainok commented 8 months ago

Hi @dietybright sorry for the late response. The affected lines are:

            prefixlen = (
                arptableentry_o.interface.ip_addresses.filter(
                    address__net_contains_or_equals=address
                )
                .first()
                .address.prefixlen
            )

I suspect that the query arptableentry_o.interface.ip_addresses.filter is returning None, thus address.prefixlen is Failing. This should not happen. Can you debug your setup? I suggest to run the script line by line from a Netbox shell because each type you restart Netbox, the init script will update and overwrite Netbox scripts.

dietybright commented 8 months ago

Will create another issue with update IPAM from arp table