You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
VLAN creation fails if device name associated contains dots. The issue seems to be that the code does not correctly slugify the device name, rather does not slugify at all.
This results in an error when the POST is made to create the VLAN (see below)
{'name': 'device=cht.mpls.rtr01', 'slug': 'device__cht.mpls.rtr01'}
{'name': 'device=cht.mpls.rtr01', 'slug': 'device__cht.mpls.rtr01'}
Traceback (most recent call last):
File "/opt/nautobot/bin/network-importer", line 8, in <module>
sys.exit(main())
File "/opt/nautobot/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/opt/nautobot/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/opt/nautobot/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/opt/nautobot/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/opt/nautobot/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/opt/nautobot/lib/python3.8/site-packages/network_importer/cli.py", line 108, in apply
ni.sync()
File "/opt/nautobot/lib/python3.8/site-packages/network_importer/main.py", line 142, in sync
self.sot.sync_from(self.network, diff_class=NetworkImporterDiff)
File "/opt/nautobot/lib/python3.8/site-packages/diffsync/__init__.py", line 525, in sync_from
result = syncer.perform_sync()
File "/opt/nautobot/lib/python3.8/site-packages/diffsync/helpers.py", line 326, in perform_sync
changed |= self.sync_diff_element(element)
File "/opt/nautobot/lib/python3.8/site-packages/diffsync/helpers.py", line 390, in sync_diff_element
changed |= self.sync_diff_element(child, parent_model=dst_model)
File "/opt/nautobot/lib/python3.8/site-packages/diffsync/helpers.py", line 366, in sync_diff_element
changed, modified_model = self.sync_model(src_model=src_model, dst_model=dst_model, ids=ids, attrs=attrs)
File "/opt/nautobot/lib/python3.8/site-packages/diffsync/helpers.py", line 419, in sync_model
dst_model = dst_model.update(attrs=attrs)
File "/opt/nautobot/lib/python3.8/site-packages/network_importer/adapters/nautobot_api/models.py", line 612, in update
nb_params = self.translate_attrs_for_nautobot(attrs)
File "/opt/nautobot/lib/python3.8/site-packages/network_importer/adapters/nautobot_api/models.py", line 522, in translate_attrs_for_nautobot
tag_id = device.get_device_tag_id()
File "/opt/nautobot/lib/python3.8/site-packages/network_importer/adapters/nautobot_api/models.py", line 53, in get_device_tag_id
tag = self.diffsync.nautobot.extras.tags.create(name=f"device={self.name}", slug=f"device__{self.name}")
File "/opt/nautobot/lib/python3.8/site-packages/pynautobot/core/endpoint.py", line 279, in create
req = Request(base=self.url, token=self.token, http_session=self.api.http_session,).post(
File "/opt/nautobot/lib/python3.8/site-packages/pynautobot/core/query.py", line 325, in post
return self._make_call(verb="post", data=data)
File "/opt/nautobot/lib/python3.8/site-packages/pynautobot/core/query.py", line 227, in _make_call
raise RequestError(req)
pynautobot.core.query.RequestError: The request failed with code 400 Bad Request: {'slug': ['Enter a valid "slug" consisting of letters, numbers, underscores or hyphens.']}
I worked around the issue myself by installing python-slugify and doing the following modifications to the code of network_importer/adapters/nautobot_api/models.py
from slugify import slugify
tag = self.diffsync.nautobot.extras.tags.create(name=f"device={self.name}", slug=f"device__{self.name}") -> tag = self.diffsync.nautobot.extras.tags.create(name=f"device={self.name}", slug=f"device__{slugify(self.name)}")
Steps to Reproduce
import a device containing dots in hostname
try to import vlans
What did you expect to happen?
Expected Behavior
Correct VLAN creation in Nautobot's IPAM module
What happened instead?
Observed Behavior
Error during network-importer apply
The text was updated successfully, but these errors were encountered:
Environment
VLAN creation fails if device name associated contains dots. The issue seems to be that the code does not correctly slugify the device name, rather does not slugify at all.
This results in an error when the POST is made to create the VLAN (see below)
I worked around the issue myself by installing python-slugify and doing the following modifications to the code of network_importer/adapters/nautobot_api/models.py
Steps to Reproduce
What did you expect to happen?
Expected Behavior
Correct VLAN creation in Nautobot's IPAM module
What happened instead?
Observed Behavior
Error during network-importer apply
The text was updated successfully, but these errors were encountered: