Beispiel #1
0
    def getArgs(cls, arg):
        """turn a comma-separated set of values into opts
        and values that can be merged with other configuration
        opts, and return it

        args:    a string possibly containing commas
        returns: dict of option, value where the options may include:
                 'host'     -- source host(s)
                 'path'     -- path to file or files on source host
                 'db'       -- name of db for source
                 'user'     -- user name for db connection
                 'password' -- password for db connection
                 or other options particular to a given source
        """

        result = HOptions.getOptions(
            arg,
            sorted(cls.options, key=lambda optName: cls.options[optName][0]))
        for opt in result:
            result[opt] = cls.parseOptionMultiples(opt, result[opt])
        return result
Beispiel #2
0
    def getArgs(cls, arg):
        """turn a comma-separated set of values into opts
        and values that can be merged with other configuration
        opts, and return it

        args:    a string possibly containing commas
        returns: dict of option, value where the options may include:
                 'host'     -- source host(s)
                 'path'     -- path to file or files on source host
                 'db'       -- name of db for source
                 'user'     -- user name for db connection
                 'password' -- password for db connection
                 or other options particular to a given source
        """

        result = HOptions.getOptions(
            arg, sorted(cls.options,
                        key=lambda optName: cls.options[optName][0]))
        for opt in result:
            result[opt] = cls.parseOptionMultiples(opt, result[opt])
        return result
Beispiel #3
0
        if opt:
            mainOptsSet += 1
    if not mainOptsSet:
        HHelp.usage("You must choose one of 'filter', 'report' or 'cli'")
    if mainOptsSet > 1:
        HHelp.usage("You may choose only one of 'filter', 'report' or 'cli'")

    # handle configuration file processing
    hc = HConfig.CheckHostsConfig(configfile)
    hc.parseConfFile()
    configInfoFromFiles = hc.conf.options

    # merge in any config options we got from the command line
    for t in list(set(configInfoFromFiles.keys() + configInfo.keys())):
        if t in configInfo:
            configInfo[t] = HOptions.mergeDefaults(configInfoFromFiles[t],
                                                   configInfo[t])
        else:
            configInfo[t] = HOptions.mergeDefaults(configInfoFromFiles[t],
                                                   None)
    if timeout is None:
        if hc.conf.has_option('globals', 'timeout'):
            timeout = hc.conf.get('globals', 'timeout')

    if verbose:
        print "running with configuration:"
        print configInfo

    # list of hosts in sources
    if filterExpr:
        hf = HFilter.HostFilter(configInfo, hostExprs, timeout, verbose)
        hf.processFilterArg(filterExpr)