Permalink
Browse files

maint: whitespace fixes and remove vim modelines

  • Loading branch information...
1 parent 7a8b59b commit 2c20b69913d9ef75e7bc395f30ac112b3d7f5687 @ripienaar ripienaar committed Oct 22, 2011
Showing with 119 additions and 175 deletions.
  1. +0 −1 Rakefile
  2. +0 −2 ext/stompclient
  3. +0 −2 lib/mcollective.rb
  4. +0 −2 lib/mcollective/agents.rb
  5. +0 −2 lib/mcollective/client.rb
  6. +0 −2 lib/mcollective/config.rb
  7. +0 −1 lib/mcollective/connector.rb
  8. +0 −2 lib/mcollective/connector/base.rb
  9. +0 −1 lib/mcollective/facts.rb
  10. +0 −2 lib/mcollective/log.rb
  11. +0 −1 lib/mcollective/matcher.rb
  12. +0 −1 lib/mcollective/message.rb
  13. +0 −2 lib/mcollective/optionparser.rb
  14. +0 −1 lib/mcollective/pluginmanager.rb
  15. +0 −1 lib/mcollective/registration.rb
  16. +0 −1 lib/mcollective/registration/base.rb
  17. +0 −1 lib/mcollective/rpc.rb
  18. +118 −120 lib/mcollective/rpc/agent.rb
  19. +0 −1 lib/mcollective/rpc/audit.rb
  20. +0 −1 lib/mcollective/rpc/client.rb
  21. +0 −2 lib/mcollective/rpc/ddl.rb
  22. +0 −2 lib/mcollective/rpc/progress.rb
  23. +0 −1 lib/mcollective/rpc/reply.rb
  24. +0 −1 lib/mcollective/rpc/request.rb
  25. +0 −1 lib/mcollective/rpc/result.rb
  26. +0 −2 lib/mcollective/rpc/stats.rb
  27. +0 −1 lib/mcollective/runner.rb
  28. +0 −1 lib/mcollective/security.rb
  29. +0 −1 lib/mcollective/security/base.rb
  30. +0 −2 lib/mcollective/util.rb
  31. +0 −2 mc-call-agent
  32. +1 −2 mcollectived.rb
  33. +0 −2 plugins/mcollective/agent/discovery.rb
  34. +0 −1 plugins/mcollective/audit/logfile.rb
  35. +0 −2 plugins/mcollective/connector/stomp.rb
  36. +0 −1 plugins/mcollective/facts/yaml_facts.rb
  37. +0 −1 plugins/mcollective/registration/agentlist.rb
  38. +0 −1 plugins/mcollective/security/psk.rb
  39. +0 −2 plugins/mcollective/security/ssl.rb
