예제 #1
0
def check_and_kill(user):
    """Checks a container's uptime and kills it and the user if time is up"""
    try:
        get_container_info(user.name)
        time_left = user.dhbox_duration - how_long_up(user.name)
        # print user.name, " time left: ", time_left, " seconds"
        if time_left <= 0:
            kill_and_remove_user(user.name)
    except docker.errors.NotFound:
        dhbox.delete_user(user.name)
예제 #2
0
def kill_and_remove_user(name, user=True):
    """Kill a running DH Box container and remove the user if there is one"""
    try:
        print "Killing container."
        c.kill(name)
        c.kill(name+'_wp')
        c.remove_container(name)
        c.remove_container(name+'_wp')
        if user:
            dhbox.delete_user(name)
    except (docker.errors.NotFound, docker.errors.APIError) as e:
        print "Could not kill container ", name
        if user:
            dhbox.delete_user(name)
        return e
예제 #3
0
파일: DockerBackend.py 프로젝트: sabo/dhbox
def kill_and_remove_user(name, user=True):
    """Kill a running DH Box container and remove the user if there is one"""
    try:
        print "Killing container."
        c.kill(name)
        c.kill(name + "_wp")
        c.remove_container(name)
        c.remove_container(name + "_wp")
        if user:
            dhbox.delete_user(name)
    # except Exception, e:
    except docker.errors.NotFound, e:
        print "Could not kill container ", name
        print e
        return e
예제 #4
0
def kill_and_remove_user(name):
    kill_dhbox(name)
    dhbox.delete_user(name)
예제 #5
0
def kill_and_remove_user(name):
    kill_dhbox(name)
    dhbox.delete_user(name)