Exemple #1
0
    def run(self,args):

        p = FuncOptionParser(version=True)
        #currently not implemented
        p.add_option("-a", "--append",
                     dest="append",
                     action="store_true",
                     help="append new map to current map")
        p.add_option("-t", "--timeout",
                     dest="timeout",
                     action="store",
                     type="int",
                     default=60,
                     help="timeout to wait for reply from minions, increase for larger func installations.")
        p.add_option("-o", "--onlyalive",
                     dest="only_alive",
                     action="store_true",
                     help="gather only currently-living minions")
        p.add_option("-v", "--verbose",
                     dest="verbose",
                     action="store_true",
                     help="provide extra output")

        (options, args) = p.parse_args(args)
        self.options = options

        if options.verbose:
            print "- recursively calling map function"

        self.build_map()

        return 1
Exemple #2
0
 def run(self,args):
 
     p = FuncOptionParser(version=True)
     #currently not implemented
     p.add_option("-a", "--append",
                  dest="append",
                  action="store_true",
                  help="append new map to current map")
     p.add_option("-o", "--onlyalive",
                  dest="only_alive",
                  action="store_true",
                  help="gather only currently-living minions")
     p.add_option("-v", "--verbose",
                  dest="verbose",
                  action="store_true",
                  help="provide extra output")
                  
     (options, args) = p.parse_args(args)
     self.options = options
     
     if options.verbose:
         print "- recursively calling map function"
     
     self.build_map()
     
     return 1
Exemple #3
0
    def run(self, args):

        p = FuncOptionParser(version=True)
        #currently not implemented
        p.add_option("-a",
                     "--append",
                     dest="append",
                     action="store_true",
                     help="append new map to current map")
        p.add_option("-o",
                     "--onlyalive",
                     dest="only_alive",
                     action="store_true",
                     help="gather only currently-living minions")
        p.add_option("-v",
                     "--verbose",
                     dest="verbose",
                     action="store_true",
                     help="provide extra output")

        (options, args) = p.parse_args(args)
        self.options = options

        if options.verbose:
            print "- recursively calling map function"

        self.build_map()

        return 1
Exemple #4
0
    def run(self, args):

        p = FuncOptionParser(version=True)
        p.add_option("-v",
                     "--verbose",
                     dest="verbose",
                     action="store_true",
                     help="provide extra output")
        p.add_option("-s",
                     "--server-spec",
                     dest="server_spec",
                     default="*",
                     help="run against specific servers, default: '*'")
        p.add_option(
            "-m",
            "--methods",
            dest="methods",
            default="inventory",
            help=
            "run inventory only on certain function names, default: 'inventory'"
        )
        p.add_option(
            "-M",
            "--modules",
            dest="modules",
            default="all",
            help="run inventory only on certain module names, default: 'all'")
        p.add_option("-t",
                     "--tree",
                     dest="tree",
                     default=DEFAULT_TREE,
                     help="output results tree here, default: %s" %
                     DEFAULT_TREE)
        p.add_option("-n",
                     "--no-git",
                     dest="nogit",
                     action="store_true",
                     help="disable useful change tracking features")
        p.add_option("-x",
                     "--xmlrpc",
                     dest="xmlrpc",
                     help="output data using XMLRPC format",
                     action="store_true")
        p.add_option("-j",
                     "--json",
                     dest="json",
                     help="output data using JSON",
                     action="store_true")

        (options, args) = p.parse_args(args)
        self.options = options

        filtered_module_list = options.modules.split(",")
        filtered_function_list = options.methods.split(",")

        self.git_setup(options)

        # see what modules each host provides (as well as what hosts we have)
        host_methods = func_client.Overlord(
            options.server_spec).system.list_methods()

        # call all remote info methods and handle them
        if options.verbose:
            print "- scanning ..."
        # for (host, modules) in host_modules.iteritems():

        for (host, methods) in host_methods.iteritems():

            if utils.is_error(methods):
                sys.stderr.write("-- connection refused: %s\n" % host)
                break

            for each_method in methods:

                #if type(each_method) == int:
                #    if self.options.verbose:
                #        print "-- connection refused: %s" % host
                #    break

                tokens = each_method.split(".")
                module_name = ".".join(tokens[:-1])
                method_name = tokens[-1]

                if not "all" in filtered_module_list and not module_name in filtered_module_list:
                    continue

                if not "all" in filtered_function_list and not method_name in filtered_function_list:
                    continue

                overlord = func_client.Overlord(host,
                                                noglobs=True)  # ,noglobs=True)
                results = getattr(getattr(overlord, module_name),
                                  method_name)()
                if self.options.verbose:
                    print "-- %s: running: %s %s" % (host, module_name,
                                                     method_name)
                self.save_results(options, host, module_name, method_name,
                                  results)
        self.git_update(options)
        return 1
Exemple #5
0
    def run(self,args): 

        p = FuncOptionParser(version=True)
        p.add_option("-v", "--verbose",
                     dest="verbose",
                     action="store_true",
                     help="provide extra output")
        p.add_option("-s", "--server-spec",
                     dest="server_spec",
                     default="*",
                     help="run against specific servers, default: '*'")
        p.add_option("-m", "--methods",
                     dest="methods",
                     default="inventory",
                     help="run inventory only on certain function names, default: 'inventory'")
        p.add_option("-M", "--modules",
                     dest="modules",
                     default="all",
                     help="run inventory only on certain module names, default: 'all'")
        p.add_option("-t", "--tree",
                     dest="tree",
                     default=DEFAULT_TREE,
                     help="output results tree here, default: %s" % DEFAULT_TREE)
        p.add_option("-n", "--no-git",
                     dest="nogit",
                     action="store_true",
                     help="disable useful change tracking features")
        p.add_option("-x", "--xmlrpc", dest="xmlrpc",
                     help="output data using XMLRPC format",
                     action="store_true")
        p.add_option("-j", "--json", dest="json",
                     help="output data using JSON",
                     action="store_true")


        (options, args) = p.parse_args(args)
        self.options = options

        filtered_module_list = options.modules.split(",")
        filtered_function_list = options.methods.split(",")

        self.git_setup(options)

        # see what modules each host provides (as well as what hosts we have)
        host_methods = func_client.Overlord(options.server_spec).system.list_methods()
       
        # call all remote info methods and handle them
        if options.verbose:
            print "- scanning ..."
        # for (host, modules) in host_modules.iteritems():

        for (host, methods) in host_methods.iteritems():

            if utils.is_error(methods):
                sys.stderr.write("-- connection refused: %s\n" % host) 
                break 

            for each_method in methods:

                #if type(each_method) == int:
                #    if self.options.verbose:
                #        print "-- connection refused: %s" % host
                #    break

                tokens = each_method.split(".")
                module_name = ".".join(tokens[:-1])
                method_name = tokens[-1]

                if not "all" in filtered_module_list and not module_name in filtered_module_list:
                    continue

                if not "all" in filtered_function_list and not method_name in filtered_function_list:
                    continue
               
                overlord = func_client.Overlord(host,noglobs=True) # ,noglobs=True)
                results = getattr(getattr(overlord,module_name),method_name)()
                if self.options.verbose:
                    print "-- %s: running: %s %s" % (host, module_name, method_name)
                self.save_results(options, host, module_name, method_name, results)
        self.git_update(options)
        return 1