Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

implemented list_nodes_from_file and nodes_from_file commands

  • Loading branch information...
commit 5aa1981f4a7515606055b0e4ad5a24891b8701c5 1 parent f3a80cf
@thekorn thekorn authored
Showing with 29 additions and 0 deletions.
  1. +12 −0 littlechef/lib.py
  2. +17 −0 littlechef/runner.py
View
12 littlechef/lib.py
@@ -97,6 +97,18 @@ def get_nodes_with_tag(tag, environment=None, include_guests=False):
pass
+def get_nodes_from_file(filename):
+ """Get all nodes listed in a given file"""
+ with open(filename) as fd:
+ for line in fd:
+ n = get_node(line.strip())
+ if n == {'run_list': []}:
+ # no node object found, ignore this entry
+ continue
+ else:
+ yield n
+
+
def get_nodes_with_recipe(recipe_name, environment=None):
"""Get all nodes which include a given recipe,
prefix-searches are also supported
View
17 littlechef/runner.py
@@ -101,6 +101,17 @@ def nodes_with_tag(tag):
@hosts('setup')
+def nodes_from_file(filename):
+ """Sets a list of nodes that are listed in a given file and calls node()"""
+ nodes = lib.get_nodes_from_file(filename)
+ nodes = [n['name'] for n in nodes]
+ if not len(nodes):
+ print("No nodes found with tag '{0}'".format(tag))
+ sys.exit(0)
+ return node(*nodes)
+
+
+@hosts('setup')
def node(*nodes):
"""Selects and configures a list of nodes. 'all' configures all nodes"""
if not len(nodes) or nodes[0] == '':
@@ -280,6 +291,12 @@ def list_nodes_with_tag(tag):
@hosts('api')
+def list_nodes_from_file(filename):
+ """Show all nodes which are listed in a given file"""
+ lib.print_nodes(lib.get_nodes_from_file(filename))
+
+
+@hosts('api')
def list_recipes():
"""Show a list of all available recipes"""
for recipe in lib.get_recipes():
Please sign in to comment.
Something went wrong with that request. Please try again.