-
How do I configure deletion protection for devices? Some time ago, I asked an FR #14996 to set up deletion protection for devices. I then learnt from jeremystretch that this should be possible with the following rule. https://docs.netbox.dev/en/stable/configuration/data-validation/#protection_rules As it happens, I didn't get round to setting it up and wanted to do it now. (Of course I deleted something by mistake again). So I added this Protection Roles entry. If I now create a new device, I can delete it again immediately, although the status is "Active". At first I thought that my config was not working, but if I change something else in the config file and restart Netbox, then a change happens. So how do I configure PROTECTION_RULES so that devices are not deleted when the status is Active? Thanks for your info |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 3 replies
-
What exactly did you put there? |
Beta Was this translation helpful? Give feedback.
-
This:
In the hope that you can only delete the devices if they are in the following status: decommissioning |
Beta Was this translation helpful? Give feedback.
-
I am a clueless fool when it comes to validation. :D I was also puzzled by the line in the example, which is why I left it out. I just copied it one-to-one from this link and had no success with it. From the description, it sounds like that's what I need. Only the code that is given is a bit confusing. https://docs.netbox.dev/en/stable/configuration/data-validation/#protection_rules |
Beta Was this translation helpful? Give feedback.
-
I am currently using 3.7.1 snd yes, for me it is in the configuration file: /opt/netbox/netbox/netbox/configuration.py At least I knew that I had read validation somewhere on the website, I just couldn't remember where. I tried it once via the web frontend, but apparently I also entered it incorrectly there. Can you give me an example of how to spell it correctly? Because that doesn't work. |
Beta Was this translation helpful? Give feedback.
-
I have now updated to 4.0.0. And in the Admin --> Configuration History before and after area I created a configuration with a maximum page size of 500. And I can still select 1000 in each list. I think the configurations are never used by me. |
Beta Was this translation helpful? Give feedback.
-
OK the config is partially loaded. |
Beta Was this translation helpful? Give feedback.
-
These protection rules are pretty great! Thanks for the info folks! |
Beta Was this translation helpful? Give feedback.
-
Summary of the solution"dcim.site, not dcim.device" oh man, I could have thought of that myself :D So here's a summary for everyone (Tested in version 4.0.0): Admin --> Configuration Config Revisions (v3.x.x) --> Add (or Edit last Config) Protection rules
If you navigate to a device, rack or site, you will find the path in the top right-hand corner. Create a device and delete it: I'll see if I can / may revise the article https://docs.netbox.dev/en/stable/configuration/data-validation/#protection_rules a little. |
Beta Was this translation helpful? Give feedback.
From your original post:
Your protection rule is configured to protect
dcim.site
, notdcim.device
. Try adding and deleting a site instead.