netbox-sync
netbox-sync copied to clipboard
Problem with sync
Hi, I have Netbox v3.1.7 and netbox-sync v 1.2.3.
I got this error when start the sync process:
2022-07-20 14:20:42,408 - DEBUG: Start resolving relations
Traceback (most recent call last):
File "netbox-sync.py", line 145, in <module>
main()
File "netbox-sync.py", line 113, in main
inventory.resolve_relations()
File "/opt/netbox-sync-new/netbox-sync/module/netbox/inventory.py", line 216, in resolve_relations
this_object.resolve_relations()
File "/opt/netbox-sync-new/netbox-sync/module/netbox/object_classes.py", line 1554, in resolve_relations
self.data["assigned_object_id"] = self.inventory.get_by_id(self.data_model_relation.get(o_type), nb_id=o_id)
File "/opt/netbox-sync-new/netbox-sync/module/netbox/inventory.py", line 62, in get_by_id
(object_type.__name__, NetBoxObject.__name__))
AttributeError: 'NoneType' object has no attribute '__name__'
I also noticed that if I change this code in module/netbox/inventory.py
def get_by_id(self, object_type, nb_id=None):
"""
Try to find an object of $object_type with ID $id in inventory
Parameters
----------
object_type: NetBoxObject sub class
object type to find
nb_id: int
NetBox ID of object
Returns
-------
(NetBoxObject sub class, None): return object instance if object was found, None otherwise
"""
if object_type not in NetBoxObject.__subclasses__():
raise AttributeError("'%s' object must be a sub class of '%s'." %
(object_type.__name__, NetBoxObject.__name__))
to
def get_by_id(self, object_type, nb_id=None):
"""
Try to find an object of $object_type with ID $id in inventory
Parameters
----------
object_type: NetBoxObject sub class
object type to find
nb_id: int
NetBox ID of object
Returns
-------
(NetBoxObject sub class, None): return object instance if object was found, None otherwise
"""
if object_type not in NetBoxObject.__subclasses__():
return None
everything seems to start working fine: I'm new in python, so could you please help me to resolve this problem correctly?
Thanx in advice )
Hi, can you try the development branch. It should be already fixed there.
I had the same issue. I'm using the docker version. Is there a development image for docker with the fix?
Hi, can you try out the beta docker container?: https://hub.docker.com/r/bbricardo/netbox-sync/tags