- if (nodehist is not None and nodehist.status != 'down') or \
- (nodebl is not None and not nodebl.expired()):
- up = up + 1
+ if checkpcu:
+ # get pcu history for node
+ if nodehist.haspcu:
+ # get node record for pcuid
+ noderec = FindbadNodeRecord.get_latest_by(hostname=node['hostname'])
+ # get pcuhistory based on pcuid
+ pcuhist = HistoryPCURecord.findby_or_create(plc_pcuid=noderec.plc_pcuid)
+ # if pcu is not down & node is not down
+ if (nodehist is not None and nodehist.status != 'down' and \
+ pcuhist is not None and pcuhist.status != 'down') or \
+ (nodebl is not None and not nodebl.expired()):
+ up = up + 1
+
+ else:
+ # todo: don't count
+ pass
+ else:
+ if (nodehist is not None and nodehist.status != 'down') or \
+ (nodebl is not None and not nodebl.expired()):
+ up = up + 1