def recipes_add(): """ Add detected recipes based on local cookbooks to db""" l = LocalStorage() for user in l.list_users(): repo = RepoManager(user) for cb in l.list_cookbooks(user): system = l.find_system(cb) for r in l.list_recipes(cb): ro = Recipe() ro.name = r ro.cookbook = cb ro.version = repo.browse_file(r) ro.system = system ro.user = user ro.save()
def cookbooks_add(): """Add local cookbooks to db""" l = LocalStorage() for user in l.list_users(): repo = RepoManager(user) for cb in l.list_cookbooks(user): system = l.find_system(cb) LOG.info("Adding cookbook %s" % cb) cb = CookBook() cb.name = cb cb.system = system cb.version = repo.version cb.path = os.path.join(l.path, cb) cb.user = user cb.save() for r in l.list_recipes(cb.path): ro = Recipe() ro.name = r ro.cookbook = cb ro.version = repo.browse_file(r) ro.system = system ro.user = user ro.save()