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/')
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/')
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))