def api_aggregate_host(hostname, module, metric): dt_start = get_dt_start(request) dt_end = get_dt_end(request, dt_start) table = query.host_mapreduce(hostname, module, metric, dt_start, dt_end) for k, v in table.items(): table[k]['last_dt'] = query.dt_to_timestamp(table[k]['last_dt']) return {"result": table}
def api_aggregate_host(hostname, module, metric): dt_start = get_dt_start(request) dt_end = get_dt_end(request, dt_start) table = query.host_mapreduce(hostname, module, metric, dt_start, dt_end) for k,v in table.items(): table[k]['last_dt'] = query.dt_to_timestamp(table[k]['last_dt']) return {"result": table}
def host_view_post(hostname): dt_start = post_dt_start(request) dt_end = post_dt_end(request, dt_start) last_update = datetime.datetime.now() hostlist = query.hostlist() ping_table = query.host_mapreduce(hostname, 'ping', 'avg', dt_start, dt_end) iperf_table = query.host_mapreduce(hostname, 'iperf', 'bandwidth', dt_start, dt_end) return template('host_template', title=hostname, hostname=hostname, hostlist=hostlist, last_update=last_update, dt_start=query.dt_to_timestamp(dt_start), dt_end=query.dt_to_timestamp(dt_end), ping_table=ping_table, iperf_table=iperf_table)
def host_view(hostname): last_update = datetime.datetime.now() dt_start = datetime.datetime.now() - config.DT_QUERY dt_end = datetime.datetime.now() hostlist = query.hostlist() ping_table = query.host_mapreduce(hostname, 'ping', 'avg', dt_start, dt_end) iperf_table = query.host_mapreduce(hostname, 'iperf', 'bandwidth', dt_start, dt_end) logging.error(iperf_table) return template('host_template', title=hostname, hostname=hostname, hostlist=hostlist, last_update=last_update, dt_start=query.dt_to_timestamp(dt_start), dt_end=query.dt_to_timestamp(dt_end), ping_table=ping_table, iperf_table=iperf_table)