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



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

def self.included(includer)
  includer.class_eval do
    deps do
      require_relative "../tidy_server"
      require_relative "../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



70
71
72
73
74
# File 'lib/chef/knife/tidy_base.rb', line 70

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



62
63
64
# File 'lib/chef/knife/tidy_base.rb', line 62

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

#completion_messageObject



58
59
60
# File 'lib/chef/knife/tidy_base.rb', line 58

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

#restObject



46
47
48
# File 'lib/chef/knife/tidy_base.rb', line 46

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

#serverObject



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

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



66
67
68
# File 'lib/chef/knife/tidy_base.rb', line 66

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

#tidyObject



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

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