+def check_node_and_pcu_status_for(loginbase):
+ """
+ this function checks whether all the nodes and associated pcus for a
+ given site are considered 'good'.
+
+ If so, the function returns True.
+ Otherwise, the function returns False.
+ """
+
+ results = []
+ for node in plccache.plcdb_lb2hn[loginbase]:
+
+ noderec = FindbadNodeRecord.findby_or_create(hostname=node['hostname'])
+ nodehist = HistoryNodeRecord.findby_or_create(hostname=node['hostname'])
+ nodebl = BlacklistRecord.get_by(hostname=node['hostname'])
+ pcuhist = HistoryPCURecord.get_by(plc_pcuid=noderec.plc_pcuid)
+
+ if (nodehist is not None and nodehist.status == 'good' and \
+ ((pcuhist is not None and pcuhist.status == 'good') or (pcuhist is None)) ):
+ if nodebl is None: # no entry in blacklist table
+ results.append(True)
+ elif nodebl is not None and nodebl.expired(): # expired entry in blacklist table
+ results.append(True)
+ else:
+ results.append(False) # entry that is not expired.
+ else:
+ results.append(False)
+
+ try:
+ print "test: %s" % results
+ # NOTE: incase results is empty, reduce does not work on an empty set.
+ return reduce(lambda x,y: x&y, results) and len(results) > MINUP
+ except:
+ return False
+