-
Notifications
You must be signed in to change notification settings - Fork 12
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
New import_netbox_objectchange_json command #40
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the pull request! I like the approach here a lot.
nautobot_netbox_importer/management/commands/import_netbox_objectchange_json.py
Outdated
Show resolved
Hide resolved
nautobot_netbox_importer/management/commands/import_netbox_objectchange_json.py
Outdated
Show resolved
Hide resolved
nautobot_netbox_importer/management/commands/import_netbox_objectchange_json.py
Outdated
Show resolved
Hide resolved
nautobot_netbox_importer/management/commands/import_netbox_objectchange_json.py
Outdated
Show resolved
Hide resolved
nautobot_netbox_importer/management/commands/import_netbox_objectchange_json.py
Outdated
Show resolved
Hide resolved
nautobot_netbox_importer/management/commands/import_netbox_objectchange_json.py
Outdated
Show resolved
Hide resolved
nautobot_netbox_importer/management/commands/import_netbox_objectchange_json.py
Outdated
Show resolved
Hide resolved
nautobot_netbox_importer/management/commands/import_netbox_objectchange_json.py
Show resolved
Hide resolved
…ectchange_json.py Co-authored-by: Glenn Matthews <[email protected]>
refactor code for readability Co-authored-by: Glenn Matthews <[email protected]>
nautobot_netbox_importer/management/commands/import_netbox_objectchange_json.py
Outdated
Show resolved
Hide resolved
nautobot_netbox_importer/management/commands/import_netbox_objectchange_json.py
Outdated
Show resolved
Hide resolved
self.logger, _ = initialize_logger(options) | ||
|
||
self.logger.info("Loading NetBox JSON data into memory...", filename={options["json_file"].name}) | ||
no_objectchange_data = json.load(options["json_file"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
netbox-docker
, by default, prepends a few lines of text log output to any manage.py
command, including manage.py dumpdata
, which causes the resulting file to not be valid JSON until/unless you manually delete those lines with a text editor. I mention this just to suggest that you add a try...except ValueError
around each of the json.load
calls so that if the file isn't valid JSON, you can handle it gracefully with an appropriate error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the hint
btw, I believe that the same applies to https://github.com/nautobot/nautobot-plugin-netbox-importer/blob/develop/nautobot_netbox_importer/management/commands/import_netbox_json.py#L132
nautobot_netbox_importer/management/commands/import_netbox_objectchange_json.py
Outdated
Show resolved
Hide resolved
nautobot_netbox_importer/management/commands/import_netbox_objectchange_json.py
Outdated
Show resolved
Hide resolved
nautobot_netbox_importer/management/commands/import_netbox_objectchange_json.py
Outdated
Show resolved
Hide resolved
What's the story behind the changes to |
terror story... I will rollback it |
Co-authored-by: Glenn Matthews <[email protected]>
…gin-netbox-importer into import-ObjectChange
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates!
nautobot_netbox_importer/management/commands/import_netbox_objectchange_json.py
Outdated
Show resolved
Hide resolved
nautobot_netbox_importer/management/commands/import_netbox_objectchange_json.py
Outdated
Show resolved
Hide resolved
nautobot_netbox_importer/management/commands/import_netbox_objectchange_json.py
Show resolved
Hide resolved
Co-authored-by: Glenn Matthews <[email protected]>
Addresses issue #39
In this PR:
nautobot_netbox_importer/command_utils.py
to be reused by both commands (it was not possible to move toutils.py
due circular dependency fromadapters
ObjectChanges
from Netbox to Nautobot, using the properContentType
references, the user and the creation date.dryrun
mode to run the command without changing the databaseTODO
EXAMPLE