foreman_maintain 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4153054fabffdccbe07a9eed2689b4352077c3c4be62b92042dc20c885677a76
4
- data.tar.gz: 68d332ebb071f25e585c0e866b0a85fa7efccd3820640452afcd06f5910860cc
3
+ metadata.gz: ca55a94ef08b62455d53810a1c240a4b7575b4633d91cf7bbcaa1f63c18911a5
4
+ data.tar.gz: 8d344101f80d7317b1bffecfdd1919f651d011f90b5a06da60cb421d0e9a9775
5
5
  SHA512:
6
- metadata.gz: e431d1063f9b866d5300cc8de0a07d72c4b6542c8e974c3bec906e77bab465d54b8b68285d2c85ad12453a28fe4a7e20fd9d3ad01cb4493c65f2930418d1c58f
7
- data.tar.gz: d39d2fcaaa8b0e90ac9fefd56e66bdc30e695078e853e3006d79c1204d90b08c4a39f41196bbf55888c47a995be9e276e6dd8b84016e85ced883c8d91655ffa8
6
+ metadata.gz: 59a0b6977fc0888606b0e6d25cfc2c7172c462059e34dc68a0cbef32b13feae33d7a5d77ccac9e1f6adaa469b187fbec83253fd110464e1e8dc0f3133637f7d2
7
+ data.tar.gz: e36d9de3b3a022e7dfd312ae3b70df24a75ba1fb17b9ad7dee640b89571a1b3a2e1372380e00209671520435c475418c597cbd5443943871d9cb27351341faf7
@@ -34,10 +34,22 @@ class Features::Pulpcore < ForemanMaintain::Feature
34
34
  end
35
35
 
36
36
  def self.pulpcore_common_services
37
- [
37
+ common_services = [
38
38
  ForemanMaintain::Utils.system_service('pulpcore-api', 10, :socket => 'pulpcore-api'),
39
- ForemanMaintain::Utils.system_service('pulpcore-content', 10, :socket => 'pulpcore-content'),
40
- ForemanMaintain::Utils.system_service('pulpcore-resource-manager', 10)
39
+ ForemanMaintain::Utils.system_service('pulpcore-content', 10, :socket => 'pulpcore-content')
41
40
  ]
41
+ common_services + pulpcore_resource_manager_service
42
+ end
43
+
44
+ def pulpcore_resource_manager_service
45
+ # The pulpcore_resource_manager is only required on 3.14+
46
+ # if the old tasking system is being used
47
+ # The foreman-installer does not create unit file for this service,
48
+ # if the new tasking system is being used
49
+ if feature(:service).unit_file_available?('pulpcore-resource-manager.service')
50
+ return [ForemanMaintain::Utils.system_service('pulpcore-resource-manager', 10)]
51
+ end
52
+
53
+ []
42
54
  end
43
55
  end
@@ -50,6 +50,13 @@ class Features::Service < ForemanMaintain::Feature
50
50
  service_list
51
51
  end
52
52
 
53
+ def unit_file_available?(name)
54
+ cmd = "systemctl --no-legend --no-pager list-unit-files --type=service #{name} |\
55
+ grep --word-regexp --quiet #{name}"
56
+ exit_status, = execute_with_status(cmd)
57
+ exit_status == 0
58
+ end
59
+
53
60
  private
54
61
 
55
62
  def use_system_service(action, options, spinner)
@@ -153,7 +153,7 @@ module ForemanMaintain
153
153
  end
154
154
 
155
155
  # rubocop:disable Metrics/MethodLength
156
- def self.interactive_option(opts = %w[assumeyes whitelist force])
156
+ def self.interactive_option(opts = %w[assumeyes whitelist force plaintext])
157
157
  delete_duplicate_assumeyes_if_any
158
158
 
159
159
  if opts.include?('assumeyes')
@@ -175,6 +175,13 @@ module ForemanMaintain
175
175
  option ['-f', '--force'], :flag,
176
176
  'Force steps that would be skipped as they were already run'
177
177
  end
178
+
179
+ if opts.include?('plaintext')
180
+ option(['--plaintext'], :flag,
181
+ 'Print the output in plaintext and disable the spinner') do |plaintext|
182
+ ForemanMaintain.reporter.plaintext = plaintext
183
+ end
184
+ end
178
185
  end
179
186
  # rubocop:enable Metrics/MethodLength
180
187
 
@@ -46,6 +46,10 @@ module ForemanMaintain
46
46
  @assumeyes
47
47
  end
48
48
 
49
+ def plaintext?
50
+ @plaintext
51
+ end
52
+
49
53
  # simple yes/no question, returns :yes, :no or :quit
50
54
  # rubocop:disable Metrics/LineLength
51
55
  def ask_decision(message, actions_msg: 'y(yes), n(no), q(quit)', assumeyes: assumeyes?, run_strategy: :fail_fast)
@@ -65,6 +69,10 @@ module ForemanMaintain
65
69
  @assumeyes = !!assume
66
70
  end
67
71
 
72
+ def plaintext=(plaintext)
73
+ @plaintext = !!plaintext
74
+ end
75
+
68
76
  private
69
77
 
70
78
  def single_step_decision(step, run_strategy)
@@ -30,7 +30,7 @@ module ForemanMaintain
30
30
  end
31
31
 
32
32
  def activate
33
- @mutex.synchronize { @active = true }
33
+ @mutex.synchronize { @active = true } unless @reporter.plaintext?
34
34
  spin
35
35
  end
36
36
 
@@ -62,8 +62,11 @@ module ForemanMaintain
62
62
 
63
63
  def print_current_line
64
64
  @reporter.clear_line
65
- line = "#{@spinner_chars[@spinner_index]} #{@current_line}"
66
- @reporter.print(line)
65
+ if @reporter.plaintext?
66
+ @reporter.print(@current_line.to_s)
67
+ else
68
+ @reporter.print("#{@spinner_chars[@spinner_index]} #{@current_line}")
69
+ end
67
70
  end
68
71
  end
69
72
 
@@ -75,6 +78,7 @@ module ForemanMaintain
75
78
  @stdin = stdin
76
79
  options.validate_options!(:assumeyes)
77
80
  @assumeyes = options.fetch(:assumeyes, false)
81
+ @plaintext = options.fetch(:plaintext, false)
78
82
  @hl = HighLine.new(@stdin, @stdout)
79
83
  @max_length = 80
80
84
  @line_char = '-'
@@ -162,7 +166,11 @@ module ForemanMaintain
162
166
  end
163
167
 
164
168
  def clear_line
165
- print "\r" + ' ' * @max_length + "\r"
169
+ if plaintext?
170
+ print "\n"
171
+ else
172
+ print "\r" + ' ' * @max_length + "\r"
173
+ end
166
174
  end
167
175
 
168
176
  def assumeyes?
@@ -271,7 +279,11 @@ module ForemanMaintain
271
279
  :already_run => { :label => '[ALREADY RUN]', :color => :yellow },
272
280
  :warning => { :label => '[WARNING]', :color => :yellow } }
273
281
  properties = mapping[status]
274
- @hl.color(properties[:label], properties[:color], :bold)
282
+ if @plaintext
283
+ properties[:label]
284
+ else
285
+ @hl.color(properties[:label], properties[:color], :bold)
286
+ end
275
287
  end
276
288
 
277
289
  def hline(line_char = @line_char)
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '0.8.3'.freeze
2
+ VERSION = '0.8.4'.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.8.3
4
+ version: 0.8.4
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: 2021-07-06 00:00:00.000000000 Z
11
+ date: 2021-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp