nautobot / nautobot-app-netbox-importer

Nautobot plugin to simplify data migration from NetBox
https://docs.nautobot.com/projects/netbox-importer/en/latest/
Other
20 stars 11 forks source link

Import fails with 'ValueError: Ambiguous content type back mapping dcim.location' #156

Open amuckart opened 5 months ago

amuckart commented 5 months ago

Environment

Expected Behavior

Import runs

Observed Behavior

Import fails with a ValueError: Ambiguous content type back mapping dcim.location error:

nautobot@nautobot-test:~$ nautobot-server import_netbox --print-summary --dry-run --update-paths --bypass-data-validation --sitegroup-parent-always-region /tmp/netbox_data.json
Operations to perform:
  Apply all migrations: admin, auth, circuits, contenttypes, database, dcim, django_celery_beat, django_celery_results, extras, ipam, sessions, silk, social_django, taggit, tenancy, users, virtualization
Running migrations:
  No migrations to apply.
07:18:17.217 INFO    nautobot.extras.utils :
  Refreshed Job "System Jobs: Export Object List" from <ExportObjectList>
07:18:17.226 INFO    nautobot.extras.utils :
  Refreshed Job "System Jobs: Git Repository: Sync" from <GitRepositorySync>
07:18:17.234 INFO    nautobot.extras.utils :
  Refreshed Job "System Jobs: Git Repository: Dry-Run" from <GitRepositoryDryRun>
07:18:17.243 INFO    nautobot.extras.utils :
  Refreshed Job "System Jobs: Import Objects" from <ImportObjects>
Failed to create importer for extras.configcontext->locations
Traceback (most recent call last):
  File "/opt/nautobot/bin/nautobot-server", line 8, in <module>
    sys.exit(main())
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot/core/cli/__init__.py", line 286, in main
    execute_from_command_line([sys.argv[0], *unparsed_args])
  File "/opt/nautobot/lib/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/opt/nautobot/lib/python3.10/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/nautobot/lib/python3.10/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/nautobot/lib/python3.10/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot_netbox_importer/management/commands/import_netbox.py", line 89, in handle
    adapter.import_to_nautobot()
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot_netbox_importer/diffsync/adapters/netbox.py", line 97, in import_to_nautobot
    self._atomic_import()
  File "/usr/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot_netbox_importer/diffsync/adapters/netbox.py", line 114, in _atomic_import
    self.load()
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot_netbox_importer/diffsync/adapters/netbox.py", line 86, in load
    self.import_data()
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot_netbox_importer/generator/source.py", line 329, in import_data
    wrapper.create_importers()
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot_netbox_importer/generator/source.py", line 556, in create_importers
    field.create_importer()
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot_netbox_importer/generator/source.py", line 869, in create_importer
    self.set_importer(nautobot_name=self.definition)
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot_netbox_importer/generator/source.py", line 941, in set_importer
    self.set_m2m_importer()
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot_netbox_importer/generator/source.py", line 1071, in set_m2m_importer
    related_wrapper = self.wrapper.adapter.get_or_create_wrapper(self.nautobot.related_model)
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot_netbox_importer/generator/source.py", line 278, in get_or_create_wrapper
    raise ValueError(f"Ambiguous content type back mapping {value}")
ValueError: Ambiguous content type back mapping dcim.location

Steps to Reproduce

  1. Dump netbox data with command python3 ./manage.py dumpdata -v 3 --traceback --format=json --exclude extras.ObjectChange --exclude extras.report --exclude extras.script --exclude django_rq --output=/tmp/netbox_data.json
  2. install nautobot-netbox-importer with pip3 install nautobot-netbox-importer as user nautobot from $NAUTOBOT_HOME
  3. Run import command nautobot-server import_netbox --print-summary --dry-run --update-paths --bypass-data-validation --sitegroup-parent-always-region /tmp/netbox_data.json

I did notice that the options I have don't match the docs. There's no --field-mapping option, and --summary seems to have changed to --print-summary also --help didn't work but I put those down to documentation not having quite caught up with the updates.

Running nautobot-server import_netbox with no options gives me:

usage: nautobot-server import_netbox [-h] [--dry-run] [--update-paths] [--bypass-data-validation] [--sitegroup-parent-always-region] [--fix-powerfeed-locations] [--print-summary]
                                     [--no-unrack-zero-uheight-devices] [--save-json-summary-path SAVE_JSON_SUMMARY_PATH] [--save-text-summary-path SAVE_TEXT_SUMMARY_PATH] [--version] [-v {0,1,2,3}]
                                     [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--force-color] [--skip-checks]
                                     json_file
nautobot-server import_netbox: error: the following arguments are required: json_file

Thanks.

amuckart commented 5 months ago

I note on the app page in Nautobot's Web UI it says "Data importer from NetBox 2.10.x to Nautobot."

Is this plugin intended to work with Netbox 3.7.x?

Thanks.

chadell commented 5 months ago

I note on the app page in Nautobot's Web UI it says "Data importer from NetBox 2.10.x to Nautobot."

Is this plugin intended to work with Netbox 3.7.x?

Thanks.

yes. I guess the Nautobot0s Web UI is still referring to the previous version. Could you share the exact reference to fix it?

harsh-kotak commented 5 months ago

I had to add --exclude extras.configcontext flag in netbox dumpdata command to workaround this.