Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error creating Vlans when not using Device tags #280

Open
matt852 opened this issue Sep 15, 2022 · 0 comments
Open

Error creating Vlans when not using Device tags #280

matt852 opened this issue Sep 15, 2022 · 0 comments

Comments

@matt852
Copy link
Contributor

matt852 commented Sep 15, 2022

Environment

  • Python version: 3.6.8
  • Network Importer version: 3.0.5
  • Nautobot version: 1.3.7 and 1.4.2

Steps to Reproduce

  1. In network_importer.toml, set import_vlan = "cli"
  2. Set up the network devices in Nautobot, without using any tags
  3. Run Network Importer on Cisco IOS devices

Expected Behavior

The vlans and other device data should import correctly.

Observed Behavior

I found an issue that is causing the vlans to not properly import if Network Importer is unable to retrieve device tags. I am not sure the exact nature of what is causing this, but I've narrowed it down to these two lines throwing the exception:

https://github.com/networktocode/network-importer/blob/develop/network_importer/adapters/nautobot_api/models.py#L522-L523

                tag_id = device.get_device_tag_id()
                nb_params["tags"].append(tag_id)

The issue I'm seeing is as follows (sensitive data replaced with generic names):

2022-09-06 18:37:08,247 - network-importer - WARNING - Unable to create Vlan {'vid': 4, 'site_name': 'remote-office'} in Nautobot ({"slug":["Enter a valid \"slug\" consisting of letters, numbers, underscores or hyphens."]})
2022-09-06 18:37:08,247 - diffsync.helpers - WARNING - 2022-09-06 18:37.08 [warning  ] vlan create did not return the model object. [diffsync.helpers] action=create diffs={'+': {'name': 'ADMIN_VLAN', 'associated_devices': ['switch01.acme.com']}} dst=<Nautobot> flags=<DiffSyncFlags.NONE: 0> model=vlan src=<Network> status=failure unique_id=remote-office__4
2022-09-06 18:37:08,248 - diffsync.helpers - WARNING - 2022-09-06 18:37.08 [warning  ] No object resulted from sync, will not process child objects. [diffsync.helpers] action=create diffs={'+': {'name': 'ADMIN_VLAN', 'associated_devices': ['switch01.acme.com']}} dst=<Nautobot> flags=<DiffSyncFlags.NONE: 0> model=vlan src=<Network> unique_id=remote-office__4

I propose since tags are optional, we add a simple try/except block to catch an exception, and just pass over the tags. In my testing, this successfully worked around the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant