예제 #1
0
 def logs(self):
     try:
         client = get_docker_client()
         return client.logs(self.container_name)
     except NotFound:
         return _("Logs no longer exist.")
     except ConnectionError:
         return _("Can't connect to Docker.")
예제 #2
0
 def logs(self):
     try:
         client = get_docker_client()
         return client.logs(self.container_name)
     except NotFound:
         return _("Logs no longer exist.")
     except ConnectionError:
         return _("Can't connect to Docker.")
예제 #3
0
def run_job(job, job_attr):
    """
    Launch a job with a choosen commit

    ;param job: Job instance to launch
    :type job: :class:`abdallah.models.Job`

    :param job_attr: Job's charateristics
    :type commit: ``dict``
    """
    docker_client = get_docker_client()
    volumes, host_config = get_job_host_config(job, job_attr)
    try:
        container_attrs = docker_client.create_container(
            image='python:2',
            command='bash /job.sh',
            name=job.container_name,
            environment=job_attr['env'],
            volumes=volumes)
        docker_client.start(resource_id=container_attrs,
                            binds=host_config)
    except ConnectionError:
        job.status = 'ERR'
        job.save()
예제 #4
0
 def test_func(self):
     client = docker_utils.get_docker_client()
     self.assertIsInstance(client, docker.Client)