foreman_maintain 1.0.9 → 1.1.1

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: d333d2c850308e6bf590acee0dfd55d4b257cdebebb7b148e4ef49fe48f001dd
4
- data.tar.gz: eac9b73a13ff0f7829ddf0cea8380491884d6631e3d42ca42b9b88e76bbd4698
3
+ metadata.gz: 38a7ae9f24c88731e052acb62c13b25d29074a07ad852daa258bed6322c1d22d
4
+ data.tar.gz: e0420aa7dc1935c61ef479aed3a43069281797ca41f131048902c727676c6634
5
5
  SHA512:
6
- metadata.gz: 8f402842dfca9d32804e9825f9a7552c2eac13e81244b80436d46b51a79e8330ce208fcf91c9bf0d5d0bafd3b46ea868916bb54e6c3b8a486273cfed2cb672d2
7
- data.tar.gz: 20f99acb920a6a6cd1496e3b9429f635dc24275ce9bd8a70bceb44202147cc8ce9f9930de631a3e0ffac3b80c80b2526ada9ce3e88fe4b690dff0d9fa6aa101c
6
+ metadata.gz: e0b38e2d2819e152a508874b060b22f161aa4b56523d9b6869b714f9186920fa7d61fd10b09840158c94e4b55a7c18a718307e9a02f4320426f54baa9bdfdd9f
7
+ data.tar.gz: d53fb1934cdc2cbbc2cad92e43a4132ff0f8ea8eec1435bd930be575d3e2284a48278809b7576bdf24b8d7df36ac39fe2dcb223813dc9f8c3b57632e08e030e5
@@ -12,7 +12,7 @@ class Features::Capsule < ForemanMaintain::Feature
12
12
  end
13
13
 
14
14
  def current_version
15
- @current_version ||= rpm_version(package_name)
15
+ @current_version ||= package_version(package_name)
16
16
  end
17
17
 
18
18
  def package_name
@@ -100,7 +100,13 @@ class Features::Installer < ForemanMaintain::Feature
100
100
  end
101
101
 
102
102
  def installer_arguments
103
- installer_args = ' --disable-system-checks'
103
+ installer_args = ''
104
+
105
+ if feature(:foreman_proxy) &&
106
+ feature(:foreman_proxy).with_content?
107
+ installer_args += ' --disable-system-checks'
108
+ end
109
+
104
110
  unless check_min_version('foreman', '2.1') || check_min_version('foreman-proxy', '2.1')
105
111
  installer_args += ' --upgrade' if can_upgrade?
106
112
  end
@@ -12,7 +12,7 @@ class Features::Katello < ForemanMaintain::Feature
12
12
  end
13
13
 
14
14
  def current_version
15
- @current_version ||= rpm_version('katello')
15
+ @current_version ||= package_version('katello')
16
16
  end
17
17
 
18
18
  def services
@@ -25,14 +25,12 @@ class Features::Nftables < ForemanMaintain::Feature
25
25
  execute!("nft add chain #{family} #{table} #{chain} #{chain_options}")
26
26
  end
27
27
 
28
- def add_rules(options = {})
28
+ def add_rule(options = {})
29
29
  family = options.fetch(:family, ip_family)
30
30
  table = options.fetch(:table, table_name)
31
31
  chain = options.fetch(:chain, chain_name)
32
- rules = options.fetch(:rules) # needs validation
33
- rules.each do |rule|
34
- execute!("nft add rule #{family} #{table} #{chain} #{rule}")
35
- end
32
+ rule = options.fetch(:rule) # needs validation
33
+ execute!("nft add rule #{family} #{table} #{chain} #{rule}")
36
34
  end
37
35
 
38
36
  def table_exist?(name = table_name)
@@ -10,7 +10,7 @@ class Features::Satellite < ForemanMaintain::Feature
10
10
  end
11
11
 
12
12
  def current_version
13
- @current_version ||= rpm_version(package_name) || version_from_source
13
+ @current_version ||= package_version(package_name) || version_from_source
14
14
  end
15
15
 
16
16
  def package_name
@@ -4,7 +4,6 @@ module Procedures::Content
4
4
  description 'Prepare content for Pulp 3'
5
5
  for_feature :pulpcore
