foreman_maintain 0.1.4 → 0.1.5

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: 65b1daa7e3ed6b36c77a34061c0cde3badf9cc0d
4
- data.tar.gz: '08aedcc2e9c4242dc17b8d50b5bf356bd3349d28'
3
+ metadata.gz: 85dd75e0de03c6b2c872e728ba047ecde645148d
4
+ data.tar.gz: 93d8cc2e2381e5c890c62f114b2a3f3ad9c9b460
5
5
  SHA512:
6
- metadata.gz: 8a7548a663107ef22475acefbe0b0a5dc5aeff92e816c6eaf0096b2ce344c43536af033d9d67fbbc5c36f976c4d6f7e0dbb6e6d8f0343e69ad678feaa907cdc6
7
- data.tar.gz: 6e0a423955cd009992767a126168609ac9ec0d1687465089bfa1861798402157f8225f335ad452fa64ba04a751468d5804cac000faafe9a450d07d75109db6bf
6
+ metadata.gz: 8b307b932f52b3b9686ecca55c5904d4b901f71429e0fc485ddce9cff419026aaa96393b413dce528001c74ed0e11f03ba7ab73c280f66663dbad6b03299ef80
7
+ data.tar.gz: bcc8b92ff358e1e5c3c4c129278af67566dfc09681e7d338330a20718a955acd5fce84b939b40738beb0f3f0fb81990632aec7bb3e37a600ea5cdfcecf9ed71e
@@ -7,28 +7,35 @@ module Procedures::Candlepin
7
7
  confine do
8
8
  feature(:candlepin_database) &&
9
9
  feature(:downstream) &&
10
- feature(:downstream).current_minor_version == '6.2' &&
11
- feature(:candlepin_database).table_exist?('cp_env_content')
10
+ feature(:downstream).current_minor_version == '6.2'
12
11
  end
13
12
  end
14
13
 
15
14
  def run
16
- with_spinner('Deleting cp_env_content record(s) with unresolvable content') do |spinner|
17
- spinner.update 'Finding cp_env_content records with unresolvable content'
18
- env_content_ids = feature(:candlepin_database).env_content_ids_with_null_content
19
- if env_content_ids.empty?
20
- spinner.update 'No orphaned records found'
21
- else
22
- spinner.update 'Taking a backup of the candlepin database'
23
- feature(:candlepin_database).perform_backup
24
-
25
- puts "Total #{env_content_ids.length} records with unresolvable content"
26
- spinner.update 'Deleting record(s) from cp_env_content table'
27
- feature(:candlepin_database).delete_records_by_ids(
28
- 'cp_env_content', env_content_ids
29
- )
15
+ if feature(:candlepin_database).table_exist?('cp_env_content')
16
+ with_spinner('Deleting cp_env_content record(s) with unresolvable content') do |spinner|
17
+ spinner.update 'Finding cp_env_content records with unresolvable content'
18
+ env_content_ids = feature(:candlepin_database).env_content_ids_with_null_content
19
+ if env_content_ids.empty?
20
+ spinner.update 'No orphaned records found'
21
+ else
22
+ backup_and_delete_records(spinner, env_content_ids)
23
+ end
30
24
  end
31
25
  end
32
26
  end
27
+
28
+ private
29
+
30
+ def backup_and_delete_records(spinner, env_content_ids)
31
+ spinner.update 'Taking a backup of the candlepin database'
32
+ feature(:candlepin_database).perform_backup
33
+
34
+ puts "Total #{env_content_ids.length} records with unresolvable content"
35
+ spinner.update 'Deleting record(s) from cp_env_content table'
36
+ feature(:candlepin_database).delete_records_by_ids(
37
+ 'cp_env_content', env_content_ids
38
+ )
39
+ end
33
40
  end
34
41
  end
@@ -1,16 +1,24 @@
1
1
  module Procedures::Installer
2
2
  class Upgrade < ForemanMaintain::Procedure
3
3
  def run
4
- execute!("#{installer_command} --upgrade", :interactive => true)
4
+ execute!("LANG=en_US.utf-8 #{installer_command} #{upgrade_command?}", :interactive => true)
5
5
  end
6
6
 
7
7
  private
8
8
 
9
+ def upgrade_command?
10
+ if package_version('satellite-installer') || package_version('katello-installer')
11
+ '--upgrade'
12
+ end
13
+ end
14
+
9
15
  def installer_command
10
- if package_version('satellite-installer')
11
- 'satellite-installer'
12
- elsif package_version('katello-installer')
13
- 'katello-installer'
16
+ if feature(:downstream)
17
+ if feature(:downstream).current_minor_version <= '6.1'
18
+ 'katello-installer'
19
+ else
20
+ 'satellite-installer'
21
+ end
14
22
  else
15
23
  'foreman-installer'
16
24
  end
@@ -14,12 +14,15 @@ module ForemanMaintain
14
14
  end
15
15
 
16
16
  def psql(query, config = configuration)
17
- execute("PGPASSWORD='#{config[%(password)]}' #{psql_db_connection_str(config)}",
18
- :stdin => query)
17
+ if ping(config)
18
+ execute(psql_command(config), :stdin => query)
19
+ else
20
+ raise_service_error
21
+ end
19
22
  end
20
23
 
21
24
  def ping(config = configuration)
22
- psql('SELECT 1 as ping', config)
25
+ execute?(psql_command(config), :stdin => 'SELECT 1 as ping')
23
26
  end
24
27
 
25
28
  def backup_file_path(config = configuration)
@@ -67,10 +70,15 @@ module ForemanMaintain
67
70
 
68
71
  private
69
72
 
70
- def psql_db_connection_str(config)
73
+ def psql_command(config)
74
+ "PGPASSWORD='#{config[%(password)]}' "\
71
75
  "psql -d #{config['database']} -h #{config['host'] || 'localhost'} "\
72
76
  " -p #{config['port'] || '5432'} -U #{config['username']}"
73
77
  end
78
+
79
+ def raise_service_error
80
+ raise Error::Fail, 'Please check whether database service is up & running state.'
81
+ end
74
82
  end
75
83
  end
76
84
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '0.1.4'.freeze
2
+ VERSION = '0.1.5'.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.1.4
4
+ version: 0.1.5
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: 2018-03-20 00:00:00.000000000 Z
11
+ date: 2018-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp