Beispiel #1
0
def nodes(request):
    logger.logger_info("GET NODE LIST",
                       LOG_LEVEL=logging.INFO,
                       log_type='Nodes')
    save_db.save_logs_to_db("User:%s Get node list" % request.user)
    nodes = kube.get_node()
    return render(request, 'nodes/nodes/nodes_list.html', locals())
Beispiel #2
0
def etcd_websocket(request):
    logger.logger_info('GET Etcd Info',
                       LOG_LEVEL=logging.INFO,
                       log_type='ETCD')
    save_db.save_logs_to_db("User:%s Use websocket get etcd info" %
                            request.user)
    if request.method == 'POST':
        leader = etcds.cluster_leader()
        check_port = etcds.check_etcd_port()
        save_db.save_logs_to_db(
            "User:%s Use post request of get etcd info success" % request.user)
        logger.logger_info('GET Success',
                           LOG_LEVEL=logging.INFO,
                           log_type='ETCD')
        return HttpResponse(
            json.dumps({
                'leader': leader,
                'port_status': check_port
            }))
    else:
        save_db.save_logs_to_db(
            "User:%s Get etcd faild,Reason: Use get request" % request.user)
        logger.logger_error('GET faild',
                            LOG_LEVEL=logging.ERROR,
                            log_type='ETCD')
        return HttpResponse(json.dumps({'error': 'Access Error'}))
Beispiel #3
0
def pod_info(request, namespace):
    print('pod_info')
    logger.logger_info("get pod info",
                       LOG_LEVEL=logging.INFO,
                       log_type='pod_info')
    name = request.GET.get('pod_name')
    pods_info = kube_func.pod_info(name=name, namespace=namespace)
    save_db.save_logs_to_db("User:%s Get pod:%s info on namespaces:%s " %
                            (request.user, name, namespace))
    return render(request, 'nodes/pods/pods_info.html', locals())
Beispiel #4
0
def namespace(request):
    logger.logger_info('user:%s access namespaces list' % request.user,
                       LOG_LEVEL=logging.INFO,
                       log_type="namespace")
    if request.method == 'POST':
        name = request.GET.get('project')
        if name == 'all_project':
            namespace_info = kube_func.all_namespace_pod_role()
        else:
            namespace_info = kube_func.namespace_pod_role(namespace=name)
        return HttpResponse(json.dumps(namespace_info))
    elif request.method == 'GET':
        return render(request, 'nodes/namespace/namespace_list.html', locals())
Beispiel #5
0
def namespace_role_info(request):
    logger.logger_info("user:%s access namespace role info" % request.user,
                       LOG_LEVEL=logging.INFO,
                       log_type='namespace')
    role = request.GET.get('role').split('=')[0]