예제 #1
0
def containerstop(request):
    path = request.get_full_path()
    #print(path)
    containerid = path.split('/')[3][:12]
    #print(containerid)
    try:
        container = Container.objects.get(containerid__startswith=containerid)
    except :
        msg = '数据库查询有问题'
    #print(container.password,container.containername,container.containerhost,container.dockerhost)
    dockerip = container.dockerhost
    docker = DockerHost.objects.get(ip=dockerip)
    dockerpassword = docker.hostpassword
    #print(dockerpassword)
    stopresult = rundockercmd.stopContainer(rundockercmd.sshClient(dockerip,dockerpassword),containerid)
    #print(stopresult)
    return HttpResponseRedirect('/containers/list/')
예제 #2
0
def containerstop(request):
    path = request.get_full_path()
    #print(path)
    containerid = path.split('/')[3][:12]
    #print(containerid)
    try:
        container = Container.objects.get(containerid__startswith=containerid)
    except:
        msg = '数据库查询有问题'
    #print(container.password,container.containername,container.containerhost,container.dockerhost)
    dockerip = container.dockerhost
    docker = DockerHost.objects.get(ip=dockerip)
    dockerpassword = docker.hostpassword
    #print(dockerpassword)
    stopresult = rundockercmd.stopContainer(
        rundockercmd.sshClient(dockerip, dockerpassword), containerid)
    #print(stopresult)
    return HttpResponseRedirect('/containers/list/')
예제 #3
0
파일: views.py 프로젝트: fengbb/hcdocker
def containerstop(request):
    msg = ""
    path = request.get_full_path()
    containerid = path.split("/")[3][:12]
    # print(containerid)
    try:
        container = Container.objects.get(containerid__startswith=containerid)
    except:
        msg = "数据库查询有问题"
    # print(container.password,container.containername,container.containerhost,container.dockerhost)
    dockerip = container.dockerhost
    docker = DockerHost.objects.get(ip=dockerip)
    dockerpassword = docker.hostpassword
    # print(dockerpassword)
    stopresult = rundockercmd.stopContainer(rundockercmd.sshClient(dockerip, dockerpassword), containerid)
    if stopresult:
        msg = "关闭容器成功"
    else:
        msg = "关闭容器失败"
    return HttpResponseRedirect("/containers/list/?p1=%s" % (msg))