Ejemplo 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
Ejemplo n.º 2
0
    def _get_host_grep_modules(self, server_spec):
        """
        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 ...


        host_modules = {}
        #FIXME: we need to change this to create a dict of hostname->modules
        # so we only call module.grep on systems that report it. things like
        # virt/hardware aren't available on all guests
        m = Minions(server_spec)
        hosts = m.get_all_hosts()
        if not hosts:
            raise Exception("No minions on system!")
        for host in hosts:
            fc = Overlord(host, noglobs=True)
            module_methods = fc.system.inventory()

            for module in module_methods:
                # searching for "grep"? meta
                if "grep" in module_methods[module]:
                    if not host_modules.has_key(host):
                        host_modules[host] = []
                    host_modules[host].append(module)

        return host_modules
Ejemplo n.º 3
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
Ejemplo n.º 4
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
Ejemplo n.º 5
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)
Ejemplo n.º 6
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 !")
Ejemplo n.º 7
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)
Ejemplo n.º 8
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
Ejemplo n.º 9
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
Ejemplo n.º 10
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
Ejemplo n.º 11
0
 def test_all_minions(self):
     minions = Minions("*").get_all_hosts()
     for m in minions:
         self.minion = m
         self.remote_widget_render()