6
6
  param :quiet, 'Keep the output on a single line', :flag => true, :default => false
7
- do_not_whitelist
8
7
  end
9
8
 
10
9
  def run
@@ -9,7 +9,6 @@ module Procedures::Content
9
9
  end
10
10
 
11
11
  param :skip_deb, 'Do not run debian options in installer.'
12
- do_not_whitelist
13
12
  end
14
13
 
15
14
  def run
@@ -24,7 +24,15 @@ module Procedures::Pulp
24
24
  '/var/lib/pulp/uploads',
25
25
  '/var/lib/mongodb/',
26
26
  '/var/cache/pulp'
27
- ]
27
+ ].select { |dir| File.directory?(dir) }
28
+ end
29
+
30
+ def pulp_data_dirs_mountpoints
31
+ pulp_data_dirs.select { |d| Pathname(d).mountpoint? }
32
+ end
33
+
34
+ def deletable_pulp_dirs
35
+ @deletable_pulp_dirs ||= pulp_data_dirs - pulp_data_dirs_mountpoints
28
36
  end
29
37
 
30
38
  # rubocop:disable Metrics/MethodLength
@@ -53,11 +61,12 @@ module Procedures::Pulp
53
61
  @installed_pulp_packages
54
62
  end
55
63
 
56
- def data_dir_removal_cmds
57
- pulp_data_dirs.select { |dir| File.directory?(dir) }.map { |dir| "rm -rf #{dir}" }
64
+ def data_dir_removal_cmds(pulp_dirs)
65
+ pulp_dirs.map { |dir| "rm -rf #{dir}" }
58
66
  end
59
67
 
60
- def ask_to_proceed(rm_cmds)
68
+ def ask_to_proceed
69
+ rm_cmds = data_dir_removal_cmds(pulp_data_dirs)
61
70
  question = "\nWARNING: All pulp2 packages will be removed with the following commands:\n"
62
71
  question += "\n# rpm -e #{pulp_packages.join(' ')}" if pulp_packages.any?
63
72
  question += "\n# yum remove rh-mongodb34-*"
@@ -70,11 +79,9 @@ module Procedures::Pulp
70
79
  end
71
80
 
72
81
  def run
73
- rm_cmds = data_dir_removal_cmds
74
-
75
82
  assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
76
83
 
77
- ask_to_proceed(rm_cmds) unless assumeyes_val
84
+ ask_to_proceed unless assumeyes_val
78
85
 
79
86
  remove_pulp if pulp_packages.any?
80
87
 
@@ -86,7 +93,7 @@ module Procedures::Pulp
86
93
 
87
94
  drop_migrations
88
95
 
89
- delete_pulp_data(rm_cmds) if rm_cmds.any?
96
+ delete_pulp_data
90
97
 
91
98
  restart_pulpcore_services
92
99
  end
@@ -163,12 +170,41 @@ module Procedures::Pulp
163
170
  end
164
171
  # rubocop:enable Metrics/BlockLength
165
172
 
166
- def delete_pulp_data(rm_cmds)
167
- with_spinner('Deleting pulp2 data directories') do |spinner|
168
- rm_cmds.each do |cmd|
169
- execute!(cmd)
173
+ def delete_pulp_data
174
+ non_mountpoints = data_dir_removal_cmds(deletable_pulp_dirs)
175
+ mountpoints = pulp_data_dirs_mountpoints
176
+ with_spinner('') do |spinner|
177
+ if non_mountpoints.any?
178
+ spinner.update('Deleting pulp2 data directories.')
179
+ non_mountpoints.each do |cmd|
180
+ execute!(cmd)
181
+ end
182
+ msg_for_del_non_mountpoints(mountpoints, spinner)
183
+ end
184
+ if mountpoints.any?
185
+ msg_for_del_mountpoints(mountpoints, spinner)
170
186
  end
