Beispiel #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)
Beispiel #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
Beispiel #3
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 Exception, e:
    except docker.errors.NotFound, e:
        print "Could not kill container ", name
        print e
        return e
Beispiel #4
0
def kill_and_remove_user(name):
    kill_dhbox(name)
    dhbox.delete_user(name)
Beispiel #5
0
def kill_and_remove_user(name):
    kill_dhbox(name)
    dhbox.delete_user(name)