class MCollective::Application::Describe_filter - mcollective version 2.12.5

# class MCollective::Application::Describe_filter

### Public Instance Methods

describe_c_filter(classes) click to toggle source

       # File lib/mcollective/application/describe_filter.rb
    53 def describe_c_filter(classes)
    54   puts "-C filter expands to the following class checks:"
    55   puts
    56   classes.each do |c|
    57     puts "  " + get_class_string(c)
    58   end
    59 end

describe_f_filter(facts) click to toggle source

       # File lib/mcollective/application/describe_filter.rb
    45 def describe_f_filter(facts)
    46   puts "-F filter expands to the following fact comparisons:"
    47   puts
    48   facts.each do |f|
    49     puts "  " + get_fact_string(f[:fact], f[:value], f[:operator])
    50   end
    51 end

describe_s_filter(stack) click to toggle source

       # File lib/mcollective/application/describe_filter.rb
     9 def describe_s_filter(stack)
    10   indent = "  "
    11   old_indent = "  "
    12   puts "-S Query expands to the following instructions:"
    13   puts
    14   stack.each do |token|
    15     if token.keys[0] == "statement"
    16       if token.values[0] =~ /(<=|>=|=|=~|=)/
    17         op = $1
    18         k,v = token.values[0].split(op)
    19         puts indent + get_fact_string(k, v, op)
    20       else
    21         puts indent + get_class_string(token.values[0])
    22       end
    23     elsif token.keys[0] == "fstatement"
    24       v = token.values[0]
    25       result_string = indent + "Execute the Data Query '#{v["name"]}'"
    26       if v["params"]
    27         result_string += " with parameters (#{v["params"]})"
    28       end
    29       result_string += ". "
    30       result_string += "Check if the query's '#{v["value"]}' value #{v["operator"]} '#{v["r_compare"]}'  "
    31       puts result_string
    32     elsif token.keys[0] == "("
    33       puts indent + "("
    34       old_indent = indent
    35       indent *= 2
    36     elsif token.keys[0] == ")"
    37       indent = old_indent
    38       puts indent + ")"
    39     else
    40       puts indent + token.keys[0].upcase
    41     end
    42   end
    43 end

main() click to toggle source

       # File lib/mcollective/application/describe_filter.rb
    61 def main
    62   if !(@options[:filter]["fact"].empty?)
    63     describe_f_filter(@options[:filter]["fact"])
    64     puts
    65   end
    66
    67   if !(@options[:filter]["cf_class"].empty?)
    68     describe_c_filter(@options[:filter]["cf_class"])
    69     puts
    70   end
    71
    72   if !(@options[:filter]["compound"].empty?)
    73     describe_s_filter(@options[:filter]["compound"][0])
    74     puts
    75   end
    76 end