Module: Chef::Knife::TidyBase

Included in:
TidyBackupClean, TidyNotify, TidyServerClean, TidyServerReport
Defined in:
lib/chef/knife/tidy_base.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(includer) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/chef/knife/tidy_base.rb', line 25

def self.included(includer)
  includer.class_eval do

    deps do
      require 'chef/tidy_server'
      require 'chef/tidy_common'
    end

    option :org_list,
      :long => "--orgs ORG1,ORG2",
      :description => "Only apply to objects in the named organizations"
    end
end

Instance Method Details

#action_needed(msg, file_path = action_needed_file_path) ⇒ Object



72
73
74
75
76
# File 'lib/chef/knife/tidy_base.rb', line 72

def action_needed(msg, file_path=action_needed_file_path)
  ::File.open(file_path, 'a') do |f|
    f.write(msg + "\n")
  end
end

#action_needed_file_pathObject



64
65
66
# File 'lib/chef/knife/tidy_base.rb', line 64

def action_needed_file_path
  ::File.expand_path('knife-tidy-actions-needed.txt')
end

#completion_messageObject



60
61
62
# File 'lib/chef/knife/tidy_base.rb', line 60

def completion_message
  ui.stdout.puts "#{ui.color("** Finished **", :magenta)}"
end

#restObject



48
49
50
# File 'lib/chef/knife/tidy_base.rb', line 48

def rest
  @rest ||= Chef::ServerAPI.new(server.root_url, keepalives: true)
end

#serverObject



39
40
41
42
43
44
45
46
# File 'lib/chef/knife/tidy_base.rb', line 39

def server
  @server ||= if Chef::Config.chef_server_root.nil?
                ui.warn("chef_server_root not found in knife configuration; using chef_server_url")
                Chef::TidyServer.from_chef_server_url(Chef::Config.chef_server_url)
              else
                Chef::TidyServer.new(Chef::Config.chef_server_root)
              end
end

#server_warnings_file_pathObject



68
69
70
# File 'lib/chef/knife/tidy_base.rb', line 68

def server_warnings_file_path
  ::File.expand_path('reports/knife-tidy-server-warnings.txt')
end

#tidyObject



52
53
54
55
56
57
58
# File 'lib/chef/knife/tidy_base.rb', line 52

def tidy
  @tidy ||= if config[:backup_path].nil?
              Chef::TidyCommon.new
            else
              Chef::TidyCommon.new(config[:backup_path])
            end
end