Class: Cheftacular::Auditor
- Inherits:
-
Object
- Object
- Cheftacular::Auditor
- Defined in:
- lib/cheftacular/auditor.rb
Instance Method Summary collapse
- #audit_run ⇒ Object
- #fetch_audit_data_hash(ret_hash = {}, ip = "") ⇒ Object
-
#initialize(options, config) ⇒ Auditor
constructor
A new instance of Auditor.
- #read_audit_cache_file_to_hash(ret_hash = {}) ⇒ Object
- #write_audit_cache_file ⇒ Object
Constructor Details
#initialize(options, config) ⇒ Auditor
Returns a new instance of Auditor.
4 5 6 |
# File 'lib/cheftacular/auditor.rb', line 4 def initialize , config , @config = , config end |
Instance Method Details
#audit_run ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/cheftacular/auditor.rb', line 8 def audit_run current_day = Time.now.strftime('%Y%m%d') current_time = Time.now.strftime('%H:%M') @config[['env']]['audit_bag_hash']['audit_log'][current_day] ||= {} @config[['env']]['audit_bag_hash']['audit_log'][current_day][current_time] ||= [] @config[['env']]['audit_bag_hash']['audit_log'][current_day][current_time] << read_audit_cache_file_to_hash @config['ChefDataBag'].save_audit_bag end |
#fetch_audit_data_hash(ret_hash = {}, ip = "") ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/cheftacular/auditor.rb', line 32 def fetch_audit_data_hash ret_hash={}, ip="" ret_hash['hostname'] = Socket.gethostname ret_hash rescue StandardError => exception @config['helper'].cleanup_file_caches('current-audit-only') @config['helper'].exception_output "Unable to finish parsing auditing hash", exception end |
#read_audit_cache_file_to_hash(ret_hash = {}) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/cheftacular/auditor.rb', line 23 def read_audit_cache_file_to_hash ret_hash={} ret_hash = Hash.class_eval( File.read( @config['helper'].current_audit_file_path )) ret_hash['command'] = ['command'] ret_hash['options'] = .except(:preferred_cloud, :preferred_cloud_region, :preferred_cloud_image) #TODO load preferred_X options if they are not the default? ret_hash['arguments'] = ARGV[1..ARGV.length] ret_hash end |
#write_audit_cache_file ⇒ Object
19 20 21 |
# File 'lib/cheftacular/auditor.rb', line 19 def write_audit_cache_file File.open( @config['helper'].current_audit_file_path, "w") { |f| f.write( fetch_audit_data_hash ) } end |