Пример #1
0
def client_configs(request, client_id):
    if client_id.isdigit():
        client_handler = ClientHandler()
        client_config = client_handler.get_configs(client_id)
        return HttpResponse(json.dumps(client_config))

    else:
        return HttpResponse("client id error")
Пример #2
0
def host_detail(request, host_id):
    client_handler = ClientHandler()
    client_config = client_handler.get_configs(host_id)
    service_name_list = client_config['services'].keys()
    service_name_dic = {}
    for s in models.Service.objects.filter(name__in=service_name_list):
        service_name_dic[s.name] = {
            'has_sub_service': s.has_sub_service,
        }
        if s.has_sub_service:
            redis_key = 'StatusData_%s_%s_%s' % (host_id, s.name, 'latest')
            sub_data = REDIS_OBJ.lrange(redis_key, -1, -1)
            data_point, time_stamp = json.loads(sub_data[0])
            service_name_dic[
                s.name]['sub_services'] = data_point['data'].keys()

    host_obj = models.Host.objects.get(id=host_id)
    return render(request, 'host_detail.html', {
        "host_obj": host_obj,
        "service_name_dic": service_name_dic
    })