bb-Ricardo / netbox-sync

Sync objects from VMware or redfish sources to NetBox
MIT License
282 stars 65 forks source link

Script not working with Python3.12 #391

Closed bone6000 closed 4 months ago

bone6000 commented 4 months ago

I've compiled the script successfully with python3.12.3 but when trying to run it I get this error messages:

[user01@test-machine]$ sudo /opt/netbox-sync/.venv/bin/python3 /opt/netbox-sync/netbox-sync.py Traceback (most recent call last): File "/opt/netbox-sync/netbox-sync.py", line 24, in from module.sources import instantiate_sources File "/opt/netbox-sync/module/sources/init.py", line 11, in from module.sources.vmware.connection import VMWareHandler File "/opt/netbox-sync/module/sources/vmware/connection.py", line 23, in from pyVim import connect File "/opt/netbox-sync/.venv/lib/python3.12/site-packages/pyVim/connect.py", line 37, in from pyVmomi import vim, vmodl, SoapStubAdapter, SessionOrientedStub File "/opt/netbox-sync/.venv/lib/python3.12/site-packages/pyVmomi/init.py", line 39, in from pyVmomi.SoapAdapter import SoapStubAdapter, StubAdapterBase, SoapCmdStubAdapter, \ File "/opt/netbox-sync/.venv/lib/python3.12/site-packages/pyVmomi/SoapAdapter.py", line 1003, in _SocketWrapper = ssl.wrap_socket ^^^^^^^^^^^^^^^ AttributeError: module 'ssl' has no attribute 'wrap_socket'

The python3 version have the ssl module correct, but I think there is a change in the 3.12 version...

bone6000 commented 4 months ago

I've executed the script with the previous python3.8 version, and I get this error:

/opt/netbox-sync/.venv/bin/python3.8 /opt/netbox-sync/netbox-sync.py

Traceback (most recent call last): File "/opt/netbox-sync/netbox-sync.py", line 146, in main() File "/opt/netbox-sync/netbox-sync.py", line 98, in main nb_handler.query_current_data(source.dependent_netbox_objects) File "/opt/netbox-sync/module/netbox/connection.py", line 521, in query_current_data self.inventory.add_object(nb_object_class, data=object_data, read_from_netbox=True) File "/opt/netbox-sync/module/netbox/inventory.py", line 176, in add_object new_object = object_type(data, read_from_netbox=read_from_netbox, inventory=self, source=source) File "/opt/netbox-sync/module/netbox/object_classes.py", line 1178, in init super().init(*args, **kwargs) File "/opt/netbox-sync/module/netbox/object_classes.py", line 296, in init self.update(data=data, read_from_netbox=read_from_netbox, source=source) File "/opt/netbox-sync/module/netbox/object_classes.py", line 1199, in update for object_type in data.get("object_types"): TypeError: 'NoneType' object is not iterable

That seems solved by following this: https://github.com/bb-Ricardo/netbox-sync/issues/390

But would like to run it with python3.12 instead...

bb-Ricardo commented 4 months ago

Hi, Python 3.12 is not support. Only Python 3.11 as the underlying vmware SDK does not work well with Python 3.12

bone6000 commented 4 months ago

OK Ricardo, thanks for your quick answer