Beispiel #1
0
def ping_docker(request):
    if request.method == 'GET':
        ip = request.GET['ip']
        port = request.GET['port']
        if ip and port:
            re = dockerclient.testEngine(ip, port)
            if re:
                respones = {}
                respones['result'] = 'ok'
                return JsonResponse(respones, safe=False)
    respones = {}
    respones['result'] = 'fail'
    return JsonResponse(respones, safe=False)
Beispiel #2
0
def ping_docker(request):
    if request.method == 'GET':
        ip=request.GET['ip']
        port=request.GET['port']
        if ip and port:
            re=dockerclient.testEngine(ip,port)
            if re:
                respones={}
                respones['result']='ok'
                return JsonResponse(respones,safe=False)
    respones={}
    respones['result']='fail'
    return JsonResponse(respones,safe=False)
Beispiel #3
0
def container_update(request):
    if request.method == 'GET':
        x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
        if x_forwarded_for:
            ip = x_forwarded_for.split(',')[0]
        else:
            ip = request.META.get('REMOTE_ADDR')
        port = "2375"
        if ip and port:
            ping = dockerclient.testEngine(ip, port)
            if ping:
                re1 = dockerclient.listContainers(ip, port)
                re2 = application.listByIp(ip)
                if re1:
                    for re in re1:
                        #auto detect
                        if not application.exist(re['id']):
                            application.auto_detect(ip, port, re['id'])
                if re2:
                    for re in re2:
                        #update status
                        application.updateStatus(re)
                return HttpResponse("ok")
    return HttpResponseNotFound("403")
Beispiel #4
0
def container_update(request):
    if request.method == 'GET':
        x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
        if x_forwarded_for:
            ip = x_forwarded_for.split(',')[0]
        else:
            ip = request.META.get('REMOTE_ADDR')
        port="2375"
        if ip and port:
            ping=dockerclient.testEngine(ip, port)
            if ping:
                re1=dockerclient.listContainers(ip,port)
                re2=application.listByIp(ip)
                if re1:
                    for re in re1:
                        #auto detect
                        if not application.exist(re['id']):
                            application.auto_detect(ip, port, re['id'])
                if re2:    
                    for re in re2:
                        #update status
                        application.updateStatus(re)
                return HttpResponse("ok")
    return HttpResponseNotFound("403")