예제 #1
0
def download_log(request):
    sys_mgr = sysinfo.sys_mgr()      # get sys manager
    sys_mgr.rm_sys_log()   # rm the exist tar log file
    log_tar_file = sys_mgr.tar_sys_log()
    response = FileResponse(log_tar_file, request=request, content_type='application/force-download')
    response.headers['Content-Disposition'] = 'attachment; filename=%s' % (os.path.basename(log_tar_file))
    return response
예제 #2
0
def download_log(request):
    sys_mgr = sysinfo.sys_mgr()  # get sys manager
    sys_mgr.rm_sys_log()  # rm the exist tar log file
    log_tar_file = sys_mgr.tar_sys_log()
    response = FileResponse(log_tar_file,
                            request=request,
                            content_type='application/force-download')
    response.headers['Content-Disposition'] = 'attachment; filename=%s' % (
        os.path.basename(log_tar_file))
    return response
예제 #3
0
def system_cpu_list_get(request):
    sys_mgr = sysinfo.sys_mgr()      # get sys manager
    cpus = sys_mgr.get_cpu_list()
    cpu_list_dict = []
    for cpu in cpus:
        cpu_info = {'processor': int(cpu["processor"]),
                    'model_name': cpu["model name"],
                    'cpu_MHz': float(cpu["cpu MHz"]),
                    'cache_size': cpu["cache size"]}
        cpu_list_dict.append(cpu_info)
    return cpu_list_dict
예제 #4
0
def system_cpu_list_get(request):
    sys_mgr = sysinfo.sys_mgr()  # get sys manager
    cpus = sys_mgr.get_cpu_list()
    cpu_list_dict = []
    for cpu in cpus:
        cpu_info = {
            'processor': int(cpu["processor"]),
            'model_name': cpu["model name"],
            'cpu_MHz': float(cpu["cpu MHz"]),
            'cache_size': cpu["cache size"]
        }
        cpu_list_dict.append(cpu_info)
    return cpu_list_dict
예제 #5
0
def get_system_localhost(request):
    sys_mgr = sysinfo.sys_mgr()
    sys_uname = platform.uname()
    hostname = sys_mgr.get_hostname()
    dist_name, dist_version, dist_id = sys_mgr.get_dist_info()
    uptime = datetime.now() - datetime.fromtimestamp(psutil.BOOT_TIME)
    av1, av2, av3 = os.getloadavg()
    info = {
        'hostname': hostname,
        'system': sys_uname[0],
        'release': sys_uname[2],
        'version': sys_uname[3],
        'machine': sys_uname[4],
        'processor': sys_uname[5],
        'dist_name': dist_name,
        'dist_version': dist_version,
        'dist_id': dist_id,
        "uptime": str(uptime).split('.')[0],
        "loadavg":[av1, av2, av3]
    }
    return info
예제 #6
0
def get_system_localhost(request):
    sys_mgr = sysinfo.sys_mgr()
    sys_uname = platform.uname()
    hostname = sys_mgr.get_hostname()
    dist_name, dist_version, dist_id = sys_mgr.get_dist_info()
    uptime = datetime.now() - datetime.fromtimestamp(psutil.BOOT_TIME)
    av1, av2, av3 = os.getloadavg()
    info = {
        'hostname': hostname,
        'system': sys_uname[0],
        'release': sys_uname[2],
        'version': sys_uname[3],
        'machine': sys_uname[4],
        'processor': sys_uname[5],
        'dist_name': dist_name,
        'dist_version': dist_version,
        'dist_id': dist_id,
        "uptime": str(uptime).split('.')[0],
        "loadavg": [av1, av2, av3]
    }
    return info
예제 #7
0
def set_datetime(request):
    params = get_params_from_request(request)
    sys_mgr = sysinfo.sys_mgr()      # get sys manager
    sys_mgr.set_datetime(params['datetime'], user=request.client_addr)
    return Response(status=200)
예제 #8
0
def get_datetime(request):
    sys_mgr = sysinfo.sys_mgr()      # get sys manager
    datetime_str = sys_mgr.get_datetime()
    return {'datetime': datetime_str}
예제 #9
0
def sys_reboot(request):
    sys_mgr = sysinfo.sys_mgr()      # get sys manager
    sys_mgr.reboot(user=request.client_addr)
    return Response(status=200)
