foreman_maintain 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6541f1ff74d6b4f49f684fdf4a90169407fff41c
4
- data.tar.gz: 0de3f21c5ec4b3f20da234dd4ab6de64914e1da4
3
+ metadata.gz: 18fd98c7a843565d1557576d646eed3836b4531d
4
+ data.tar.gz: 28bf7c63c9992e72d14cc6341aafa4ec77245721
5
5
  SHA512:
6
- metadata.gz: c728131aed58b4939b2d8b2e1d4c0df2adfa192a28523643072ee16a1348f9136feb178987bd4a230ffc123adad54298be86697b6a657956c6c970c49313bb25
7
- data.tar.gz: 643d48edb17bd4d7dafc84fd0a80b0404152c9ee77b834b88a4d10c960c107fe5b71bdb2da5a0801552d4cc31017bbe870f55c7b0b1f4154e79a62e2c7dd6ede
6
+ metadata.gz: a208375098dcdd9afa2cfe24f0be922933e28b979133f4bf5af5a7f09c54dcb8718f4029bb65bf0982fdffa16b2f644917b0039ba6e3eee274fdad53b90a2d6b
7
+ data.tar.gz: 8fdd5953b332088338c2b624016b57713733de79a90f1ef88bed936abf1d772ac15458fd7e1949351ccd00fc827b36b432aa523c2c27c282974462e86782e4d9
data/README.md CHANGED
@@ -227,7 +227,7 @@ class Procedures::InstallPackage < ForemanMaintain::Procedure
227
227
  end
228
228
 
229
229
  def run
230
- install_packages(@packages)
230
+ packages_action(:install, @packages)
231
231
  end
232
232
 
233
233
  # if false, the step will be considered as done: it will not be executed
@@ -16,6 +16,7 @@ class Features::ForemanTasks < ForemanMaintain::Feature
16
16
  EXCLUDE_ACTIONS_FOR_RUNNING_TASKS = %w[
17
17
  Actions::Candlepin::ListenOnCandlepinEvents
18
18
  Actions::Katello::EventQueue::Monitor
19
+ Actions::Insights::EmailPoller
19
20
  ].freeze
20
21
 
21
22
  metadata do
@@ -6,7 +6,9 @@ module Procedures::Packages
6
6
  end
7
7
 
8
8
  def run
9
- packages_action(:update, @packages, :assumeyes => @assumeyes.nil? ? assumeyes? : @assumeyes)
9
+ assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
10
+ clean_all_packages(:assumeyes => assumeyes_val)
11
+ packages_action(:update, @packages, :assumeyes => assumeyes_val)
10
12
  end
11
13
 
12
14
  def necessary?
@@ -29,6 +29,10 @@ module ForemanMaintain
29
29
  detector.available_scenarios(conditions)
30
30
  end
31
31
 
32
+ def find_all_scenarios(conditions)
33
+ detector.all_scenarios(conditions)
34
+ end
35
+
32
36
  private
33
37
 
34
38
  def ensure_one_object(object_type, label_or_class)
@@ -76,13 +76,6 @@ module ForemanMaintain
76
76
  execute('hostname -f')
77
77
  end
78
78
 
79
- def install_packages(packages, options = {})
80
- options.validate_options!(:assumeyes)
81
- yum_options = []
82
- yum_options << '-y' if options[:assumeyes]
83
- execute!("yum #{yum_options.join(' ')} install #{packages.join(' ')}", :interactive => true)
84
- end
85
-
86
79
  def server?
87
80
  find_package('foreman')
88
81
  end
@@ -103,6 +96,15 @@ module ForemanMaintain
103
96
  :interactive => true)
104
97
  end
105
98
 
99
+ def clean_all_packages(options = {})
100
+ options.validate_options!(:assumeyes)
101
+ yum_options = []
102
+ yum_options << '-y' if options[:assumeyes]
103
+ execute!("yum #{yum_options.join(' ')} clean all", :interactive => true)
104
+ execute!('rm -rf /var/cache/yum')
105
+ execute!('rm -rf /var/cache/dnf')
106
+ end
107
+
106
108
  def package_version(name)
