File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ from django .core .management .base import BaseCommand
2
+ from tom_targets .models import Target
3
+
4
+ class Command (BaseCommand ):
5
+ """
6
+ Command to unalive events with target names provided in a list as a command line argument
7
+ """
8
+
9
+ help = 'Command to unalive events with target names provided in a list as a command line argument'
10
+
11
+ def add_arguments (self , parser ):
12
+
13
+ parser .add_argument ('target_list' , help = 'List of events to unalive' )
14
+
15
+
16
+ def handle (self , * args , ** options ):
17
+
18
+ targets_to_unalive = options ['target_list' ].split (',' )
19
+
20
+ for target_name in targets_to_unalive :
21
+ t , created = Target .objects .get_or_create (name = target_name )
22
+ print ('Target ' + str (t .pk ) + ' ' + t .name + ' has status=' + repr (t .alive ))
23
+ t .alive = False
24
+ t .save ()
25
+ print ('Target ' + str (t .pk ) + ' ' + t .name + ' now has status=' + repr (t .alive ))
You can’t perform that action at this time.
0 commit comments