Example #1
0
def stop(args):
    """`sandbox stop` command"""

    log = logging.getLogger(__name__)
    running_containers = sandbox_common.resolve_running_docker_containers()
    if running_containers:
        log.info(headline('Stopping ConductR'))
        terminal.docker_rm(running_containers)
Example #2
0
def stop(args):
    """`sandbox stop` command"""

    log = logging.getLogger(__name__)
    running_containers = sandbox_common.resolve_running_docker_containers()
    if running_containers:
        log.info('Stopping ConductR..')
        terminal.docker_rm(running_containers)
Example #3
0
    def test_docker_rm(self):
        containers = ['cond-0', 'cond-1']
        stdout = MagicMock()
        subprocess_call_mock = MagicMock()

        with patch('subprocess.call', subprocess_call_mock), \
                patch('sys.stdout', stdout):
            terminal.docker_rm(containers)

        self.assertEqual('', self.output(stdout))
        subprocess_call_mock.assert_called_with(['docker', 'rm', '-f'] + containers)
Example #4
0
    def test_docker_rm(self):
        containers = ['cond-0', 'cond-1']
        stdout = MagicMock()
        subprocess_call_mock = MagicMock()

        with patch('subprocess.call', subprocess_call_mock), \
                patch('sys.stdout', stdout):
            terminal.docker_rm(containers)

        self.assertEqual('', self.output(stdout))
        subprocess_call_mock.assert_called_with(['docker', 'rm', '-f'] +
                                                containers)
Example #5
0
def stop_proxy():
    log = logging.getLogger(__name__)

    try:
        running_container = get_running_haproxy()
        if running_container:
            log.info(headline('Stopping HAProxy'))
            is_docker_present()
            terminal.docker_rm([DEFAULT_SANDBOX_PROXY_CONTAINER_NAME])
            log.info('HAProxy has been successfully stopped')

        return True
    except (AttributeError, CalledProcessError):
        # Fail silently as these errors will be raised if Docker is not installed or Docker environment is not
        # configured properly.
        return False
Example #6
0
def stop_nodes(args, running_containers):
    log = logging.getLogger(__name__)

    log.info('Stopping ConductR nodes..')
    last_containers = len(running_containers) - args.nr_of_containers
    containers_to_be_stopped = running_containers[-last_containers:]
    return terminal.docker_rm(containers_to_be_stopped)
Example #7
0
def stop_nodes(args, running_containers):
    log = logging.getLogger(__name__)

    log.info('Stopping ConductR nodes..')
    last_containers = len(running_containers) - args.nr_of_containers
    containers_to_be_stopped = running_containers[-last_containers:]
    return terminal.docker_rm(containers_to_be_stopped)
Example #8
0
def stop_proxy():
    log = logging.getLogger(__name__)

    if docker.is_docker_present():
        try:
            running_container = get_running_haproxy()
            if running_container:
                log.info(h1('Stopping HAProxy'))
                terminal.docker_rm([DEFAULT_SANDBOX_PROXY_CONTAINER_NAME])
                log.info('HAProxy has been successfully stopped')

            return True
        except (AttributeError, CalledProcessError, NOT_FOUND_ERROR):
            return False
    else:
        # Docker is not present, so the proxy feature won't be running in the first place.
        return True
Example #9
0
def stop(args):
    log = logging.getLogger(__name__)
    running_containers = sandbox_common.resolve_running_docker_containers()
    if running_containers:
        log.info(headline('Stopping ConductR'))
        try:
            terminal.docker_rm(running_containers)
            log.info('ConductR has been successfully stopped')
            return True
        except (AttributeError, CalledProcessError):
            log.error(
                'ConductR containers could not be stopped pid 58002 could not be stopped'
            )
            log.error('Please stop the Docker containers manually')
            return False
    else:
        return True
def stop(args):
    log = logging.getLogger(__name__)
    try:
        running_containers = sandbox_common.resolve_running_docker_containers()
    except (AttributeError, CalledProcessError, NOT_FOUND_ERROR):
        # return True because Docker is not installed and therefore no containers need to be stopped.
        return True

    if running_containers:
        log.info(h1('Stopping ConductR'))
        try:
            terminal.docker_rm(running_containers)
            log.info('ConductR has been successfully stopped')
            return True
        except (AttributeError, CalledProcessError, NOT_FOUND_ERROR):
            log.error('ConductR containers could not be stopped')
            log.error('Please stop the Docker containers manually')
            return False
    else:
        return True
Example #11
0
def stop_nodes(running_containers):
    log = logging.getLogger(__name__)
    log.info('Stopping ConductR nodes..')
    return terminal.docker_rm(running_containers)