예제 #10
0
def sys_poweroff(request):
    sys_mgr = sysinfo.sys_mgr()      # get sys manager
    sys_mgr.poweroff(user=request.client_addr)
    return Response(status=200)
예제 #11
0
def flush_page_cache_post(request):
    sys_mgr = sysinfo.sys_mgr()  # get sys manager
    sys_mgr.flush_page_cache()
    return Response(status=200)
예제 #12
0
def get_datetime(request):
    sys_mgr = sysinfo.sys_mgr()  # get sys manager
    datetime_str = sys_mgr.get_datetime()
    return {'datetime': datetime_str}
예제 #13
0
def put_selinux_state(request):
    params = get_params_from_request(request, selinux_mod_schema)
    sys_mgr = sysinfo.sys_mgr()      # get sys manager
    sys_mgr.set_selinux_state(params['state'], user=request.client_addr)
    return "System should be reboot when selinux state is changed"
예제 #14
0
def get_host_list(request):
    sys_mgr = sysinfo.sys_mgr()
    host_list = sys_mgr.get_host_list()
    return host_list
예제 #15
0
def put_selinux_state(request):
    params = get_params_from_request(request, selinux_mod_schema)
    sys_mgr = sysinfo.sys_mgr()  # get sys manager
    sys_mgr.set_selinux_state(params['state'], user=request.client_addr)
    return "System should be reboot when selinux state is changed"
예제 #16
0
def get_selinux_state(request):
    sys_mgr = sysinfo.sys_mgr()  # get sys manager
    return {"state": sys_mgr.get_selinux_state()}
예제 #17
0
def get_timestamp(request):
    sys_mgr = sysinfo.sys_mgr()  # get sys manager
    timestamp = sys_mgr.get_timestamp()
    return {'timestamp': timestamp}
예제 #18
0
def set_datetime(request):
    params = get_params_from_request(request)
    sys_mgr = sysinfo.sys_mgr()  # get sys manager
    sys_mgr.set_datetime(params['datetime'], user=request.client_addr)
    return Response(status=200)
예제 #19
0
def get_timestamp(request):
    sys_mgr = sysinfo.sys_mgr()      # get sys manager
    timestamp = sys_mgr.get_timestamp()
    return {'timestamp': timestamp}
예제 #20
0
def get_host_list(request):
    sys_mgr = sysinfo.sys_mgr()
    host_list = sys_mgr.get_host_list()
    return host_list
예제 #21
0
def get_selinux_state(request):
    sys_mgr = sysinfo.sys_mgr()      # get sys manager
    return {"state": sys_mgr.get_selinux_state()}
예제 #22
0
def sys_poweroff(request):
    sys_mgr = sysinfo.sys_mgr()  # get sys manager
    sys_mgr.poweroff(user=request.client_addr)
    return Response(status=200)
예제 #23
0
def put_system_localhost(request):
    sys_mgr = sysinfo.sys_mgr()      # get sys manager
    params = get_params_from_request(request, local_host_schema)
    if "hostname" in params:
        sys_mgr.set_hostname(params["hostname"], user=request.client_addr)
    return Response(status=200)
예제 #24
0
def sys_reboot(request):
    sys_mgr = sysinfo.sys_mgr()  # get sys manager
    sys_mgr.reboot(user=request.client_addr)
    return Response(status=200)
예제 #25
0
def put_host_list(request):
    params = get_params_from_request(request, host_list_schema)
    sys_mgr = sysinfo.sys_mgr()
    sys_mgr.set_host_list(params, request.client_addr)
    return Response(status=200)
예제 #26
0
def flush_page_cache_post(request):
    sys_mgr = sysinfo.sys_mgr()      # get sys manager
    sys_mgr.flush_page_cache()
    return Response(status=200)
예제 #27
0
def put_host_list(request):
    params = get_params_from_request(request, host_list_schema)
    sys_mgr = sysinfo.sys_mgr()
    sys_mgr.set_host_list(params, request.client_addr)
    return Response(status=200)
예제 #28
0
def put_system_localhost(request):
    sys_mgr = sysinfo.sys_mgr()  # get sys manager
    params = get_params_from_request(request, local_host_schema)
    if "hostname" in params:
        sys_mgr.set_hostname(params["hostname"], user=request.client_addr)
    return Response(status=200)