clearer names for actions, and infer actions better
[monitor.git] / tests / testtemplate.py
1 #!/usr/bin/python
2
3 from monitor.database import FindbadNodeRecord, FindbadPCURecord
4 from template import *
5 from nodequery import *
6 from monitor import util
7 import sys
8
9
10 dc7800list = util.file.getListFromFile("dc7800.txt")
11
12 # get node info
13 # if membership satisfied
14 #     get pcu info
15 #     verify pcu constraint
16 #     verify node constraint
17
18 fbquery = FindbadNodeRecord.get_all_latest()
19 for noderec in fbquery:
20         fbinfo = noderec.to_dict()
21         member = verifyType(dc7800['membership'], fbinfo) 
22         if not member: continue
23                 
24         if pcu_in(fbinfo):
25                 fbpcuinfo  = FindbadPCURecord.get_latest_by(plc_pcuid=fbinfo['plc_node_stats']['pcu_ids'][0]).to_dict()
26         else:
27                 fbpcuinfo = None
28         fbinfo['pcuinfo'] = fbpcuinfo
29
30         pcuok = verifyType(dc7800['pcu']['constraint'], fbpcuinfo) 
31         nodeok = verifyType(dc7800['node']['constraint'], fbinfo)
32         print "pcuok : ", pcuok, " nodeok: ", nodeok , " ", hostname
33         continue
34         sys.exit(1)
35
36         if not pcuok and not nodeok:
37                 # donation_down_one
38                 pass
39         elif not pcuok and nodeok:
40                 # donation_nopcu_one
41                 pass
42         elif pcuok and not nodeok:
43                 # reboot
44                 pass
45         elif pcuok and nodeok:
46                 # noop 
47                 pass
48
49         if pcuok:
50                 print "PCU-OK ", 
51         else:
52                 print "PCU-BAD",
53         if nodeok:
54                 print "NODE-OK ",
55         else:
56                 print "NODE-BAD",
57         print " for %-45s" % hostname
58         
59
60