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

SSOT - Catalyst Center (DNA Center) sync improvement #708

Open
PiotrOrman opened this issue Feb 24, 2025 · 11 comments · May be fixed by #716
Open

SSOT - Catalyst Center (DNA Center) sync improvement #708

PiotrOrman opened this issue Feb 24, 2025 · 11 comments · May be fixed by #716
Labels
integration: dna center Issues/PRs for Cisco DNA Center integration. type: bug Issues/PRs addressing a bug.

Comments

@PiotrOrman
Copy link

Environment

  • Nautobot version: 2.4.2
  • nautobot-ssot version: 3.5.0

Proposed Functionality

Ability to correctly sync devices under the same building name in DNAC.

Use Case

Catalyst Center (Dna Center) Allow by design use the same building name located in different Areas. We can have Area name which correspond to for example city name . Area can have two buildings called Plant and Office. This scenario can be multiple by Areas number. There is also Scenario where Buildings can have multiple floors named exactly the same in multiple building (Like Floor 1 or Floor 2)
SSOT should check Area name to which builiding belongs and assign network devices to correct location in Nautobot. Currently Nautobot is checking only Area \ Building \ Floor name independently and it is assigning all devices to first location name which match the one from DNAC.

@jdrew82 jdrew82 added type: enhancement New feature or request integration: dna center Issues/PRs for Cisco DNA Center integration. labels Feb 25, 2025
@jdrew82
Copy link
Contributor

jdrew82 commented Feb 25, 2025

Just to be clear, currently the uniqueness for Areas are the Area name and the associated parent Area if there is one. For Buildings it's the Building name and Area so as long as the Area name is different the Building name can be the same. For Floors we automatically add the Building name to ensure uniqueness while allowing for repeat names like you described.

@PiotrOrman
Copy link
Author

Hello

This is exactlyh my scenarion. Differetn Area name but the same building name.

Image

And all devices from multpile PLant-Business Buildings in DNAC assigned just to one location in Nautobot

Image

@jdrew82
Copy link
Contributor

jdrew82 commented Feb 27, 2025

@PiotrOrman I see the problem now. That should be an easy enough fix.

@jdrew82 jdrew82 added type: bug Issues/PRs addressing a bug. and removed type: enhancement New feature or request labels Feb 27, 2025
@PiotrOrman
Copy link
Author

OK i checked your patch, and look like Bulidng name issue is solved now, however the same scenario may happen on floor name. So if there is the same floor name all de devices are assinged to one floor locationin nautbot.

PS. not sure how you created patch branch but it still has issue with location. DNA Center Location Structure Incorrect #687

@jdrew82
Copy link
Contributor

jdrew82 commented Feb 28, 2025

@PiotrOrman thanks for confirming that the building issue is fixed and confirming the floors were an issue. I had a feeling on that. I'll get a fix for the floors. Can you clarify your last comment? Are you saying that the location structure still isn't matching what it is in DNAC? It could be ordering of Areas being imported if you have more levels than my instance has.

@PiotrOrman
Copy link
Author

I'm not syncing Global Area.

It is structure in NautoBot

Image

However this is from DNAC:

Image

  • Plant name building is skipped as there is no devices (Good)
  • Floor under Wireless Controller Building is renamed to Wireless Controlller-Floor (Bad)
  • My Dnac strucure is build Area\Area\Building\Floor however in Nautobot dependency between Areas are removed. BR-PortoReal should be child of Americas

@jdrew82
Copy link
Contributor

jdrew82 commented Feb 28, 2025

Also, do you get any logs about being unable to find an Area?

@PiotrOrman
Copy link
Author

So there is a warning like this

Image

this is when checking diffs (nothing about partent location)

Image

If you need some specific logs let me know where i can find it

@PiotrOrman
Copy link
Author

PiotrOrman commented Feb 28, 2025

If i run the same sync job more than one time. Here is the error related to locations

Traceback (most recent call last):
  File "/opt/nautobot/lib/python3.12/site-packages/celery/app/trace.py", line 477, in trace_task
    R = retval = fun(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^
  File "/opt/nautobot/lib/python3.12/site-packages/celery/app/trace.py", line 760, in __protected_call__
    return self.run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/nautobot/lib/python3.12/site-packages/nautobot/extras/jobs.py", line 1234, in run_job
    result = job(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^
  File "/opt/nautobot/lib/python3.12/site-packages/nautobot/extras/jobs.py", line 160, in __call__
    return self.run(*args, **deserialized_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/nautobot/lib/python3.12/site-packages/nautobot_ssot/integrations/dna_center/jobs.py", line 226, in run
    super().run(dryrun=self.dryrun, memory_profiling=self.memory_profiling, *args, **kwargs)
  File "/opt/nautobot/lib/python3.12/site-packages/nautobot_ssot/jobs/base.py", line 354, in run
    self.sync_data(memory_profiling)
  File "/opt/nautobot/lib/python3.12/site-packages/nautobot_ssot/jobs/base.py", line 196, in sync_data
    self.execute_sync()
  File "/opt/nautobot/lib/python3.12/site-packages/nautobot_ssot/integrations/dna_center/jobs.py", line 189, in execute_sync
    self.source_adapter.sync_to(
  File "/opt/nautobot/lib/python3.12/site-packages/diffsync/__init__.py", line 626, in sync_to
    return target.sync_from(self, diff_class=diff_class, flags=flags, callback=callback, diff=diff)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/nautobot/lib/python3.12/site-packages/diffsync/__init__.py", line 598, in sync_from
    result = syncer.perform_sync()
             ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/nautobot/lib/python3.12/site-packages/diffsync/helpers.py", line 329, in perform_sync
    changed |= self.sync_diff_element(element)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/nautobot/lib/python3.12/site-packages/diffsync/helpers.py", line 379, 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.12/site-packages/diffsync/helpers.py", line 428, in sync_model
    dst_model = self.model_class.create(adapter=self.dst_diffsync, ids=ids, attrs=attrs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/nautobot/lib/python3.12/site-packages/nautobot_ssot/integrations/dna_center/diffsync/models/nautobot.py", line 72, in create
    new_area.validated_save()
  File "/opt/nautobot/lib/python3.12/site-packages/nautobot/core/models/__init__.py", line 132, in validated_save
    self.full_clean()
  File "/opt/nautobot/lib/python3.12/site-packages/django/db/models/base.py", line 1502, in full_clean
    raise ValidationError(errors)
django.core.exceptions.ValidationError: {'name': ['A root-level location with this name already exists.']}

@jdrew82
Copy link
Contributor

jdrew82 commented Feb 28, 2025

@PiotrOrman In your Sync Details, does it show Americas__None in areas? It should as that's a top level Area and that should automatically be created first in my latest PR update. Can you confirm you have the latest fixes from #716?

@jdrew82
Copy link
Contributor

jdrew82 commented Feb 28, 2025

@PiotrOrman I just pushed a fix for the floor issue. That should also include the fix for the areas being imported in the wrong order. The Americas area should absolutely be created first so if it's not that feels like something is up. Also, I'd strongly advise that you get rid of the bad data that you currently have for the Locations and Devices so it's not compounding issues here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration: dna center Issues/PRs for Cisco DNA Center integration. type: bug Issues/PRs addressing a bug.
Projects
None yet
2 participants