Пример #1
0
    def test_nodes_with_recipe_wildcard(self):
        """Should return node when wildcard is given and role is asigned"""
        nodes = list(lib.get_nodes_with_recipe('sub*'))
        self.assertEqual(len(nodes), 4)

        # Get node with at least one recipe
        nodes = list(lib.get_nodes_with_recipe('*'))
        self.assertEqual(len(nodes), 5)
        nodes = list(lib.get_nodes_with_role(''))
        self.assertEqual(len(nodes), 0)
Пример #2
0
 def test_nodes_with_recipe_in_env(self):
     """Should return all nodes with a given recipe and in the given env"""
     nodes = list(lib.get_nodes_with_recipe('subversion', 'production'))
     self.assertEqual(len(nodes), 2)
     self.assertEqual(nodes[0]['name'], 'testnode1')
     nodes = list(lib.get_nodes_with_recipe('subversion', 'staging'))
     self.assertEqual(len(nodes), 1)
     # No nodes in staging with this role
     nodes = list(lib.get_nodes_with_recipe('vim', 'staging'))
     self.assertFalse(len(nodes))
Пример #3
0
 def test_nodes_with_recipe_in_env(self):
     """Should return all nodes with a given recipe and in the given env"""
     nodes = list(lib.get_nodes_with_recipe("subversion", "production"))
     self.assertEquals(len(nodes), 2)
     self.assertEquals(nodes[0]["name"], "testnode1")
     nodes = list(lib.get_nodes_with_recipe("subversion", "staging"))
     self.assertEquals(len(nodes), 1)
     # No nodes in staging with this role
     nodes = list(lib.get_nodes_with_recipe("vim", "staging"))
     self.assertFalse(len(nodes))
Пример #4
0
    def test_nodes_with_recipe_expanded(self):
        """Should return node when recipe is in the expanded run_list"""
        # 'subversion' is in the 'base' role
        nodes = list(lib.get_nodes_with_recipe('subversion'))
        self.assertEqual(len(nodes), 4)

        # man recipe inside role "all_you_can_eat" and in testnode4
        nodes = list(lib.get_nodes_with_recipe('man'))
        self.assertEqual(len(nodes), 2)
        self.assertEqual(nodes[0]['name'], 'testnode2')
Пример #5
0
 def test_nodes_with_recipe_in_env(self):
     """Should return all nodes with a given recipe and in the given env"""
     nodes = list(lib.get_nodes_with_recipe('subversion', 'production'))
     self.assertEquals(len(nodes), 2)
     self.assertEquals(nodes[0]['name'], 'testnode1')
     nodes = list(lib.get_nodes_with_recipe('subversion', 'staging'))
     self.assertEquals(len(nodes), 1)
     # No nodes in staging with this role
     nodes = list(lib.get_nodes_with_recipe('vim', 'staging'))
     self.assertFalse(len(nodes))
Пример #6
0
    def test_nodes_with_recipe_wildcard(self):
        """Should return node when wildcard is given and role is asigned"""
        nodes = list(lib.get_nodes_with_recipe('sub*'))
        self.assertEqual(len(nodes), 4)

        # Get node with at least one recipe
        nodes = list(lib.get_nodes_with_recipe('*'))
        self.assertEqual(len(nodes), 5)
        nodes = list(lib.get_nodes_with_role(''))
        self.assertEqual(len(nodes), 0)
Пример #7
0
    def test_nodes_with_recipe_expanded(self):
        """Should return node when recipe is in the expanded run_list"""
        # 'subversion' is in the 'base' role
        nodes = list(lib.get_nodes_with_recipe('subversion'))
        self.assertEqual(len(nodes), 4)

        # man recipe inside role "all_you_can_eat" and in testnode4
        nodes = list(lib.get_nodes_with_recipe('man'))
        self.assertEqual(len(nodes), 2)
        self.assertEqual(nodes[0]['name'], 'testnode2')
Пример #8
0
def nodes_with_recipe(recipename):
    """Configures a list of nodes that have the given recipe in their run list
    """
    nodes = [n['name'] for n in
             lib.get_nodes_with_recipe(recipename, env.chef_environment)]
    if not len(nodes):
        print("No nodes found with recipe '{0}'".format(recipename))
        sys.exit(0)
    return node(*nodes)