View
1 Rakefile
@@ -203,4 +203,3 @@ task :mail_patches do
# Finally, clean up the patches
sh "rm 00*.patch"
end
-# vi:tabstop=4:expandtab:ai
View
2 ext/stompclient
@@ -154,5 +154,3 @@ loop do
puts("ERROR: unrecognised input: #{line}")
end
end
-
-# vi:tabstop=4:expandtab:ai
View
2 lib/mcollective.rb
@@ -63,5 +63,3 @@ def self.version
VERSION
end
end
-
-# vi:tabstop=4:expandtab:ai
View
2 lib/mcollective/agents.rb
@@ -158,5 +158,3 @@ def self.agentlist
end
end
end
-
-# vi:tabstop=4:expandtab:ai
View
2 lib/mcollective/client.rb
@@ -272,5 +272,3 @@ def display_stats(stats, options=false, caption="stomp call summary")
end
end
end
-
-# vi:tabstop=4:expandtab:ai
View
2 lib/mcollective/config.rb
@@ -186,5 +186,3 @@ def read_plugin_config_dir(dir)
end
end
end
-
-# vi:tabstop=4:expandtab:ai
View
1 lib/mcollective/connector.rb
@@ -16,4 +16,3 @@ module Connector
autoload :Base, "mcollective/connector/base"
end
end
-# vi:tabstop=4:expandtab:ai
View
2 lib/mcollective/connector/base.rb
@@ -22,5 +22,3 @@ def self.inherited(klass)
end
end
end
-
-# vi:tabstop=4:expandtab:ai
View
1 lib/mcollective/facts.rb
@@ -37,4 +37,3 @@ def self.[](fact)
end
end
end
-# vi:tabstop=4:expandtab:ai
View
2 lib/mcollective/log.rb
@@ -101,5 +101,3 @@ def from
end
end
end
-
-# vi:tabstop=4:expandtab:ai:filetype=ruby
View
1 lib/mcollective/matcher.rb
@@ -14,4 +14,3 @@ module Matcher
autoload :Scanner, "mcollective/matcher/scanner"
end
end
-# vi:tabstop=4:expandtab:ai
View
1 lib/mcollective/message.rb
@@ -171,4 +171,3 @@ def create_reqid
end
end
end
-# vi:tabstop=4:expandtab:ai
View
2 lib/mcollective/optionparser.rb
@@ -143,5 +143,3 @@ def parse_fact(fact)
end
end
-
-# vi:tabstop=4:expandtab:ai
View
1 lib/mcollective/pluginmanager.rb
@@ -117,4 +117,3 @@ def self.grep(regex)
end
end
end
-# vi:tabstop=4:expandtab:ai
View
1 lib/mcollective/registration.rb
@@ -14,4 +14,3 @@ module Registration
autoload :Base, "mcollective/registration/base"
end
end
-# vi:tabstop=4:expandtab:ai
View
1 lib/mcollective/registration/base.rb
@@ -73,4 +73,3 @@ def publish(message)
end
end
end
-# vi:tabstop=4:expandtab:ai
View
1 lib/mcollective/rpc.rb
@@ -186,4 +186,3 @@ def self.reply
end
end
end
-# vi:tabstop=4:expandtab:ai
View
238 lib/mcollective/rpc/agent.rb
@@ -44,12 +44,12 @@ class Agent
def initialize
# Default meta data unset
@meta = {:timeout => 10,
- :name => "Unknown",
- :description => "Unknown",
- :author => "Unknown",
- :license => "Unknown",
- :version => "Unknown",
- :url => "Unknown"}
+ :name => "Unknown",
+ :description => "Unknown",
+ :author => "Unknown",
+ :license => "Unknown",
+ :version => "Unknown",
+ :url => "Unknown"}
@timeout = meta[:timeout] || 10
@logger = Log.instance
@@ -303,133 +303,131 @@ def self.authorized_by(plugin)
PluginManager.loadclass(pluginname) unless MCollective::Util.constants.include?(plugin)
class_eval("
- def authorization_hook(request)
- #{pluginname}.authorize(request)
- end
- ")
+ def authorization_hook(request)
+ #{pluginname}.authorize(request)
+ end
+ ")
+ end
+
+ # Validates a data member, if validation is a regex then it will try to match it
+ # else it supports testing object types only:
+ #
+ # validate :msg, String
+ # validate :msg, /^[\w\s]+$/
+ #
+ # There are also some special helper validators:
+ #
+ # validate :command, :shellsafe
+ # validate :command, :ipv6address
+ # validate :command, :ipv4address
+ #
+ # It will raise appropriate exceptions that the RPC system understand
+ #
+ # TODO: this should be plugins, 1 per validatin method so users can add their own
+ # at the moment i have it here just to proof the point really
+ def validate(key, validation)
+ raise MissingRPCData, "please supply a #{key} argument" unless @request.include?(key)
+
+ if validation.is_a?(Regexp)
+ raise InvalidRPCData, "#{key} should match #{validation}" unless @request[key].match(validation)
+
+ elsif validation.is_a?(Symbol)
+ case validation
+ when :shellsafe
+ raise InvalidRPCData, "#{key} should be a String" unless @request[key].is_a?(String)
+
+ ['`', '$', ';', '|', '&&', '>', '<'].each do |chr|
+ raise InvalidRPCData, "#{key} should not have #{chr} in it" if @request[key].match(Regexp.escape(chr))
end
- # Validates a data member, if validation is a regex then it will try to match it
- # else it supports testing object types only:
- #
- # validate :msg, String
- # validate :msg, /^[\w\s]+$/
- #
- # There are also some special helper validators:
- #
- # validate :command, :shellsafe
- # validate :command, :ipv6address
- # validate :command, :ipv4address
- #
- # It will raise appropriate exceptions that the RPC system understand
- #
- # TODO: this should be plugins, 1 per validatin method so users can add their own
- # at the moment i have it here just to proof the point really
- def validate(key, validation)
- raise MissingRPCData, "please supply a #{key} argument" unless @request.include?(key)
-
- if validation.is_a?(Regexp)
- raise InvalidRPCData, "#{key} should match #{validation}" unless @request[key].match(validation)
-
- elsif validation.is_a?(Symbol)
- case validation
- when :shellsafe
- raise InvalidRPCData, "#{key} should be a String" unless @request[key].is_a?(String)
-
- ['`', '$', ';', '|', '&&', '>', '<'].each do |chr|
- raise InvalidRPCData, "#{key} should not have #{chr} in it" if @request[key].match(Regexp.escape(chr))
- end
-
- when :ipv6address
- begin
- require 'ipaddr'
- ip = IPAddr.new(@request[key])
- raise InvalidRPCData, "#{key} should be an ipv6 address" unless ip.ipv6?
- rescue
- raise InvalidRPCData, "#{key} should be an ipv6 address"
- end
-
- when :ipv4address
- begin
- require 'ipaddr'
- ip = IPAddr.new(@request[key])
- raise InvalidRPCData, "#{key} should be an ipv4 address" unless ip.ipv4?
- rescue
- raise InvalidRPCData, "#{key} should be an ipv4 address"
- end
-
- when :boolean
- raise InvalidRPCData, "#{key} should be boolean" unless [TrueClass, FalseClass].include?(@request[key].class)
- end
- else
- raise InvalidRPCData, "#{key} should be a #{validation}" unless @request[key].is_a?(validation)
- end
+ when :ipv6address
+ begin
+ require 'ipaddr'
+ ip = IPAddr.new(@request[key])
+ raise InvalidRPCData, "#{key} should be an ipv6 address" unless ip.ipv6?
+ rescue
+ raise InvalidRPCData, "#{key} should be an ipv6 address"
end
- # convenience wrapper around Util#shellescape
- def shellescape(str)
- Util.shellescape(str)
+ when :ipv4address
+ begin
+ require 'ipaddr'
+ ip = IPAddr.new(@request[key])
+ raise InvalidRPCData, "#{key} should be an ipv4 address" unless ip.ipv4?
+ rescue
+ raise InvalidRPCData, "#{key} should be an ipv4 address"
end
- # handles external actions
- def implemented_by(command, type=:json)
- runner = ActionRunner.new(command, request, type)
+ when :boolean
+ raise InvalidRPCData, "#{key} should be boolean" unless [TrueClass, FalseClass].include?(@request[key].class)
+ end
+ else
+ raise InvalidRPCData, "#{key} should be a #{validation}" unless @request[key].is_a?(validation)
+ end
+ end
+
+ # convenience wrapper around Util#shellescape
+ def shellescape(str)
+ Util.shellescape(str)
+ end
- res = runner.run
+ # handles external actions
+ def implemented_by(command, type=:json)
+ runner = ActionRunner.new(command, request, type)
- reply.fail! "Did not receive data from #{command}" unless res.include?(:data)
- reply.fail! "Reply data from #{command} is not a Hash" unless res[:data].is_a?(Hash)
+ res = runner.run
- reply.data.merge!(res[:data])
+ reply.fail! "Did not receive data from #{command}" unless res.include?(:data)
+ reply.fail! "Reply data from #{command} is not a Hash" unless res[:data].is_a?(Hash)
- if res[:exitstatus] > 0
- reply.fail "Failed to run #{command}: #{res[:stderr]}", res[:exitstatus]
- end
- rescue Exception => e
- Log.warn("Unhandled #{e.class} exception during #{request.agent}##{request.action}: #{e}")
- reply.fail! "Unexpected failure calling #{command}: #{e.class}: #{e}"
- end
+ reply.data.merge!(res[:data])
- # Called at the end of the RPC::Agent standard initialize method
- # use this to adjust meta parameters, timeouts and any setup you
- # need to do.
- #
- # This will not be called right when the daemon starts up, we use
- # lazy loading and initialization so it will only be called the first
- # time a request for this agent arrives.
- def startup_hook
- end
+ if res[:exitstatus] > 0
+ reply.fail "Failed to run #{command}: #{res[:stderr]}", res[:exitstatus]
+ end
+ rescue Exception => e
+ Log.warn("Unhandled #{e.class} exception during #{request.agent}##{request.action}: #{e}")
+ reply.fail! "Unexpected failure calling #{command}: #{e.class}: #{e}"
+ end
- # Called just after a message was received from the middleware before
- # it gets passed to the handlers. @request and @reply will already be
- # set, the msg passed is the message as received from the normal
- # mcollective runner and the connection is the actual connector.
- def before_processing_hook(msg, connection)
- end
+ # Called at the end of the RPC::Agent standard initialize method
+ # use this to adjust meta parameters, timeouts and any setup you
+ # need to do.
+ #
+ # This will not be called right when the daemon starts up, we use
+ # lazy loading and initialization so it will only be called the first
+ # time a request for this agent arrives.
+ def startup_hook
+ end
- # Called at the end of processing just before the response gets sent
- # to the middleware.
- #
- # This gets run outside of the main exception handling block of the agent
- # so you should handle any exceptions you could raise yourself. The reason
- # it is outside of the block is so you'll have access to even status codes
- # set by the exception handlers. If you do raise an exception it will just
- # be passed onto the runner and processing will fail.
- def after_processing_hook
- end
+ # Called just after a message was received from the middleware before
+ # it gets passed to the handlers. @request and @reply will already be
+ # set, the msg passed is the message as received from the normal
+ # mcollective runner and the connection is the actual connector.
+ def before_processing_hook(msg, connection)
+ end
- # Gets called right after a request was received and calls audit plugins
- #
- # Agents can disable auditing by just overriding this method with a noop one
- # this might be useful for agents that gets a lot of requests or simply if you
- # do not care for the auditing in a specific agent.
- def audit_request(msg, connection)
- PluginManager["rpcaudit_plugin"].audit_request(msg, connection) if @config.rpcaudit
- rescue Exception => e
- Log.warn("Audit failed - #{e} - continuing to process message")
- end
- end
- end
+ # Called at the end of processing just before the response gets sent
+ # to the middleware.
+ #
+ # This gets run outside of the main exception handling block of the agent
+ # so you should handle any exceptions you could raise yourself. The reason
+ # it is outside of the block is so you'll have access to even status codes
+ # set by the exception handlers. If you do raise an exception it will just
+ # be passed onto the runner and processing will fail.
+ def after_processing_hook
end
- # vi:tabstop=4:expandtab:ai
+ # Gets called right after a request was received and calls audit plugins
+ #
+ # Agents can disable auditing by just overriding this method with a noop one
+ # this might be useful for agents that gets a lot of requests or simply if you
+ # do not care for the auditing in a specific agent.
+ def audit_request(msg, connection)
+ PluginManager["rpcaudit_plugin"].audit_request(msg, connection) if @config.rpcaudit
+ rescue Exception => e
+ Log.warn("Audit failed - #{e} - continuing to process message")
+ end
+ end
+ end
+end
View
1 lib/mcollective/rpc/audit.rb
@@ -36,4 +36,3 @@ def audit_request(request, connection)
end
end
end
-# vi:tabstop=4:expandtab:ai
View
1 lib/mcollective/rpc/client.rb
@@ -634,4 +634,3 @@ def process_results_with_block(action, resp, block)
end
end
end
-# vi:tabstop=4:expandtab:ai
View
2 lib/mcollective/rpc/ddl.rb
@@ -242,5 +242,3 @@ def validate_request(action, arguments)
end
end
end
-
-# vi:tabstop=4:expandtab:ai
View
2 lib/mcollective/rpc/progress.rb
@@ -61,5 +61,3 @@ def twirl(current, total)
end
end
end
-
-# vi:tabstop=4:expandtab:ai
View
1 lib/mcollective/rpc/reply.rb
@@ -59,4 +59,3 @@ def to_hash
end
end
end
-# vi:tabstop=4:expandtab:ai
View
1 lib/mcollective/rpc/request.rb
@@ -49,4 +49,3 @@ def to_json
end
end
end
-# vi:tabstop=4:expandtab:ai
View
1 lib/mcollective/rpc/result.rb
@@ -39,4 +39,3 @@ def to_json(*a)
end
end
end
-# vi:tabstop=4:expandtab:ai
View
2 lib/mcollective/rpc/stats.rb
@@ -183,5 +183,3 @@ def no_response_report
end
end
end
-
-# vi:tabstop=4:expandtab:ai
View
1 lib/mcollective/runner.rb
@@ -140,4 +140,3 @@ def reply(msg, request)
end
end
-# vi:tabstop=4:expandtab:ai
View
1 lib/mcollective/security.rb
@@ -24,4 +24,3 @@ module Security
autoload :Base, "mcollective/security/base"
end
end
-# vi:tabstop=4:expandtab:ai
View
1 lib/mcollective/security/base.rb
@@ -209,4 +209,3 @@ def decodemsg(msg)
end
end
end
-# vi:tabstop=4:expandtab:ai
View
2 lib/mcollective/util.rb
@@ -254,5 +254,3 @@ def self.eval_compound_statement(expression)
end
end
end
-
-# vi:tabstop=4:expandtab:ai
View
2 mc-call-agent
@@ -52,5 +52,3 @@ rescue Exception => e
end
client.display_stats(stats)
-
-# vi:tabstop=4:expandtab:ai
View
3 mcollectived.rb
@@ -41,6 +41,7 @@
if config.daemonize
MCollective::Log.debug("Starting in the background (#{config.daemonize})")
+
MCollective::Runner.daemonize do
if pid
begin
@@ -57,5 +58,3 @@
runner = MCollective::Runner.new(configfile)
runner.run
end
-
-# vi:tabstop=4:expandtab:ai
View
2 plugins/mcollective/agent/discovery.rb
@@ -86,5 +86,3 @@ def inventory
end
end
end
-
-# vi:tabstop=4:expandtab:ai:filetype=ruby
View
1 plugins/mcollective/audit/logfile.rb
@@ -23,4 +23,3 @@ def audit_request(request, connection)
end
end
end
-# vi:tabstop=4:expandtab:ai
View
2 plugins/mcollective/connector/stomp.rb
@@ -303,5 +303,3 @@ def make_target(agent, type, collective, target_node=nil)
end
end
end
-
-# vi:tabstop=4:expandtab:ai
View
1 plugins/mcollective/facts/yaml_facts.rb
@@ -59,4 +59,3 @@ def force_reload?
end
end
end
-# vi:tabstop=4:expandtab:ai
View
1 plugins/mcollective/registration/agentlist.rb
@@ -8,4 +8,3 @@ def body
end
end
end
-# vi:tabstop=4:expandtab:ai
View
1 plugins/mcollective/security/psk.rb
@@ -111,4 +111,3 @@ def makehash(body)
end
end
end
-# vi:tabstop=4:expandtab:ai
View
2 plugins/mcollective/security/ssl.rb
@@ -328,5 +328,3 @@ def request_description(msg)
end
end
end
-#
-# vi:tabstop=4:expandtab:ai

0 comments on commit 2c20b69

Please sign in to comment.