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
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
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