- if '2.6' not in node['kernel']: node['kernel'] = ""
- node['boot_state'] = color_boot_state(node['boot_state'])
- node['current'] = color_boot_state(node['current'])
- #node['boot_state'] = node['boot_state']
- #node['current'] = node['current']
- node['pcu'] = fb['nodes'][node['hostname']]['values']['pcu']
- return "%(hostname)-38s %(boot_state)5s %(current)5s %(pcu)6s %(key)45s %(kernel)s" % node
-
-from model import *
-import soltesz
-
-def node_end_record(node):
- act_all = soltesz.dbLoad("act_all")
- if node not in act_all:
- del act_all
- return False
- a = Action(node, act_all[node][0])
- a.delField('rt')
- a.delField('found_rt_ticket')
- a.delField('second-mail-at-oneweek')
- a.delField('second-mail-at-twoweeks')
- a.delField('first-found')
- rec = a.get()
- rec['action'] = ["close_rt"]
- rec['category'] = "UNKNOWN"
- rec['stage'] = "monitor-end-record"
- rec['time'] = time.time() - 7*60*60*24
- act_all[node].insert(0,rec)
- soltesz.dbDump("act_all", act_all)
- del act_all
- return True
+ if '2.6' not in node['kernel_version']: node['kernel_version'] = ""
+ if conf and not conf.nocolor:
+ node['boot_state'] = color_boot_state(node['boot_state'])
+ node['current'] = color_boot_state(node['current'])
+
+ if type(fbdata['plc_node_stats']['pcu_ids']) == type([]):
+ node['pcu'] = "PCU"
+ node['lastupdate'] = diff_time(node['last_contact'])
+
+ pf = PersistFlags(node['hostname'], 1, db='node_persistflags')
+ try:
+ node['lc'] = diff_time(pf.last_changed)
+ except:
+ node['lc'] = "err"
+
+ ut = fbdata['comon_stats']['uptime']
+ if ut != "null":
+ ut = diff_time(float(fbdata['comon_stats']['uptime']), False)
+ node['uptime'] = ut
+
+ return "%(hostname)-42s %(boot_state)8s %(current)5s %(pcu)6s %(key)10.10s... %(kernel_version)35.35s %(lastupdate)12s, %(lc)s, %(uptime)s" % node
+
+def datetime_fromstr(str):
+ if '-' in str:
+ try:
+ tup = time.strptime(str, "%Y-%m-%d")
+ except:
+ tup = time.strptime(str, "%Y-%m-%d-%H:%M")
+ elif '/' in str:
+ tup = time.strptime(str, "%m/%d/%Y")
+ else:
+ tup = time.strptime(str, "%m/%d/%Y")
+ ret = datetime.fromtimestamp(time.mktime(tup))
+ return ret
+
+def get_nodeset(config):
+ """
+ Given the config values passed in, return the set of hostnames that it
+ evaluates to.
+ """
+ api = plc.getAuthAPI()
+ l_nodes = plccache.l_nodes
+
+ if config.nodelist:
+ f_nodes = util.file.getListFromFile(config.nodelist)
+ l_nodes = filter(lambda x: x['hostname'] in f_nodes, l_nodes)
+ elif config.node:
+ f_nodes = [config.node]
+ l_nodes = filter(lambda x: x['hostname'] in f_nodes, l_nodes)
+ elif config.nodegroup:
+ ng = api.GetNodeGroups({'name' : config.nodegroup})
+ l_nodes = api.GetNodes(ng[0]['node_ids'], ['hostname'])
+ elif config.site:
+ site = api.GetSites(config.site)
+ l_nodes = api.GetNodes(site[0]['node_ids'], ['hostname'])
+
+ l_nodes = [node['hostname'] for node in l_nodes]
+
+ # perform this query after the above options, so that the filter above
+ # does not break.
+ if config.nodeselect:
+ fbquery = FindbadNodeRecord.get_all_latest()
+ node_list = [ n.hostname for n in fbquery ]
+ l_nodes = node_select(config.nodeselect, node_list, None)
+
+ return l_nodes
+