171
- spinner.update('Done deleting pulp2 data directories')
187
+ end
188
+ end
189
+
190
+ def msg_for_del_non_mountpoints(mountpoints, spinner)
191
+ if mountpoints.empty?
192
+ spinner.update('Done deleting all pulp2 data directories.')
193
+ else
194
+ spinner.update("Deleted: #{deletable_pulp_dirs.join("\n")}")
195
+ end
196
+ end
197
+
198
+ def msg_for_del_mountpoints(mountpoints, spinner)
199
+ _, cmd_name = ForemanMaintain.pkg_and_cmd_name
200
+ if mountpoints.count > 1
201
+ spinner.update("The directories #{mountpoints.join(',')} are individual mountpoints.")
202
+ puts "\nThe #{cmd_name} won't delete these directories.\n"\
203
+ 'You need to remove content and these directories on your own.'
204
+ else
205
+ spinner.update("The directory #{mountpoints.join(',')} is individual mountpoint.")
206
+ puts "\nThe #{cmd_name} won't delete the directory.\n"\
207
+ 'You need to remove content and the directory on your own.'
172
208
  end
173
209
  end
174
210
 
@@ -10,7 +10,7 @@ module ForemanMaintain
10
10
  unless table_exist?
11
11
  add_table
12
12
  add_chain(:chain_options => nftables_chain_options)
13
- add_rules(rules: nftables_rules)
13
+ add_rule(rule: nftables_rule)
14
14
  end
15
15
  end
16
16
 
@@ -22,8 +22,8 @@ module ForemanMaintain
22
22
  '{type filter hook input priority 0\\;}'
23
23
  end
24
24
 
25
- def nftables_rules
26
- ['iifname "lo" accept', 'tcp dport 443 reject']
25
+ def nftables_rule
26
+ 'tcp dport https reject'
27
27
  end
28
28
 
29
29
  def status_for_maintenance_mode
@@ -100,10 +100,6 @@ module ForemanMaintain
100
100
  @data[:advanced_run] = advanced_run
101
101
  end
102
102
 
103
- def do_not_whitelist
104
- @data[:do_not_whitelist] = true
105
- end
106
-
107
103
  def self.eval_dsl(metadata, &block)
108
104
  new(metadata).tap do |dsl|
109
105
  dsl.instance_eval(&block)
@@ -115,7 +115,8 @@ module ForemanMaintain
115
115
 
116
116
  def package_version(name)
117
117
  # space for extension to support non-rpm distributions
118
- rpm_version(name)
118
+ pkg = package_manager.find_installed_package(name, '%{VERSION}')
119
+ version(pkg) unless pkg.nil?
119
120
  end
120
121
 
121
122
  def parse_csv(data)
@@ -132,13 +133,6 @@ module ForemanMaintain
132
133
  nil
133
134
  end
134
135
 
135
- def rpm_version(name)
136
- rpm_version = execute(%(rpm -q '#{name}' --queryformat="%{VERSION}"))
137
- if $CHILD_STATUS.success?
138
- version(rpm_version)
139
- end
140
- end
141
-
142
136
  def shellescape(string)
143
137
  Shellwords.escape(string)
144
138
  end
