author Gregory Szorc <gps@mozilla.com>
Sun, 19 Oct 2014 17:30:51 -0700
changeset 1340 edc4d061ba895bbcfd92849d98a11fa7a6bb8e01
parent 1236 1ae5c5dde8f81540936c406d772562034e683ab6
child 1384 244a217608e6dd8f0117156c2bdb0743162f42f3
permissions -rwxr-xr-x
testing: detect Docker TLS settings from environment boot2docker 1.3.0 switched to use TLS by default. We update our Docker connection code to recognize these variables and to talk to Docker over TLS, if applicable. Future patches will update other consumers of this API to use the new, more robust code.

#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# This script is used to manage Docker containers in the context of running
# Mercurial tests.

import os
import sys

from vcttesting.docker import (

def main(args):
    if 'DOCKER_STATE_FILE' in os.environ:
        state_file = os.environ['DOCKER_STATE_FILE']
    elif 'HGTMP' in os.environ:
        state_file = os.path.join(os.environ['HGTMP'], 'docker-state.json')
        print('Do not know where to put a Docker state file.')
        return 1

    docker_url, tls = params_from_env(os.environ)

    d = Docker(state_file, docker_url, tls=tls)

    if not d.is_alive():
        print('Docker is not available!')
        return 1

    action = args[0]

    if action == 'build-bmo':
    elif action == 'start-bmo':
        cluster, http_port = args[1:]
        db_image = os.environ.get('DOCKER_BMO_DB_IMAGE')
        web_image = os.environ.get('DOCKER_BMO_WEB_IMAGE')

        d.start_bmo(cluster=cluster, hostname=None, http_port=http_port,
                db_image=db_image, web_image=web_image)
    elif action == 'stop-bmo':
    elif action == 'prune-images':

if __name__ == '__main__':
    # Unbuffer stdout.
    sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)