Esempio n. 1
0
    def test_get_all_hosts(self):
        """
        Getting all hosts
        """
        for backend_dict in self.backends:
            #create a minion with relevant backens
            m = Minions("*", **backend_dict)
            #create some groups and hosts into that Minion
            m.group_class.add_group("group1")
            m.group_class.add_hosts_to_group_glob("group1", "[0-9]")

            hosts = m.get_all_hosts()
            assert compare_arrays(hosts, self.current_minions) == True

            #now test with grouping
            m = Minions("[1][0-9];@group1:*", **backend_dict)
            hosts = m.get_all_hosts()
            assert compare_arrays(hosts, range(20)) == True

            m = Minions("[1][0-5];@group1:[5-9]", **backend_dict)
            hosts = m.get_all_hosts()
            assert compare_arrays(hosts, range(5, 16)) == True

            #do some testing about exclude string
            m = Minions("*", exclude_spec="[1-9][0-9]", **backend_dict)
            hosts = m.get_all_hosts()
            assert compare_arrays(hosts, range(10)) == True

            m = Minions("[1][0-5];@group1:[5-9]",
                        exclude_spec="[1][3-5];@group1:[5-7]",
                        **backend_dict)
            hosts = m.get_all_hosts()
            assert compare_arrays(hosts, range(8, 13)) == True
Esempio n. 2
0
 def test_get_hosts_for_spec(self):
     """
     Testing the minions just to pull things for a spec
     """
     spec = "*"
     m = Minions(spec)
     minions = m.get_hosts_for_spec(spec)
     assert compare_arrays(minions, self.current_minions) == True
Esempio n. 3
0
def get_hosts_spec(spec):
    """
    A simple call to Minions class to be
    able to use globbing in groups when
    querying ...
    """
    from func.overlord.client import Minions

    m = Minions(spec)
    return m.get_hosts_for_spec(spec)
Esempio n. 4
0
    def minions(self, glob='*'):
        """ Return a list of our minions that match a given glob """
        #make the cache thing
        if self.func_cache['glob'] == glob:
            minions = self.func_cache['minions']
        else:
            #we dont have it it is for first time so lets pull it
            minions = Minions(glob).get_all_hosts()
            self.func_cache['glob'] = glob
            self.func_cache['minions'] = minions

        return dict(minions=minions)
Esempio n. 5
0
 def _get_modules(self):
     """
     In cases when user doesnt supply the module list
     we have to consider that all of the modules are
     chosen so that method will return a list of them
     """
     from func.overlord.client import Minions,Overlord
     
     #insetad of getting all of the modules we consider
     #that all of machines has the same modules ...
     m = Minions("*")
     hosts = m.get_all_hosts()
     if hosts:
         fc = Overlord(hosts[0], noglobs=True)
         return fc.system.list_modules()
     else:
         raise Exception("No minions on system !")
Esempio n. 6
0
 def test_get_urls(self):
     for backend_dict in self.backends:
         #create a minion with relevant backens
         m = Minions("[0-9]", **backend_dict)
         hosts = m.get_urls()
         print hosts
Esempio n. 7
0
 def test_all_minions(self):
     minions = Minions("*").get_all_hosts()
     for m in minions:
         self.minion = m
         self.remote_widget_render()