dainok / netdoc

Automatic Network Documentation plugin for NetBox
GNU General Public License v3.0
89 stars 13 forks source link

ingesting error #26

Closed mamingzhi945 closed 1 year ago

mamingzhi945 commented 1 year ago

Ingesting log 3819 with command show cdp neighbors detail on device 10.254.2.161 via netmiko_cisco_nxos

An exception occurred: IntegrityError: Multiple neighbors on CNBJBCDR-BEIYAN-WUHAN-N93180-1:Ethernet1/8 (e1/8) or INAGGSW-N93180-CNWUH01-1326-01:Ethernet1/5 (e1/5)

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.10/site-packages/netdoc/schemas/cable.py", line 87, in link
    cable_o = Cable.objects.filter(terminations__interface=left_interface_o).get(
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 650, in get
    raise self.model.DoesNotExist(
dcim.models.cables.Cable.DoesNotExist: Cable matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "dcim_cabletermination_unique_termination"
DETAIL:  Key (termination_type_id, termination_id)=(32, 43285) already exists.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.10/site-packages/netdoc/schemas/cable.py", line 96, in link
    CableTermination.objects.create(
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 671, in create
    obj.save(force_insert=True, using=self.db)
  File "/opt/netbox/netbox/dcim/models/cables.py", line 318, in save
    super().save(*args, **kwargs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/base.py", line 812, in save
    self.save_base(
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/base.py", line 863, in save_base
    updated = self._save_table(
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1006, in _save_table
    results = self._do_insert(
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1047, in _do_insert
    return manager._insert(
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 1791, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1660, in execute_sql
    cursor.execute(sql, params)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "dcim_cabletermination_unique_termination"
DETAIL:  Key (termination_type_id, termination_id)=(32, 43285) already exists.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/netbox/netbox/extras/scripts.py", line 476, in _run_script
    script.output = script.run(data=data, commit=commit)
  File "/opt/netbox/netbox/scripts/NetDoc.py", line 290, in run
    log_ingest(log)
  File "/opt/netbox/venv/lib/python3.10/site-packages/netdoc/utils.py", line 381, in log_ingest
    module.ingest(log)
  File "/opt/netbox/venv/lib/python3.10/site-packages/netdoc/ingestors/netmiko_cisco_nxos_show_cdp_neighbors_detail.py", line 87, in ingest
    cable.link(
  File "/opt/netbox/venv/lib/python3.10/site-packages/netdoc/schemas/cable.py", line 111, in link
    raise IntegrityError(
django.db.utils.IntegrityError: Multiple neighbors on CNBJBCDR-BEIYAN-WUHAN-N93180-1:Ethernet1/8 (e1/8) or INAGGSW-N93180-CNWUH01-1326-01:Ethernet1/5 (e1/5)
dainok commented 1 year ago

Check https://github.com/dainok/netdoc/wiki/FAQ#multiple-neighbors