def playbooks(self): results = [] project_path = self.get_project_path() if project_path: for dirpath, dirnames, filenames in os.walk(smart_str(project_path), followlinks=settings.AWX_SHOW_PLAYBOOK_LINKS): if skip_directory(dirpath): continue for filename in filenames: playbook = could_be_playbook(project_path, dirpath, filename) if playbook is not None: results.append(smart_text(playbook)) return sorted(results, key=lambda x: smart_str(x).lower())
def all_playbooks(self): results = [] project_path = self.get_project_path() if project_path: for dirpath, dirnames, filenames in os.walk( smart_str(project_path), followlinks=True): if skip_directory(dirpath): continue for filename in filenames: playbook = os.path.relpath(os.path.join(dirpath, filename), smart_str(project_path)) if playbook is None: results.append(smart_text(playbook)) return sorted(results, key=lambda x: smart_str(x).lower())
def inventories(self): results = [] project_path = self.get_project_path() if project_path: # Cap the number of results, because it could include lots max_inventory_listing = 50 for dirpath, dirnames, filenames in os.walk(smart_str(project_path)): if skip_directory(dirpath): continue for filename in filenames: inv_path = could_be_inventory(project_path, dirpath, filename) if inv_path is not None: results.append(smart_text(inv_path)) if len(results) > max_inventory_listing: break if len(results) > max_inventory_listing: break return sorted(results, key=lambda x: smart_str(x).lower())