Пример #9
0
 def test_nodes_with_recipe(self):
     """Should return all nodes with a given recipe"""
     # All nodes have the subversion recipe in the expanded run_list
     nodes = list(lib.get_nodes_with_recipe('subversion'))
     self.assertEquals(len(nodes), 3)
     nodes = list(lib.get_nodes_with_recipe('sub*'))
     self.assertEquals(len(nodes), 3)
     nodes = list(lib.get_nodes_with_recipe('vim'))
     self.assertEquals(len(nodes), 1)
     self.assertEquals(nodes[0]['name'], 'testnode3.mydomain.com')
     # man recipe inside role "all_you_can_eat"
     nodes = list(lib.get_nodes_with_recipe('man'))
     self.assertEquals(len(nodes), 1)
     self.assertEquals(nodes[0]['name'], 'testnode2')
     # Get node with at least one recipe
     nodes = list(lib.get_nodes_with_recipe('*'))
     self.assertEquals(len(nodes), 3)
     nodes = list(lib.get_nodes_with_role(''))
     self.assertEquals(len(nodes), 0)
Пример #10
0
 def test_nodes_with_recipe(self):
     """Should return all nodes with a given recipe"""
     # All nodes have the subversion recipe in the expanded run_list
     nodes = list(lib.get_nodes_with_recipe('subversion'))
     self.assertEquals(len(nodes), 3)
     nodes = list(lib.get_nodes_with_recipe('sub*'))
     self.assertEquals(len(nodes), 3)
     nodes = list(lib.get_nodes_with_recipe('vim'))
     self.assertEquals(len(nodes), 1)
     self.assertEquals(nodes[0]['name'], 'testnode3.mydomain.com')
     # man recipe inside role "all_you_can_eat"
     nodes = list(lib.get_nodes_with_recipe('man'))
     self.assertEquals(len(nodes), 1)
     self.assertEquals(nodes[0]['name'], 'testnode2')
     # Get node with at least one recipe
     nodes = list(lib.get_nodes_with_recipe('*'))
     self.assertEquals(len(nodes), 3)
     nodes = list(lib.get_nodes_with_role(''))
     self.assertEquals(len(nodes), 0)
Пример #11
0
 def test_nodes_with_recipe(self):
     """Should return all nodes with a given recipe"""
     # All nodes have the subversion recipe in the expanded run_list
     nodes = list(lib.get_nodes_with_recipe("subversion"))
     self.assertEquals(len(nodes), 3)
     nodes = list(lib.get_nodes_with_recipe("sub*"))
     self.assertEquals(len(nodes), 3)
     nodes = list(lib.get_nodes_with_recipe("vim"))
     self.assertEquals(len(nodes), 1)
     self.assertEquals(nodes[0]["name"], "testnode3.mydomain.com")
     # man recipe inside role "all_you_can_eat" and in testnode4
     nodes = list(lib.get_nodes_with_recipe("man"))
     self.assertEquals(len(nodes), 2)
     self.assertEquals(nodes[0]["name"], "testnode2")
     # Get node with at least one recipe
     nodes = list(lib.get_nodes_with_recipe("*"))
     self.assertEquals(len(nodes), 4)
     nodes = list(lib.get_nodes_with_role(""))
     self.assertEquals(len(nodes), 0)
Пример #12
0
def nodes_with_recipe(recipename):
    """Configures a list of nodes that have the given recipe in their run list
    """
    nodes = [
        n['name']
        for n in lib.get_nodes_with_recipe(recipename, env.chef_environment)
    ]
    if not len(nodes):
        print("No nodes found with recipe '{0}'".format(recipename))
        sys.exit(0)
    return node(*nodes)
Пример #13
0
def list_nodes_with_recipe(recipe):
    """Show all nodes which have asigned a given recipe"""
    lib.print_nodes(lib.get_nodes_with_recipe(recipe, env.chef_environment))
Пример #14
0
 def test_nodes_with_recipe(self):
     """Should return node when recipe is in the explicit run_list"""
     nodes = list(lib.get_nodes_with_recipe('vim'))
     self.assertEqual(len(nodes), 1)
     self.assertEqual(nodes[0]['name'], 'testnode3.mydomain.com')
Пример #15
0
def list_nodes_with_recipe(recipe):
    """Show all nodes which have asigned a given recipe"""
    lib.print_nodes(lib.get_nodes_with_recipe(recipe, env.chef_environment))
Пример #16
0
 def test_nodes_with_recipe(self):
     """Should return node when recipe is in the explicit run_list"""
     nodes = list(lib.get_nodes_with_recipe('vim'))
     self.assertEqual(len(nodes), 1)
     self.assertEqual(nodes[0]['name'], 'testnode3.mydomain.com')