foreman_maintain 0.7.7 → 0.7.8

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
  SHA256:
3
- metadata.gz: 2730a865433069746a18277ed6e484f907ee072cbed797a23cb24b079efeca9c
4
- data.tar.gz: 8801e1447e2da1fb1aa170747e6cdc709aa5ea3280b2094fcf408e0cdc224488
3
+ metadata.gz: ae46ef9452f9bbb61d9f453a1d3aba399aa39aad83c8340ba2ba7129196eb6ec
4
+ data.tar.gz: daae5660ce5a676c230b6ef4360e7341f3fdb5d82ce46cc53a0ac3596926ab94
5
5
  SHA512:
6
- metadata.gz: e3029fe3bc2144203923d9486bdbbb5d8be88babb17516af46c29a81f5faad416b5a1a0468ef9b0c3f8a998c93efddc793d0eb65a882f1c866c77d1ed19359de
7
- data.tar.gz: 8a9f559d07c20a301ebbb3816fa42c49101ee0a4af5cbf7c1123753dc57c9053d86f28ed79862a1f77851c6b9b894c85b03ac72dde63121d53a1228a982f8183
6
+ metadata.gz: 62d82ea9a9d4ece0797e5872b8b0a551940864965416b23f3dfa7a7b054c68b8cd684d76f2cfd85532d6c744ab9f88942b03a8282a43aac96ae2282cb2a715ec
7
+ data.tar.gz: 00f495d544d54df325d9e0541a0b206dab5fbd2a2f5930e5d17eb86173d450e92926cc41c74379fda20a878ed634c8e473abfaf440d0034ae6c0c44e50c88fe5
@@ -62,58 +62,48 @@ class Features::Service < ForemanMaintain::Feature
62
62
  status = 0
63
63
  failed_services = []
64
64
  filtered_services(options).each_value do |group|
65
- systemctl_status, _output = execute_with_status('systemctl ' \
66
- "#{action} #{group.map(&:name).join(' ')}")
67
- display_status(group, options, action, spinner)
68
- if systemctl_status > 0
69
- status = systemctl_status
70
- failed_services |= failed_services_by_status(action, group, spinner)
65
+ fork_threads_for_services(action, group, spinner).each do |service, status_and_output|
66
+ spinner.update("#{action_noun(action)} #{service}") if action == 'status'
67
+ item_status, output = status_and_output
68
+ formatted = format_status(output, item_status, options)
69
+ puts formatted unless formatted.empty?
70
+
71
+ if item_status > 0
72
+ status = item_status
73
+ failed_services << service
74
+ end
71
75
  end
72
76
  end
73
77
  [status, failed_services]
74
78
  end
75
79
 
76
- def display_status(services, options, action, spinner)
80
+ def fork_threads_for_services(action, services, spinner)
81
+ services_and_statuses = []
77
82
  services.each do |service|
78
- spinner.update("#{action_noun(action)} #{service}")
79
- formatted = format_status(service.status, options, action)
80
- puts formatted unless formatted.empty?
83
+ spinner.update("#{action_noun(action)} #{service}") if action != 'status'
84
+ services_and_statuses << [service, Thread.new { service.send(action.to_sym) }]
81
85
  end
86
+ services_and_statuses.map! { |service, status| [service, status.value] }
82
87
  end
83
88
 
84
- def format_status(service_status, options, action)
85
- exit_code, output = service_status
89
+ def format_status(output, exit_code, options)
86
90
  status = ''
87
91
  if !options[:failing] || exit_code > 0
88
92
  if options[:brief]
89
93
  status += format_brief_status(exit_code)
90
- elsif include_output?(action, exit_code)
94
+ elsif !(output.nil? || output.empty?)
91
95
  status += "\n" + output
92
96
  end
93
97
  end
94
98
  status
95
99
  end
96
100
 
97
- def include_output?(action, status)
98
- (action == 'start' && status > 0) ||
99
- action == 'status'
100
- end
101
-
102
101
  def format_brief_status(exit_code)
103
102
  result = exit_code == 0 ? reporter.status_label(:success) : reporter.status_label(:fail)
104
103
  padding = reporter.max_length - reporter.last_line.to_s.length - 30
105
104
  "#{' ' * padding} #{result}"
106
105
  end
107
106
 
108
- def failed_services_by_status(action, services, spinner)
109
- failed_services = []
110
- services.each do |service|
111
- spinner.update("#{action_noun(action)} #{service}")
112
- failed_services << service unless service.running?
113
- end
114
- failed_services
115
- end
116
-
117
107
  def allowed_action?(action)
