# File lib/mcollective/matcher.rb, line 78 def self.execute_function(function_hash) # In the case where a data plugin isn't present there are two ways we can handle # the raised exception. The function result can either be false or the entire # expression can fail. # # In the case where we return the result as false it opens us op to unexpected # negation behavior. # # !foo('bar').name = bar # # In this case the user would expect discovery to match on all machines where # the name value of the foo function does not equal bar. If a non existent function # returns false then it is posible to match machines where the name value of the # foo function is bar. # # Instead we raise a DDLValidationError to prevent this unexpected behavior from # happening. result = Data.send(function_hash["name"], function_hash["params"]) if function_hash["value"] begin eval_result = result.send(function_hash["value"]) rescue # If data field has not been set we set the comparison result to nil eval_result = nil end return eval_result else return result end rescue NoMethodError Log.debug("cannot execute discovery function '#{function_hash["name"]}'. data plugin not found") raise DDLValidationError end