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 = {}, options_to_ignore = []) ⇒ Object
- #write_audit_cache_file ⇒ Object
Constructor Details
#initialize(options, config) ⇒ 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
40 41 42 43 44 45 46 47 48 |
# File 'lib/cheftacular/auditor.rb', line 40 def fetch_audit_data_hash ret_hash={}, ip="" ret_hash['hostname'] = Socket.gethostname ret_hash rescue StandardError => exception @config['filesystem'].cleanup_file_caches('current-audit-only') @config['error'].exception_output "Unable to finish parsing auditing hash", exception end |
#read_audit_cache_file_to_hash(ret_hash = {}, options_to_ignore = []) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cheftacular/auditor.rb', line 23 def read_audit_cache_file_to_hash ret_hash={}, =[] ret_hash = Hash.class_eval( File.read( @config['filesystem'].current_audit_file_path )) ret_hash['command'] = ['command'] << :preferred_cloud if ['preferred_cloud'] == @config['cheftacular']['preferred_cloud'] << :preferred_cloud_image if ['preferred_cloud_image'] == @config['cheftacular']['preferred_cloud_image'] << :preferred_cloud_region if ['preferred_cloud_region'] == @config['cheftacular']['preferred_cloud_region'] << :virtualization_mode if ['virtualization_mode'] == @config['cheftacular']['virtualization_mode'] << :route_dns_changes_via if ['route_dns_changes_via'] == @config['cheftacular']['route_dns_changes_via'] ret_hash['options'] = .dup.delete_if { |key, value| .include?(key.to_sym) } 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['filesystem'].current_audit_file_path, "w") { |f| f.write( fetch_audit_data_hash ) } end |