Class: Chef::Provider::HouseKeeping

Inherits:
Chef::Provider show all
Includes:
Garcon
Defined in:
lib/garcon/chef/provider/house_keeping.rb

Defined Under Namespace

Classes: Humanize, PurgeFlushBinge

Constant Summary

Constants included from Garcon

Garcon::VERSION

Instance Method Summary collapse

Methods included from Garcon

auto_terminate_all_executors?, auto_terminate_global_executors?, coercer, coercer=, config, configuration, crypto, crypto=, disable_auto_termination_of_all_executors!, disable_auto_termination_of_global_executors!, global_fast_executor, global_io_executor, global_timer_set, included, #inspect, kill_global_executors, monotonic_time, new_fast_executor, new_io_executor, physical_processor_count, processor_count, secret, secret=, shutdown_global_executors, #terminal_dimensions, timer, #to_s, wait_for_global_executors_termination, warn

Instance Method Details

#action_purge(r = new_resource) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/garcon/chef/provider/house_keeping.rb', line 92

def action_purge(r = new_resource)
  if @current_resource.num_files > 1
    path  = r.path
    age   = r.age
    size  = r.size
    dsize = r.directory_size
    num   = @current_resource.num_files
    purge = {}
    purge.merge!(@current_resource.older_than(age))    unless age.nil?
    purge.merge!(@current_resource.larger_than(size))  unless size.nil?
    purge.merge!(@current_resource.to_dir_size(dsize)) unless dsize.nil?
    num_purged = purge.length

    converge_by "Processed #{num} files from #{path}, " \
                "#{num_purged} purged" do
      if purge.length > 1
        purge.each do |file, data|
          file file do
            force_unlink          r.force_unlink
            manage_symlink_source r.manage_symlink_source
            backup  false
            action :delete
          end
        end
        r.updated_by_last_action(true)
      end
    end
  end
end

#load_current_resource(r = new_resource) ⇒ Chef::Provider::HouseKeeping

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Load and return the current resource



86
87
88
89
90
# File 'lib/garcon/chef/provider/house_keeping.rb', line 86

def load_current_resource(r = new_resource)
  @current_resource ||= PurgeFlushBinge.new(r)
  @current_resource.exclude(r.exclude) if r.exclude
  @current_resource
end

#whyrun_supported?TrueClass, FalseClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Boolean indicating if WhyRun is supported by this provider

Returns:



77
78
79
# File 'lib/garcon/chef/provider/house_keeping.rb', line 77

def whyrun_supported?
  true
end