# Path: src/myaas/settings.py
# DEBUG = config('MYAAS_DEBUG', default=False, cast=bool)
# 
# Path: src/myaas/utils/database.py
# def get_myaas_containers():
#     return filter(_is_database_container, list_containers())
# 
# def get_enabled_backend():
#     return importlib.import_module(settings.BACKEND)
# 
# Path: src/myaas/utils/container.py
# def find_container(name):
# def list_containers(all=True):
# def translate_host_basedir(path):
# def get_random_cpuset(cores_to_assign):
# def get_mapped_cpuset():


import signal
import logging
import click
from time import sleep
from datetime import datetime
from .settings import DEBUG
from .utils.database import get_myaas_containers, get_enabled_backend
from .utils.container import client
        logger.info(f'removing {name}')
        backend = get_enabled_backend().Database
        backend(client, template, name).remove()
    except Exception as e:
        logger.exception(
            f"Failed to remove database {template} {name}")


@click.command()
@click.option('-e', '--expired', is_flag=True, default=False, help='Remove expired containers.')
@click.option('-d', '--dead', is_flag=True, default=False, help='Remove exited containers.')
@click.option('-u', '--unhealthy', is_flag=True, default=False, help='Remove unhealthy containers.')
@click.option('--dry-run', is_flag=True, default=False, help='Only print name of containers that would be removed and exit.')
def cleanup(expired, dead, unhealthy, dry_run):
    if not (expired or dead or unhealthy):
        raise click.UsageError("at least one filter must be enabled, use --help for more information")

    cf = ContainerFilter(expired, dead, unhealthy)
    databases = cf.filter(get_myaas_containers())

    if dry_run:
        logger.info("Started in dry mode")
        for d in databases:
            name = get_container_name(d)
            logger.info("would remove %s", name)
        return

    logger.info("Starting myaas ttl reaper...")
    sighandler = SignalHandler()
    while not sighandler.exit:

# Path: src/myaas/settings.py
# DEBUG = config('MYAAS_DEBUG', default=False, cast=bool)
# 
# Path: src/myaas/utils/database.py
# def get_myaas_containers():
#     return filter(_is_database_container, list_containers())
# 
# def get_enabled_backend():
#     return importlib.import_module(settings.BACKEND)
# 
# Path: src/myaas/utils/container.py
# def find_container(name):
# def list_containers(all=True):
# def translate_host_basedir(path):
# def get_random_cpuset(cores_to_assign):
# def get_mapped_cpuset():


# Path: src/myaas/reaper.py
import signal
import logging
import click
from time import sleep
from datetime import datetime
from .settings import DEBUG
from .utils.database import get_myaas_containers, get_enabled_backend
from .utils.container import client

        logger.info(f'removing {name}')
        backend = get_enabled_backend().Database
        backend(client, template, name).remove()
    except Exception as e:
        logger.exception(
            f"Failed to remove database {template} {name}")


@click.command()
@click.option('-e', '--expired', is_flag=True, default=False, help='Remove expired containers.')
@click.option('-d', '--dead', is_flag=True, default=False, help='Remove exited containers.')
@click.option('-u', '--unhealthy', is_flag=True, default=False, help='Remove unhealthy containers.')
@click.option('--dry-run', is_flag=True, default=False, help='Only print name of containers that would be removed and exit.')
def cleanup(expired, dead, unhealthy, dry_run):
    if not (expired or dead or unhealthy):
        raise click.UsageError("at least one filter must be enabled, use --help for more information")

    cf = ContainerFilter(expired, dead, unhealthy)
    databases = cf.filter(get_myaas_containers())

    if dry_run:
        logger.info("Started in dry mode")
        for d in databases:
            name = get_container_name(d)
            logger.info("would remove %s", name)
        return

    logger.info("Starting myaas ttl reaper...")
    sighandler = SignalHandler()
    while not sighandler.exit:

        databases = cf.filter(get_myaas_containers())