def hosts_list(): logger.info("/hosts_list method=" + r.method) request_debug(r, logger) col_filter = dict((key, r.args.get(key)) for key in r.args) items = list(host_handler.list(filter_data=col_filter)) return make_ok_resp(data=items)
def hosts_list(): logger.info("/hosts_list method=" + r.method) request_debug(r, logger) col_filter = dict((key, r.args.get(key)) for key in r.args) items = list(host_handler.list(filter_data=col_filter)) return make_ok_resp(data=items)
def clusters_show(): request_debug(r, logger) show_type = r.args.get("type", "active") col_filter = dict((key, r.args.get(key)) for key in r.args if key != "col_name" and key != "page" and key != "type") if show_type != "released": col_name = r.args.get("col_name", "active") else: col_name = r.args.get("col_name", "released") if show_type == "inused": col_filter["user_id"] = {"$ne": ""} clusters = list(cluster_handler.list(filter_data=col_filter, col_name=col_name)) if show_type == "active": clusters.sort(key=lambda x: str(x["create_ts"]), reverse=True) elif show_type == "inused": clusters.sort(key=lambda x: str(x["apply_ts"]), reverse=True) else: clusters.sort(key=lambda x: str(x["release_ts"]), reverse=True) total_items = len(clusters) hosts = list(host_handler.list()) hosts_avail = list(filter(lambda e: e["status"] == "active" and len( e["clusters"]) < e["capacity"], hosts)) return render_template("clusters.html", type=show_type, col_name=col_name, items_count=total_items, items=clusters, hosts_available=hosts_avail, network_type=NETWORK_TYPES, consensus_plugins=CONSENSUS_PLUGINS_FABRIC_V1, consensus_modes=CONSENSUS_MODES, cluster_sizes=NETWORK_SIZE_FABRIC_V1)
def hosts(self): """ Get hosts related statistic result :return: The stat result """ result = {'status': [], 'type': []} actives = list(host_handler.list(filter_data={'status': 'active'})) inactive = list(host_handler.list(filter_data={'status': 'inactive'})) result['status'] = [ {'name': 'active', 'y': len(actives)}, {'name': 'inactive', 'y': len(inactive)} ] for host_type in HOST_TYPES: hosts = list(host_handler.list(filter_data={'type': host_type})) result['type'].append({ 'name': host_type, 'y': len(hosts) }) return result
def hosts_show(): logger.info("/hosts method=" + r.method) request_debug(r, logger) col_filter = dict((key, r.args.get(key)) for key in r.args) items = list(host_handler.list(filter_data=col_filter)) items.sort(key=lambda x: str(x["name"]), reverse=True) logger.debug(items) return render_template("hosts.html", items_count=len(items), items=items, host_types=WORKER_TYPES, log_types=CLUSTER_LOG_TYPES, log_levels=CLUSTER_LOG_LEVEL, )
def watch_run(period=15): """ Run the checking in period. :param period: Wait period between two checking :return: """ while True: logger.info("Watchdog run checks with period = %d s", period) hosts = list(host_handler.list()) for h in hosts: # operating on different host is safe t = Thread(target=host_check, args=(h.get("id"), )) t.start() t.join(timeout=2 * period) time.sleep(period)
def hosts_show(): logger.info("/hosts method=" + r.method) request_debug(r, logger) col_filter = dict((key, r.args.get(key)) for key in r.args) items = list(host_handler.list(filter_data=col_filter)) items.sort(key=lambda x: str(x["name"]), reverse=True) logger.debug(items) return render_template("hosts.html", items_count=len(items), items=items, host_types=WORKER_TYPES, log_types=CLUSTER_LOG_TYPES, log_levels=CLUSTER_LOG_LEVEL, )
def watch_run(period=15): """ Run the checking in period. :param period: Wait period between two checking :return: """ while True: logger.info("Watchdog run checks with period = %d s", period) hosts = list(host_handler.list()) logger.info("Found {} hosts".format(len(hosts))) for h in hosts: # operating on different host is safe t = Thread(target=host_check, args=(h.get("id"),)) t.start() t.join(timeout=2 * period) time.sleep(period)
def show(): request_debug(r, logger) hosts = list(host_handler.list(filter_data={})) hosts.sort(key=lambda x: x["name"], reverse=False) hosts_active = list(filter(lambda e: e["status"] == "active", hosts)) hosts_inactive = list(filter(lambda e: e["status"] != "active", hosts)) hosts_free = list( filter(lambda e: len(e["clusters"]) < e["capacity"], hosts_active)) hosts_available = hosts_free clusters_active = len(list(cluster_handler.list(col_name="active"))) clusters_released = len(list(cluster_handler.list(col_name="released"))) clusters_free = len( list( cluster_handler.list(filter_data={"user_id": ""}, col_name="active"))) clusters_inuse = clusters_active - clusters_free clusters_temp = len( list( cluster_handler.list(filter_data={"user_id": "/^__/"}, col_name="active"))) user_id, username, is_admin = \ str(current_user.id), current_user.username, current_user.isAdmin return render_template("index.html", hosts=hosts, hosts_free=hosts_free, hosts_active=hosts_active, hosts_inactive=hosts_inactive, hosts_available=hosts_available, clusters_active=clusters_active, clusters_released=clusters_released, clusters_free=clusters_free, clusters_inuse=clusters_inuse, clusters_temp=clusters_temp, cluster_sizes=NETWORK_SIZE_FABRIC_PRE_V1, network_type=NETWORK_TYPES, consensus_plugins=CONSENSUS_PLUGINS_FABRIC_V1, consensus_modes=CONSENSUS_MODES, host_types=WORKER_TYPES, log_types=CLUSTER_LOG_TYPES, log_levels=CLUSTER_LOG_LEVEL, username=username, user_id=user_id, is_admin=is_admin)
def show(): request_debug(r, logger) hosts = list(host_handler.list(filter_data={})) hosts.sort(key=lambda x: x["name"], reverse=False) hosts_active = list(filter(lambda e: e["status"] == "active", hosts)) hosts_inactive = list(filter(lambda e: e["status"] != "active", hosts)) hosts_free = list( filter(lambda e: len(e["clusters"]) < e["capacity"], hosts_active)) hosts_available = hosts_free clusters_active = len(list(cluster_handler.list(col_name="active"))) clusters_released = len(list(cluster_handler.list(col_name="released"))) clusters_free = len( list( cluster_handler.list(filter_data={"user_id": ""}, col_name="active"))) clusters_inuse = clusters_active - clusters_free clusters_temp = len( list( cluster_handler.list(filter_data={"user_id": "/^__/"}, col_name="active"))) return render_template( "index.html", hosts=hosts, hosts_free=hosts_free, hosts_active=hosts_active, hosts_inactive=hosts_inactive, hosts_available=hosts_available, clusters_active=clusters_active, clusters_released=clusters_released, clusters_free=clusters_free, clusters_inuse=clusters_inuse, clusters_temp=clusters_temp, cluster_sizes=CLUSTER_SIZES, fabric_version=FABRIC_VERSION, consensus_plugins=CONSENSUS_PLUGINS, consensus_modes=CONSENSUS_MODES, host_types=HOST_TYPES, log_types=CLUSTER_LOG_TYPES, log_levels=CLUSTER_LOG_LEVEL, )
def show(): request_debug(r, logger) hosts = list(host_handler.list(filter_data={})) hosts.sort(key=lambda x: x["name"], reverse=False) hosts_active = list(filter(lambda e: e["status"] == "active", hosts)) hosts_inactive = list(filter(lambda e: e["status"] != "active", hosts)) hosts_free = list(filter( lambda e: len(e["clusters"]) < e["capacity"], hosts_active)) hosts_available = hosts_free clusters_active = len(list(cluster_handler.list(col_name="active"))) clusters_released = len(list(cluster_handler.list(col_name="released"))) clusters_free = len(list(cluster_handler.list(filter_data={"user_id": ""}, col_name="active"))) clusters_inuse = clusters_active - clusters_free clusters_temp = len(list(cluster_handler.list(filter_data={ "user_id": "/^__/"}, col_name="active"))) username, is_admin = current_user.username, current_user.isAdmin return render_template("index.html", hosts=hosts, hosts_free=hosts_free, hosts_active=hosts_active, hosts_inactive=hosts_inactive, hosts_available=hosts_available, clusters_active=clusters_active, clusters_released=clusters_released, clusters_free=clusters_free, clusters_inuse=clusters_inuse, clusters_temp=clusters_temp, cluster_sizes=NETWORK_SIZE_FABRIC_PRE_V1, network_type=NETWORK_TYPES, consensus_plugins=CONSENSUS_PLUGINS_FABRIC_V1, consensus_modes=CONSENSUS_MODES, host_types=WORKER_TYPES, log_types=CLUSTER_LOG_TYPES, log_levels=CLUSTER_LOG_LEVEL, username=username, is_admin=is_admin )
def show(): logger.info("path={}, method={}".format(r.path, r.method)) hosts = list(host_handler.list()) return render_template("stat.html", hosts=hosts)
def show(): logger.info("path={}, method={}".format(r.path, r.method)) hosts = list(host_handler.list()) return render_template("stat.html", hosts=hosts)