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

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

Open
amuckart opened this issue Apr 5, 2024 · 3 comments

Comments

@amuckart
Copy link

amuckart commented Apr 5, 2024

Environment

  • Python version: 3.10.12
  • Nautobot version: 2.2.0
  • nautobot-netbox-importer version: 2.0
  • Netbox version: 3.6.5, 3.7.5

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
Copy link
Author

amuckart commented Apr 8, 2024

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
Copy link
Contributor

chadell commented Apr 8, 2024

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
Copy link

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

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

No branches or pull requests

4 participants