clearer names for actions, and infer actions better
[monitor.git] / tests / template.py
1 #!/usr/bin/python
2
3
4 import emailTxt
5 class Type:
6         def __init__(self, value):
7                 self.value = value
8         def name(self):
9                 return self.__class__.__name__
10         
11 class Is(Type): pass
12 class Match(Type): pass
13 class ListMatch(Type): pass
14 class FilledIn(Type): pass
15 class PortOpen(Type): pass
16 class NodesUp(Type): pass
17
18 # a failed constraint leads to a message-escelation process.
19 # so, define a constraint, which defines the set of nodes it operates on, the
20 #         message to send if it fails, and maybe a thank you message when it's
21 #         satisfied (if previously failed.).
22 standardnode = {
23         'membership' : [ { 'plcnode/nodegroups' : Match('.*') } ],
24         'site'       : [ { 'nodes'    : NodesUp(2), } ],
25         'node'       : { 'constraint' : 
26                                                                 [ {     'state'    : Match('BOOT'),
27                                                                 'kernel'   : Match('2.6.22.19-vs2.3.0.34'), } ],
28                                          'failed_message'       : [ emailTxt.mailtxt.newdown ],
29                                          'resolved_message'     : [ emailTxt.mailtxt.newthankyou ],
30                                         },
31         'pcu'            : { 
32                                          'constraint' : [ {     'hostname' : FilledIn(True),
33                                                                                 'password' : FilledIn(True), },
34                                                                          {      'ip' : FilledIn(True),
35                                                                                 'password' : FilledIn(True), },
36                                                                         ],
37                                          'failed_message'       : [ emailTxt.mailtxt.pcudown ],
38                                          'resolved_message'     : [ emailTxt.mailtxt.pcuthankyou ],
39                                         },
40 }
41
42 dc7800 = {
43         # if membership constraint it true, then apply the other constraints.
44         'membership'    : [ { 'plcnode/nodegroups' : ListMatch('DC7800Deployment'), } ],
45
46         'pcu'                   : { 'constraint' : [ { 'hostname'       : FilledIn(True),
47                                                                         'ip'            : FilledIn(True),
48                                                                         'password'      : FilledIn(True),
49                                                                         'model'         : Match('AMT'),
50                                                                         'username'      : Match('admin'),
51                                                                         'portstatus': PortOpen(16992),
52                                                                         'reboot'        : Is(0),
53                                                                  },
54                                                                  {      'hostname'      : FilledIn(True),
55                                                                         'ip'            : FilledIn(True),
56                                                                         'password'      : FilledIn(True),
57                                                                         'reboot'        : Is(0),
58                                                                         #'valid'                : Is(True),
59                                                                  },],
60                                          'failed_message'       : [ emailTxt.mailtxt.donation_nopcu],
61                                          'resolved_message'     : [ emailTxt.mailtxt.pcuthankyou ],
62                                          },
63         'node'       : { 'constraint' : 
64                                                                 [ {     'state'    : Match('BOOT'),
65                                                                         'kernel'   : Match('2.6.22.19-vs2.3.0.34'), } ],
66                                          'failed_message'       : [ emailTxt.mailtxt.donation_down],
67                                          'resolved_message'     : [ emailTxt.mailtxt.newthankyou ],
68                                 },
69 }
70
71 #
72 # data source, { constraints ... value } 
73 # action on failure of constraint
74 # information about why it failed
75 # # stop action if constraint is satisfied at a later time.
76 # kind of like asynchronous constraint solving.
77 # or stored procedures.