File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
netbox/core/management/commands Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 11from django .core .cache import cache
22from django .core .management .base import BaseCommand
33
4+ from extras .models import ConfigRevision
5+
46
57class Command (BaseCommand ):
68 """Command to clear the entire cache."""
79 help = 'Clears the cache.'
810
911 def handle (self , * args , ** kwargs ):
12+ # Fetch the current config revision from the cache
13+ config_version = cache .get ('config_version' )
14+ # Clear the cache
1015 cache .clear ()
1116 self .stdout .write ('Cache has been cleared.' , ending = "\n " )
17+ if config_version :
18+ # Activate the current config revision
19+ ConfigRevision .objects .get (id = config_version ).activate ()
20+ self .stdout .write (f'Config revision ({ config_version } ) has been restored.' , ending = "\n " )
You can’t perform that action at this time.
0 commit comments