# Path: src/myaas/utils/container.py
# def list_containers(all=True):
#     client = docker.Client()
#     return client.containers(all=all)


import logging
import importlib
from .. import settings
from .container import list_containers
def get_enabled_backend():
    return importlib.import_module(settings.BACKEND)


def get_myaas_containers():
    return filter(_is_database_container, list_containers())


def list_databases():
    containers = filter(_is_database_container, list_containers())
    return [_get_database_name(c) for c in containers]


def list_database_templates():
    containers = filter(_is_template_container, list_containers())
    return [_get_database_name(c) for c in containers]


def _is_database_container(container):
    if not container['Labels']:
        return False

    if 'com.myaas.instance' not in container['Labels']:
        return False

    return container['Labels'].get('com.myaas.instance') != ''


def _is_template_container(container):
    if not container['Labels']:

# Path: src/myaas/utils/container.py
# def list_containers(all=True):
#     client = docker.Client()
#     return client.containers(all=all)


# Path: src/myaas/utils/database.py
import logging
import importlib
from .. import settings
from .container import list_containers

def get_enabled_backend():
    return importlib.import_module(settings.BACKEND)


def get_myaas_containers():
    return filter(_is_database_container, list_containers())


def list_databases():
    containers = filter(_is_database_container, list_containers())
    return [_get_database_name(c) for c in containers]


def list_database_templates():
    containers = filter(_is_template_container, list_containers())
    return [_get_database_name(c) for c in containers]


def _is_database_container(container):
    if not container['Labels']:
        return False

    if 'com.myaas.instance' not in container['Labels']:
        return False

    return container['Labels'].get('com.myaas.instance') != ''


def _is_template_container(container):
    if not container['Labels']:

        return False