@@ -36,8 +36,12 @@ module ForemanMaintain::PackageManager
36
36
  sys.execute?(%(rpm -q #{packages_list}))
37
37
  end
38
38
 
39
- def find_installed_package(name)
40
- status, result = sys.execute_with_status(%(rpm -q '#{name}'))
39
+ def find_installed_package(name, queryformat = '')
40
+ rpm_cmd = "rpm -q '#{name}'"
41
+ unless queryformat.empty?
42
+ rpm_cmd += " --qf '#{queryformat}'"
43
+ end
44
+ status, result = sys.execute_with_status(rpm_cmd)
41
45
  if status == 0
42
46
  result
43
47
  end
@@ -78,12 +82,12 @@ module ForemanMaintain::PackageManager
78
82
  sys.execute(find_cmd).split("\n")
79
83
  end
80
84
 
81
- def list_installed_packages(queryfm = '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n')
82
- # The queryfm should only include valid tag(s) as per `rpm --querytag` list.
85
+ def list_installed_packages(queryformat = '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n')
86
+ # The queryformat should only include valid tag(s) as per `rpm --querytags` list.
83
87
  # If any special formatting is required with querytag then it should be provided with tag i.e,
84
- # querytag = "--%{VENDOR}"
85
- # The queryfm string must end with '\n'
86
- sys.execute!("rpm -qa --qf '#{queryfm}'").split("\n")
88
+ # "--%{VENDOR}"
89
+ # The queryformat string must end with '\n'
90
+ sys.execute!("rpm -qa --qf '#{queryformat}'").split("\n")
87
91
  end
88
92
 
89
93
  private
@@ -317,11 +317,7 @@ module ForemanMaintain
317
317
 
318
318
  steps_with_error = scenario.steps_with_error(:whitelisted => false)
319
319
  steps_with_skipped = scenario.steps_with_skipped(:whitelisted => true)
320
- not_skippable_steps = scenario.steps_with_error.select do |step|
321
- step.metadata[:do_not_whitelist] == true
322
- end
323
-
324
- steps_to_whitelist = steps_with_error + steps_with_skipped - not_skippable_steps
320
+ steps_to_whitelist = steps_with_error + steps_with_skipped
325
321
  unless steps_with_error.empty?
326
322
  message << format(<<-MESSAGE.strip_heredoc, format_steps(steps_with_error, "\n", 2))
327
323
  The following steps ended up in failing state:
@@ -329,25 +325,11 @@ module ForemanMaintain
329
325
  %s
330
326
  MESSAGE
331
327
  whitelist_labels = steps_to_whitelist.map(&:label_dashed).join(',')
332
- unless whitelist_labels.empty?
333
- recommend << if scenario.detector.feature(:instance).downstream
334
- format(<<-MESSAGE.strip_heredoc, whitelist_labels)
335
- Resolve the failed steps and rerun the command.
336
-
337
- If the situation persists and, you are unclear what to do next,
338
- contact Red Hat Technical Support.
339
-
340
- In case the failures are false positives, use
341
- --whitelist="%s"
342
- MESSAGE
343
- else
344
- format(<<-MESSAGE.strip_heredoc, whitelist_labels)
345
- Resolve the failed steps and rerun the command.
346
- In case the failures are false positives, use
347
- --whitelist="%s"
348
- MESSAGE
349
- end
350
- end
328
+ recommend << format(<<-MESSAGE.strip_heredoc, whitelist_labels)
329
+ Resolve the failed steps and rerun
330
+ the command. In case the failures are false positives,
331
+ use --whitelist="%s"
332
+ MESSAGE
351
333
  end
352
334
 
353
335
  steps_with_warning = scenario.steps_with_warning(:whitelisted => false)
@@ -8,21 +8,16 @@ module ForemanMaintain::Utils
8
8
  @instance_parent_unit = options.fetch(:instance_parent_unit, nil)
9
9
  end
10
10
 
11
- def command(action, options = {})
12
- do_wait = options.fetch(:wait, true) # wait for service to start
11
+ def command(action)
13
12
  all = @options.fetch(:all, false)
14
13
  skip_enablement = @options.fetch(:skip_enablement, false)
15
14
  if skip_enablement && %w[enable disable].include?(action)
16
15
  return skip_enablement_message(action, @name)
17
16
  end
18
17
 
19
- if do_wait && File.exist?('/usr/sbin/service-wait')
20
- "service-wait #{@name} #{action}"
21
- else
22
- cmd = "systemctl #{action} #{@name}"
23
- cmd += ' --all' if all
24
- cmd
25
- end
18
+ cmd = "systemctl #{action} #{@name}"
19
+ cmd += ' --all' if all
20
+ cmd
26
21
  end
27
22
 
28
23
  def status
@@ -38,11 +33,11 @@ module ForemanMaintain::Utils
38
33
  end
39
34
 
40
35
  def enable
41
- execute('enable', :wait => false)
36
+ execute('enable')
42
37
  end
43
38
 
44
39
  def disable
45
- execute('disable', :wait => false)
40
+ execute('disable')
46
41
  end
47
42
 
48
43
  def running?
@@ -66,8 +61,8 @@ module ForemanMaintain::Utils
66
61
 
67
62
  private
68
63
 
69
- def execute(action, options = {})
70
- @sys.execute_with_status(command(action, options))
64
+ def execute(action)
65
+ @sys.execute_with_status(command(action))
71
66
  end
72
67
 
73
68
  def service_enabled_status
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '1.0.9'.freeze
2
+ VERSION = '1.1.1'.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: 1.0.9
4
+ version: 1.1.1
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: 2022-05-04 00:00:00.000000000 Z
11
+ date: 2022-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp