Exemplo n.º 1
0
def resolve_running_docker_containers():
    """Resolve running docker containers.
       Return the running container names (e.g. cond-0) in ascending order"""
    container_ids = terminal.docker_ps(
        ps_filter='name={}'.format(CONDUCTR_NAME_PREFIX))
    container_names = [
        terminal.docker_inspect(container_id, '{{.Name}}')[1:]
        for container_id in container_ids
    ]
    return sorted(container_names)
Exemplo n.º 2
0
    def test_docker_inspect(self):
        container_id = 'cond-0'
        inspect_format = '{{.NetworkSettings.IPAddress}}'
        ip = '172.17.0.20'

        check_output_mock = MagicMock(return_value='{}\n'.format(ip))

        with patch('subprocess.check_output', check_output_mock):
            result = terminal.docker_inspect(container_id, inspect_format)

        self.assertEqual(result, ip)
        check_output_mock.assert_called_with(['docker', 'inspect', '--format', '{{.NetworkSettings.IPAddress}}',
                                              container_id], universal_newlines=True)
Exemplo n.º 3
0
    def test_docker_inspect(self):
        container_id = 'cond-0'
        inspect_format = '{{.NetworkSettings.IPAddress}}'
        ip = '172.17.0.20'

        check_output_mock = MagicMock(return_value='{}\n'.format(ip))

        with patch('subprocess.check_output', check_output_mock):
            result = terminal.docker_inspect(container_id, inspect_format)

        self.assertEqual(result, ip)
        check_output_mock.assert_called_with([
            'docker', 'inspect', '--format', '{{.NetworkSettings.IPAddress}}',
            container_id
        ],
                                             universal_newlines=True)
Exemplo n.º 4
0
def resolve_running_docker_containers():
    """Resolve running docker containers.
       Return the running container names (e.g. cond-0) in ascending order"""
    container_ids = terminal.docker_ps(ps_filter='name={}'.format(CONDUCTR_NAME_PREFIX))
    container_names = [terminal.docker_inspect(container_id, '{{.Name}}')[1:] for container_id in container_ids]
    return sorted(container_names)
Exemplo n.º 5
0
def inspect_cond0_ip():
    return terminal.docker_inspect('{}0'.format(CONDUCTR_NAME_PREFIX), '{{.NetworkSettings.IPAddress}}')
Exemplo n.º 6
0
def inspect_cond0_ip():
    return terminal.docker_inspect('{}0'.format(CONDUCTR_NAME_PREFIX),
                                   '{{.NetworkSettings.IPAddress}}')