118
108
  %w[start stop restart status enable disable].include?(action)
119
109
  end
@@ -1,6 +1,23 @@
1
1
  module ForemanMaintain::Scenarios
2
2
  module Content
3
- class Prepare < ForemanMaintain::Scenario
3
+ class ContentBase < ForemanMaintain::Scenario
4
+ def enable_and_start_services
5
+ add_step(Procedures::Service::Start)
6
+ add_step(Procedures::Service::Enable.
7
+ new(:only => Features::Pulpcore.pulpcore_migration_services))
8
+ add_step(Procedures::Service::Start.
9
+ new(:only => Features::Pulpcore.pulpcore_migration_services))
10
+ end
11
+
12
+ def disable_and_stop_services
13
+ add_step(Procedures::Service::Stop.
14
+ new(:only => Features::Pulpcore.pulpcore_migration_services))
15
+ add_step(Procedures::Service::Disable.
16
+ new(:only => Features::Pulpcore.pulpcore_migration_services))
17
+ end
18
+ end
19
+
20
+ class Prepare < ContentBase
4
21
  metadata do
5
22
  label :content_prepare
6
23
  description 'Prepare content for Pulp 3'
@@ -16,26 +33,9 @@ module ForemanMaintain::Scenarios
16
33
  add_step(Procedures::Content::Prepare)
17
34
  end
18
35
  end
19
-
20
- private
21
-
22
- def enable_and_start_services
23
- add_step(Procedures::Service::Start)
24
- add_step(Procedures::Service::Enable.
25
- new(:only => Features::Pulpcore.pulpcore_migration_services))
26
- add_step(Procedures::Service::Start.
27
- new(:only => Features::Pulpcore.pulpcore_migration_services))
28
- end
29
-
30
- def disable_and_stop_services
31
- add_step(Procedures::Service::Stop.
32
- new(:only => Features::Pulpcore.pulpcore_migration_services))
33
- add_step(Procedures::Service::Disable.
34
- new(:only => Features::Pulpcore.pulpcore_migration_services))
35
- end
36
36
  end
37
37
 
38
- class Switchover < ForemanMaintain::Scenario
38
+ class Switchover < ContentBase
39
39
  metadata do
40
40
  label :content_switchover
41
41
  description 'Switch support for certain content from Pulp 2 to Pulp 3'
@@ -51,7 +51,7 @@ module ForemanMaintain::Scenarios
51
51
  end
52
52
  end
53
53
 
54
- class PrepareAbort < ForemanMaintain::Scenario
54
+ class PrepareAbort < ContentBase
55
55
  metadata do
56
56
  label :content_prepare_abort
57
57
  description 'Abort all running Pulp 2 to Pulp 3 migration tasks'
@@ -65,7 +65,7 @@ module ForemanMaintain::Scenarios
65
65
  end
66
66
  end
67
67
 
68
- class MigrationStats < ForemanMaintain::Scenario
68
+ class MigrationStats < ContentBase
69
69
  metadata do
70
70
  label :content_migration_stats
71
71
  description 'Retrieve Pulp 2 to Pulp 3 migration statistics'
@@ -79,7 +79,7 @@ module ForemanMaintain::Scenarios
79
79
  end
80
80
  end
81
81
 
82
- class MigrationReset < ForemanMaintain::Scenario
82
+ class MigrationReset < ContentBase
83
83
  metadata do
84
84
  label :content_migration_reset
85
85
  description 'Reset the Pulp 2 to Pulp 3 migration data (pre-switchover)'
@@ -97,7 +97,7 @@ module ForemanMaintain::Scenarios
97
97
  end
98
98
  end
99
99
 
100
- class RemovePulp2 < ForemanMaintain::Scenario
100
+ class RemovePulp2 < ContentBase
101
101
  metadata do
102
102
  label :content_remove_pulp2
103
103
  description 'Remove Pulp2 and mongodb packages and data'
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '0.7.7'.freeze
2
+ VERSION = '0.7.8'.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.7.7
4
+ version: 0.7.8
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-03-08 00:00:00.000000000 Z
11
+ date: 2021-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -418,7 +418,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
418
418
  - !ruby/object:Gem::Version
419
419
  version: '0'
420
420
  requirements: []
421
- rubygems_version: 3.0.8
421
+ rubygems_version: 3.2.3
422
422
  signing_key:
423
423
  specification_version: 4
424
424
  summary: Foreman maintenance tool belt