Added mcollective 2.3.1 package
[packages/trusty/mcollective.git] / lib / mcollective / rpc / audit.rb
1 module MCollective
2   module RPC
3     # Auditing of requests is done only for SimpleRPC requests, you provide
4     # a plugin in the MCollective::Audit::* namespace which the SimpleRPC
5     # framework calls for each message
6     #
7     # We provide a simple one that logs to a logfile in the class
8     # MCollective::Audit::Logfile you can create your own:
9     #
10     # Create a class in plugins/mcollective/audit/<yourplugin>.rb
11     #
12     # You must inherit from MCollective::RPC::Audit which will take
13     # care of registering you with the plugin system.
14     #
15     # Your plugin must provide audit_request(request, connection)
16     # the request parameter will be an instance of MCollective::RPC::Request
17     #
18     # To enable auditing you should set:
19     #
20     # rpcaudit = 1
21     # rpcauditprovider = Logfile
22     #
23     # in the config file this will enable logging using the
24     # MCollective::Audit::Logile class
25     #
26     # The Audit class acts as a base for audit plugins and takes care of registering them
27     # with the plugin manager
28     class Audit
29       def self.inherited(klass)
30         PluginManager << {:type => "rpcaudit_plugin", :class => klass.to_s}
31       end
32
33       def audit_request(request, connection)
34         @log.error("audit_request is not implimented in #{this.class}")
35       end
36     end
37   end
38 end