Exemplo n.º 1
0
def list_containers(active=True,
                    defined=True,
                    as_object=False,
                    config_path=None):
    """
        List the containers on the system.
    """

    if config_path:
        if not os.path.exists(config_path):
            return tuple()
        try:
            entries = _lxc.list_containers(active=active,
                                           defined=defined,
                                           config_path=config_path)
        except ValueError:
            return tuple()
    else:
        try:
            entries = _lxc.list_containers(active=active, defined=defined)
        except ValueError:
            return tuple()

    if as_object:
        return tuple([Container(name, config_path) for name in entries])
    else:
        return entries
Exemplo n.º 2
0
def list_containers(active=True, defined=True,
                    as_object=False, config_path=None):
    """
        List the containers on the system.
    """

    if config_path:
        entries = _lxc.list_containers(active=active, defined=defined,
                                       config_path=config_path)
    else:
        entries = _lxc.list_containers(active=active, defined=defined)

    if as_object:
        return tuple([Container(name, config_path) for name in entries])
    else:
        return entries
Exemplo n.º 3
0
def my_list_containers(active=True, defined=True, as_object=False, config_path=None):
    """
    List the containers on the system.
    This function from original lxc library. It is rewrited to work with new class
    """
    if config_path:
        if not os.path.exists(config_path):
            return tuple()
        try:
            entries = _lxc.list_containers(active=active, defined=defined, config_path=config_path)
        except ValueError:
            return tuple()
    else:
        try:
            entries = _lxc.list_containers(active=active, defined=defined)
        except ValueError:
            return tuple()
    if as_object:
        return tuple([BugContainer(name, config_path) for name in entries])
    else:
        return entries
Exemplo n.º 4
0
def list_containers(active=True, defined=True,
                    as_object=False, config_path=None):
    """
        List the containers on the system.
    """

    if config_path:
        if not os.path.exists(config_path):
            return tuple()
        try:
            entries = _lxc.list_containers(active=active, defined=defined,
                                           config_path=config_path)
        except ValueError:
            return tuple()
    else:
        try:
            entries = _lxc.list_containers(active=active, defined=defined)
        except ValueError:
            return tuple()

    if as_object:
        return tuple([Container(name, config_path) for name in entries])
    else:
        return entries