Skip to content

UnboundLocalError: local variable 'ip' referenced before assignment #4

@izheen

Description

@izheen

Very nice too see this project revived, thank you for your work!

Im trying to get this setup in our testing environment, we have been using the original project for a while.

Im getting the following error when im trying to sync:

2020-11-13 10:47:02,966 - DEBUG2: Parsing vCenter VM: XX-XX-CRM
2020-11-13 10:47:02,985 - DEBUG2: Trying to find site name for cluster 'vSAN-HY'
2020-11-13 10:47:02,986 - DEBUG2: Found a match (vSAN-HY) for vSAN-HY, using site 'DC01'
2020-11-13 10:47:03,055 - DEBUG2: Found default IPv4 gateway 10.54.115.1
2020-11-13 10:47:03,055 - DEBUG2: Parsing device VirtualVmxnet3: 00:50:56:B2:D6:27
2020-11-13 10:47:03,062 - DEBUG2: Trying to find a virtual machine based on the collected name, cluster, IP and MAC addresses
2020-11-13 10:47:03,064 - DEBUG2: No exact match found. Trying to find virtual machine based on MAC addresses
2020-11-13 10:47:03,070 - DEBUG2: No match found. Trying to find virtual machine based on primary IP addresses
Traceback (most recent call last):
File "netbox-sync.py", line 165, in
main()
File "netbox-sync.py", line 146, in main
source.apply()
File "/opt/netbox-sync-dev/module/sources/vmware/connection.py", line 319, in apply
view_details.get("view_handler")(obj)
File "/opt/netbox-sync-dev/module/sources/vmware/connection.py", line 1510, in add_virtual_machine
p_ipv4=vm_primary_ip4, p_ipv6=vm_primary_ip6)
File "/opt/netbox-sync-dev/module/sources/vmware/connection.py", line 652, in add_device_vm_to_inventory
device_vm_object = self.get_object_based_on_primary_ip(object_type, p_ipv4, p_ipv6)
File "/opt/netbox-sync-dev/module/sources/vmware/connection.py", line 466, in get_object_based_on_primary_ip
if _matches_device_primary_ip(grab(device, "data.primary_ip4"), primary_ip4) is True:
File "/opt/netbox-sync-dev/module/sources/vmware/connection.py", line 447, in _matches_device_primary_ip
if ip is not None and ip.split("/")[0] == ip_needle:
UnboundLocalError: local variable 'ip' referenced before assignment

The VM it self is not yet in Netbox, the set_primary_ip directive is set to always in settings.ini. Please advice, Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions