[PR #15303] [MERGED] 14799 Fix sync of scripts from data source #14569

Closed
opened 2025-12-29 23:25:14 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/15303
Author: @arthanson
Created: 2/28/2024
Status: Merged
Merged: 3/26/2024
Merged by: @jeremystretch

Base: featureHead: 14799-script-data-source


📝 Commits (4)

  • 04488ff 14799 fix script creation from data-source
  • df41def 14799 dont cache module_scripts
  • e4a50e2 14799 fix sync_classes call
  • daf69d4 Merge branch 'feature' into 14799-script-data-source

📊 Changes

2 files changed (+12 additions, -5 deletions)

View changed files

📝 netbox/core/models/files.py (+3 -0)
📝 netbox/extras/models/scripts.py (+9 -5)

📄 Description

Fixes: #15440

There were a couple issues with loading scripts from a data source from the DB representation of Scripts which also fix this issue:

  1. setting up a local data-source and creating a Script module from it errored as the script objects were getting instantiated within the sync_data. This was a problem as it was called before the save on ScriptModule so there was no PK for the M2M to save.
  2. module_scripts was also getting called before the M2M was setup so there is now a check for this to return an empty dict.
  3. module_scripts was cached which is done only on creation so a sync of the data source would not change the internal classes. module_scripts now just needs to be called when the ScriptModule potentially changes so the cache can be removed.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/15303 **Author:** [@arthanson](https://github.com/arthanson) **Created:** 2/28/2024 **Status:** ✅ Merged **Merged:** 3/26/2024 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `14799-script-data-source` --- ### 📝 Commits (4) - [`04488ff`](https://github.com/netbox-community/netbox/commit/04488ff7df235d27a840028a8c76e7adeef6caad) 14799 fix script creation from data-source - [`df41def`](https://github.com/netbox-community/netbox/commit/df41defd8ec4086a64511f069308be4ebb0feb32) 14799 dont cache module_scripts - [`e4a50e2`](https://github.com/netbox-community/netbox/commit/e4a50e2e5ffe02a9e33d7427e556cb5fdebe64c3) 14799 fix sync_classes call - [`daf69d4`](https://github.com/netbox-community/netbox/commit/daf69d4ee8050f7a715dca58e92650fad9cd3e01) Merge branch 'feature' into 14799-script-data-source ### 📊 Changes **2 files changed** (+12 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `netbox/core/models/files.py` (+3 -0) 📝 `netbox/extras/models/scripts.py` (+9 -5) </details> ### 📄 Description ### Fixes: #15440 There were a couple issues with loading scripts from a data source from the DB representation of Scripts which also fix this issue: 1. setting up a local data-source and creating a Script module from it errored as the script objects were getting instantiated within the sync_data. This was a problem as it was called before the save on ScriptModule so there was no PK for the M2M to save. 2. module_scripts was also getting called before the M2M was setup so there is now a check for this to return an empty dict. 3. module_scripts was cached which is done only on creation so a sync of the data source would not change the internal classes. module_scripts now just needs to be called when the ScriptModule potentially changes so the cache can be removed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 23:25:14 +01:00
adam closed this issue 2025-12-29 23:25:15 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#14569