def nodes_with_tag(tag): """Sets a list of nodes that have the given tag assigned and calls node()""" nodes = lib.get_nodes_with_tag(tag, env.chef_environment, littlechef.include_guests) 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)
def list_nodes_with_tag(tag): """Show all nodes which have assigned a given tag""" lib.print_nodes(lib.get_nodes_with_tag(tag, env.chef_environment, littlechef.include_guests))
def test_get_nodes_with_tag_in_env(self): """Should list all nodes with tag 'top' in the given environment""" nodes = list(lib.get_nodes_with_tag('top', 'production')) self.assertEqual(len(nodes), 0) nodes = list(lib.get_nodes_with_tag('top', '_default')) self.assertEqual(len(nodes), 1)
def test_get_nodes_with_tag(self): """Should list all nodes with tag 'top'""" nodes = list(lib.get_nodes_with_tag('top')) self.assertEqual(len(nodes), 1)
def list_nodes_with_tag(tag): """Show all nodes which have assigned a given tag""" lib.print_nodes( lib.get_nodes_with_tag(tag, env.chef_environment, littlechef.include_guests))