107
109
  # space for extension to support non-rpm distributions
108
110
  rpm_version(name)
@@ -52,8 +52,8 @@ module ForemanMaintain
52
52
  begin
53
53
  FileUtils.mkdir_p(dir_path, :mode => 0o750) unless File.exist?(dir_path)
54
54
  rescue StandardError => e
55
- $stderr.puts "No permissions to create dir #{dir_path_str}"
56
- $stderr.puts e.message.inspect
55
+ warn "No permissions to create dir #{dir_path_str}"
56
+ warn e.message.inspect
57
57
  end
58
58
  dir_path
59
59
  end
@@ -24,6 +24,7 @@ module ForemanMaintain
24
24
  @all_features_scanned = false
25
25
  @available_checks = nil
26
26
  @available_scenarios = nil
27
+ @scenarios ||= Scenario.all_sub_classes.select(&:autodetect?)
27
28
  end
28
29
 
29
30
  def available_features(filter_conditions = nil)
@@ -57,8 +58,7 @@ module ForemanMaintain
57
58
  def available_scenarios(filter_conditions = nil)
58
59
  unless @available_scenarios
59
60
  ensure_features_detected
60
- @available_scenarios = Scenario.all_sub_classes.select(&:autodetect?).
61
- select(&:present?).map(&:new)
61
+ @available_scenarios = @scenarios.select(&:present?).map(&:new)
62
62
  end
63
63
  filter(@available_scenarios, filter_conditions)
64
64
  end
@@ -73,6 +73,10 @@ module ForemanMaintain
73
73
  @all_features_scanned = true
74
74
  end
75
75
 
76
+ def all_scenarios(filter_conditions = nil)
77
+ filter(@scenarios.map(&:new), filter_conditions)
78
+ end
79
+
76
80
  private
77
81
 
78
82
  def sort(collection)
@@ -72,7 +72,7 @@ module ForemanMaintain
72
72
  raise Error::Warn, message
73
73
  end
74
74
 
75
- # rubocop:disable Style/AccessorMethodName
75
+ # rubocop:disable Naming/AccessorMethodName
76
76
  def set_fail(message)
77
77
  execution.status = :fail
78
78
  execution.output << message
@@ -158,7 +158,7 @@ module ForemanMaintain
158
158
  end
159
159
 
160
160
  def self.new_from_hash(hash)
161
- scenarios = find_scenarios(:label => hash[:label])
161
+ scenarios = find_all_scenarios(:label => hash[:label])
162
162
  unless scenarios.size == 1
163
163
  raise "Could not find scenario #{hash[:label]}, found #{scenarios.size} scenarios"
164
164
  end
@@ -67,7 +67,7 @@ module ForemanMaintain
67
67
  def scenario(phase)
68
68
  return @scenario_cache[phase] if @scenario_cache.key?(phase)
69
69
  condition = { :tags => [tag, phase] }
70
- matching_scenarios = find_scenarios(condition)
70
+ matching_scenarios = find_all_scenarios(condition)
71
71
  raise "Too many scenarios match #{condition.inspect}" if matching_scenarios.size > 1
72
72
  @scenario_cache[phase] = matching_scenarios.first
73
73
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '0.0.10'.freeze
2
+ VERSION = '0.0.11'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_maintain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-18 00:00:00.000000000 Z
11
+ date: 2017-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -53,21 +53,21 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "<"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 11.0.0
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "<"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 11.0.0
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: minitest
70
+ name: mocha
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,19 +81,19 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: mocha
84
+ name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "<"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 11.0.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "<"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 11.0.0
97
97
  description: Provides various features that helps keeping the Foreman/Satellite up
98
98
  and running.
99
99
  email: inecas@redhat.com