Closed ecrosswhite closed 3 weeks ago
@ecrosswhite can you confirm if this is still happening in 3.0.0?
@jdrew82 Yes, it looks to still occur with 3.0.0.
{
"exc_message": [
"module 'distutils' has no attribute 'util'"
],
"exc_module": "builtins",
"exc_type": "AttributeError"
}
With a traceback of;
Traceback (most recent call last):
File "/opt/nautobot/lib/python3.10/site-packages/celery/app/trace.py", line 477, in trace_task
R = retval = fun(*args, **kwargs)
File "/opt/nautobot/lib/python3.10/site-packages/celery/app/trace.py", line 760, in __protected_call__
return self.run(*args, **kwargs)
File "/opt/nautobot/lib/python3.10/site-packages/nautobot/extras/jobs.py", line 1136, in run_job
result = job(*args, **kwargs)
File "/opt/nautobot/lib/python3.10/site-packages/nautobot/extras/jobs.py", line 149, in __call__
return self.run(*args, **deserialized_kwargs)
File "/opt/nautobot/lib/python3.10/site-packages/nautobot_ssot/integrations/aristacv/jobs.py", line 140, in run
super().run(dryrun=self.dryrun, memory_profiling=self.memory_profiling, *args, **kwargs)
File "/opt/nautobot/lib/python3.10/site-packages/nautobot_ssot/jobs/base.py", line 317, in run
self.sync_data(memory_profiling)
File "/opt/nautobot/lib/python3.10/site-packages/nautobot_ssot/jobs/base.py", line 136, in sync_data
self.load_source_adapter()
File "/opt/nautobot/lib/python3.10/site-packages/nautobot_ssot/integrations/aristacv/jobs.py", line 119, in load_source_adapter
self.source_adapter.load()
File "/opt/nautobot/lib/python3.10/site-packages/nautobot_ssot/integrations/aristacv/diffsync/adapters/cloudvision.py", line 269, in load
self.load_devices()
File "/opt/nautobot/lib/python3.10/site-packages/nautobot_ssot/integrations/aristacv/diffsync/adapters/cloudvision.py", line 95, in load_devices
self.load_device_tags(device=new_device)
File "/opt/nautobot/lib/python3.10/site-packages/nautobot_ssot/integrations/aristacv/diffsync/adapters/cloudvision.py", line 252, in load_device_tags
tag["value"] = bool(distutils.util.strtobool(tag["value"]))
AttributeError: module 'distutils' has no attribute 'util'
@ecrosswhite So this appears to be something with your version of distutils. If you look at the documentation, you can see here that distutils.util.strtobool
is valid.
@ecrosswhite I've also confirmed this in the REPL:
# Django version 3.2.25
# Nautobot version 2.2.8
# Nautobot Device Lifecycle Management version 2.2.0
# Single Source of Truth version 3.1.1a0
Python 3.10.14 (main, Jul 2 2024, 22:12:36) [GCC 12.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.12.3 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from distutils.util import strtobool
Environment
Expected Behavior
Running the Arista CloudVision --> Nautobot job should be able to complete
Observed Behavior
The job errors out due to distutils module error.
Steps to Reproduce
Possible fix
As distutils is depricated, PEP 632 I was able to get around the issue by patching my file
nautobot_ssot/integrations/aristacv/diffsync/adapters/cloudvision.py
I added python package str2bool, imported to the file
from str2bool import str2bool
and changed instances oftag["value"] = bool(distutils.util.strtobool(tag["value"]))
totag["value"] = str2bool(tag["value"])
I see the same logic exists in
nautobot_ssot/integrations/aristacv/diffsync/models/nautobot.py
but don't know what impact this file has.