foreman_maintain 0.2.3 → 0.2.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
  SHA1:
3
- metadata.gz: '0308a81ffbe17ee43deef021d8a3c43864fb886c'
4
- data.tar.gz: 6c9b6d939187e1461b991760d507364500046da1
3
+ metadata.gz: 999cf43419721ea21acfe4f43ed88dde3d41633b
4
+ data.tar.gz: 1864e1f18ff5c036f25516d52ab7cdcee87b64fc
5
5
  SHA512:
6
- metadata.gz: 7c75df5e43ecd4f33e2be2bc8b09a809c2931bf7d71657df4964f2d6ffe1ee6c5eb184800f9aa864f3effb524f3ca353dc974323f621c1c1112bd4b174e4697a
7
- data.tar.gz: 99795da6683e38730a50c1ba4a286473bd2af075da7ee33a12f4ad045c68d5bc11cbac74fde3056604d3df373a73007e43f20593cfc3911c70f939cc8ea707b3
6
+ metadata.gz: 17e48dc3ff9981b09d2265e427ebd6dc635e28e75f8f37b9c8d5d43974cc3df90cfdab9b7e585af8def025c06a736fc277d8fe2143ac8b91a8174e6c5c5b8f5d
7
+ data.tar.gz: 3b5dce2b1b7754e45c509ac032e8cfe3b511c72c51fdcf4d201cc42bb116842144250eef48f7da1b73da3c1e2ec2f238e47cab74d33292976327cf636a7d22a1
@@ -21,7 +21,7 @@ class Features::CandlepinDatabase < ForemanMaintain::Feature
21
21
 
22
22
  def check_option_using_cpdb_help(option_name, parent_cmd = '')
23
23
  parent_cmd = '/usr/share/candlepin/cpdb' if parent_cmd.empty?
24
- help_cmd = "#{parent_cmd} --help | grep -c '\\-\\-#{option_name} '"
24
+ help_cmd = "#{parent_cmd} --help | grep -c '\\-\\-#{option_name}'"
25
25
  execute?(help_cmd)
26
26
  end
27
27
 
@@ -31,6 +31,7 @@ class Features::CandlepinDatabase < ForemanMaintain::Feature
31
31
  main_cmd += format_shell_args(
32
32
  '-u' => configuration['username'], '-p' => configuration[%(password)]
33
33
  )
34
+ main_cmd += format_shell_args(extend_with_db_options)
34
35
  execute_with_status(main_cmd, :hidden_patterns => [configuration['password']])
35
36
  end
36
37
 
@@ -45,22 +46,51 @@ class Features::CandlepinDatabase < ForemanMaintain::Feature
45
46
 
46
47
  private
47
48
 
49
+ # rubocop:disable Metrics/MethodLength
48
50
  def load_configuration
49
51
  raw_config = File.read(CANDLEPIN_DB_CONFIG)
50
52
  full_config = Hash[raw_config.scan(/(^[^#\n][^=]*)=(.*)/)]
51
53
  uri_regexp = %r{://(([^/:]*):?([^/]*))/([^?]*)\??(ssl=([^&]*))?}
52
- uri = uri_regexp.match(full_config['jpa.config.hibernate.connection.url'])
54
+ url = full_config['jpa.config.hibernate.connection.url']
55
+ uri = uri_regexp.match(url)
53
56
  @configuration = {
54
57
  'username' => full_config['jpa.config.hibernate.connection.username'],
55
58
  'password' => full_config['jpa.config.hibernate.connection.password'],
56
59
  'database' => uri[4],
57
60
  'host' => uri[2],
58
61
  'port' => uri[3] || '5432',
59
- 'ssl' => (uri[6] == 'true'),
62
+ 'ssl' => (fetch_extra_param(url, 'ssl') == 'true'),
63
+ 'sslfactory' => fetch_extra_param(url, 'sslfactory'),
60
64
  'driver_class' => full_config['jpa.config.hibernate.connection.driver_class'],
61
- 'url' => full_config['jpa.config.hibernate.connection.url']
65
+ 'url' => url
62
66
  }
63
67
  end
68
+ # rubocop:enable Metrics/MethodLength
69
+
70
+ def extend_with_db_options
71
+ db_options = { '-d' => construct_database_string }
72
+ if check_option_using_cpdb_help('dbhost')
73
+ db_options['--dbhost'] = configuration['host']
74
+ db_options['--dbport'] = configuration['port']
75
+ end
76
+ db_options
77
+ end
78
+
79
+ def construct_database_string
80
+ db_str = configuration['database']
81
+ extra_opts = []
82
+ extra_opts << "ssl=#{configuration['ssl']}" if configuration['ssl']
83
+ extra_opts << "sslfactory=#{configuration['sslfactory']}" if configuration['sslfactory']
84
+ db_str += "?#{extra_opts.join('&')}" unless extra_opts.empty?
85
+ db_str
86
+ end
87
+
88
+ def fetch_extra_param(url, key_name)
89
+ query_string = url.split('?')[1]
90
+ return nil unless query_string
91
+ output = /#{key_name}=([^&]*)?/.match(query_string)
92
+ output[1] if output
93
+ end
64
94
 
65
95
  def cpdb_validate_cmd
66
96
  return '' unless check_option_using_cpdb_help('validate')
@@ -35,7 +35,12 @@ class Features::Service < ForemanMaintain::Feature
35
35
 
36
36
  def existing_services
37
37
  service_list = get_services_from_features(available_features)
38
- service_list.select { |service| service_exists?(service) }
38
+ service_list.select { |service| service_remote?(service) || service_exists?(service) }
39
+ end
40
+
41
+ def service_remote?(service)
42
+ (service == 'postgresql' && !feature(:instance).postgresql_local?) ||
43
+ (service == 'mongod' && feature(:instance).database_remote?(:mongo))
39
44
  end
40
45
 
41
46
  def filtered_services(options)
@@ -21,8 +21,8 @@ module Scenarios::Satellite_6_4
21
21
  def compose
22
22
  add_steps(find_checks(:default))
23
23
  add_steps(find_checks(:pre_upgrade))
24
+ add_steps(find_checks(:puppet_upgrade_guide))
24
25
  add_step(Checks::Repositories::Validate.new(:version => '6.4'))
25
- add_step(Checks::Puppet::ProvideUpgradeGuide.new)
26
26
  end
27
27
  end
28
28
 
@@ -22,7 +22,6 @@ module Scenarios::Satellite_6_4_z
22
22
  add_steps(find_checks(:default))
23
23
  add_steps(find_checks(:pre_upgrade))
24
24
  add_step(Checks::Repositories::Validate.new(:version => '6.4'))
25
- add_step(Checks::Puppet::ProvideUpgradeGuide.new)
26
25
  end
27
26
  end
28
27
 
@@ -37,7 +37,7 @@ module ForemanMaintain
37
37
  end
38
38
 
39
39
  def clear_register
40
- versions_to_tags.lear
40
+ versions_to_tags.clear
41
41
  end
42
42
 
43
43
  def current_target_version
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '0.2.3'.freeze
2
+ VERSION = '0.2.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.2.3
4
+ version: 0.2.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: 2018-06-22 00:00:00.000000000 Z
11
+ date: 2018-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp