Exemplo n.º 1
0
def attach():
    """
    attach to the running container
    """
    env.docker("attach %s" % env.container_name)
    
    
Exemplo n.º 2
0
def run(ep='', **kwargs):
    """
    execute the container
    
    ep - specify an alternate entrypoint, e.g., "ep=bash"
    **kwargs - additional kwargs will be converted to environment variables passed to container
    
    """ 
    vols = "-v /var/log/syslog:/var/log/syslog"
    evars = len(kwargs) and ' '.join(["-e %s=%s" % (x[0],x[1]) for x in kwargs.items()]) or '' 
    env.docker("run -d -t -i --name adsabs-forwarder %s %s adsabs/forwarder %s" \
               % (evars, vols, ep))
Exemplo n.º 3
0
def run(ep='', detach=False, **kwargs):
    """
    execute the container
    
    ep - specify an alternate entrypoint, e.g., "ep=bash"
    **kwargs - additional kwargs will be converted to environment variables passed to container
    
    """ 
    ports = "-p 8080:8080"
    evars = len(kwargs) and ' '.join(["-e %s=%s" % (x[0],x[1]) for x in kwargs.items()]) or '' 
    detach = detach and "-d" or ""
    env.docker("run %s -t -i --name %s %s %s %s %s" \
               % (detach, env.container_name, evars, ports, env.image_name, ep))
Exemplo n.º 4
0
def data_backup(output_dir, output_file="adsloggingdata.tar"):
    from tempfile import mkdtemp
    tmpdir = mkdtemp()
    
    # TODO: use elasticsearch snapshots to do this
    # SEE: http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
    # 1. create snapshot registry
    # 2. create snapshot
    # 3. tar the snapshot as before
    # 4. delete snapshot
    # 5. delete registry?
    env.docker("run --rm --volumes-from adsabs-adsloggingdata -v %s:/backup busybox tar -cf /backup/%s /data" \
               % (tmpdir, output_file))
    local("mv %s %s" % (os.path.join(tmpdir, output_file), os.path.join(output_dir, output_file)))
    # force remove the temp directory in case something went wrong with previous comand
    local("rm -rf %s" % tmpdir)
Exemplo n.º 5
0
def run(ep='', **kwargs):
    """
    execute the containers
    
    ep - specify an alternate entrypoint, e.g., "ep=bash"
    **kwargs - additional kwargs will be converted to environment variables passed to container
    
    """
    for conf in config:
        if conf['name'] not in env.containers:
            continue
        ports = conf.has_key('ports') and ' '.join("-p %s" % p for p in conf['ports']) or ''
        vfrom = conf.has_key('vfrom') and '--volumes-from %s' % conf['vfrom'] or ''
        links = conf.has_key('links') and ' '.join("--link %s" % l for l in conf['links']) or ''
        evars = len(kwargs) and ' '.join(["-e %s=%s" % (x[0],x[1]) for x in kwargs.items()]) or ''
        
        entrypoint = conf.has_key('entrypoint') and conf['entrypoint'] or ep
        env.docker("run -d -t -i --name adsabs-%s %s %s %s %s adsabs/%s %s" \
                   % (conf['name'], evars, ports, vfrom, links, conf['name'], entrypoint))
Exemplo n.º 6
0
def data(yes=False):
    """
    remove and recreate the shared data container. WARNING! this will delete existing data & logs!
    """
    # start the data container
    with settings(hide('running', 'stdout', 'stderr')):
        containers = env.docker('ps -a', capture=True)
        if not yes:
            if not confirm("This will erase all existing data. Are you sure?", default=False):
                print cyan("OK, nevermind")
                return
        if 'adsabs-adsloggingdata' in containers:
            env.docker("stop adsabs-adsloggingdata")
            env.docker("rm adsabs-adsloggingdata")
        env.docker('run --name="adsabs-adsloggingdata" -v /data -v /var/log/supervisor ventz/dataos true')
Exemplo n.º 7
0
def rmi():
    """
    remove the image
    """
    env.docker("rmi adsabs/forwarder")
Exemplo n.º 8
0
def build():
    """
    build the container
    """
    env.docker("build -t adsabs/forwarder .")
Exemplo n.º 9
0
def rm():
    """
    remove the container
    """
    env.docker("rm %s" % env.container_name)
Exemplo n.º 10
0
def stop():
    """
    stop the container
    """
    env.docker("stop %s" % env.container_name)
Exemplo n.º 11
0
def build():
    """
    build the container
    """
    env.docker("build -t %s ." % env.image_name)
Exemplo n.º 12
0
def build():
    """
    build the containers
    """
    for name in env.containers:
        env.docker("build -t adsabs/%s dockerfiles/%s" % (name, name))
Exemplo n.º 13
0
def rm():
    """
    remove the containers
    """
    for c in env.containers:
        env.docker("rm adsabs-%s" % c)
Exemplo n.º 14
0
def stop():
    """
    stop the containers
    """
    for c in env.containers:
        env.docker("stop adsabs-%s" % c)
Exemplo n.º 15
0
def stop():
    """
    stop the container
    """
    env.docker("stop adsabs-forwarder")
Exemplo n.º 16
0
def rmi():
    """
    remove the image
    """
    env.docker("rmi %s" % env.image_name)
Exemplo n.º 17
0
def rm():
    """
    remove the container
    """
    env.docker("rm adsabs-forwarder")
Exemplo n.º 18
0
def rmi():
    """
    remove the images
    """
    for name in env.containers:
        env.docker("rmi adsabs/%s" % name)