DCIM/Devices: Modules not added #17861
-
Deployment TypeSelf-hosted Triage priorityI'm a NetBox Labs customer NetBox Versionv4.1.4 Python Version3.12 Steps to Reproduce
Within the second save, modules (power outlets, console ports) were not added in the gui. Important: My code: def run (self, data, commit):
Expected BehaviorMake Topic Console Ports, Power Ports visible in Device View Observed BehaviorThese Objects were generated, but arent visible... |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Aside: duplicate of #17842.
That's useful information, because the modules are created by the first save (when the device itself is created). Therefore, what's likely happening is that the second save is resetting the cached module counts to zero. Try reloading the device with refresh_from_db() before setting the primary_ip4 and saving it back.
Or use update() to set only the primary_ip4:
Aside: why use |
Beta Was this translation helpful? Give feedback.
-
I can reproduce your problem in nbshell:
I go to
Notice it's a bit weird to have both "interfaces_count" (which is correct) and "interface_count" (which is wrong). I think
Then if I run in a different window:
Back in the first window:
Now the counts are correct. And the GUI displays the missing tabs. The general solution (to avoid running calculate_cached_counts) is to refresh the device from the db after creating it:
This new device has the correct tabs visible. |
Beta Was this translation helpful? Give feedback.
I can reproduce your problem in nbshell:
I go to
/dcim/devices/107/
in the UI, I see the 'interfaces' tab but not thepower ports
orconsole ports
tab.