manageiq-appliance_console 2.0.3 → 3.0.0

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: f59f9d77ab02be6293d6bd474900980c461250cddf3ce5368db1dace2caaef74
4
- data.tar.gz: a10f9b18db83b9cb574f76efe167e313df58fb995ce2e28a14741b87cf331763
3
+ metadata.gz: 5d7e378f02630aa568cd8ff477da4a1e492421119f5c964e8c5093ace832a501
4
+ data.tar.gz: c6ad984e153ef15639aa0f23bef9dfb9aad6e3dc448f2ce05263670499c98b2c
5
5
  SHA512:
6
- metadata.gz: 2a84fe3d01bb6dde2a23fc94c07cd0372de7b485e57cab57bdcf923e176a74b9269f2fb0de2181567b1ae8a364d72f3b881ad8715f726c4290ac115feedf8c89
7
- data.tar.gz: 1e443c7cb4901e7afbd937959ce95164ded4f83afe1994691bad72d95b657925394d8eb4518a82027c3f05fab0b41e75cdda839de329e798d7348e3fc4bbc1e7
6
+ metadata.gz: 21756d451a2359bcbee0085dc816383ec2e3d5dab9f49111976d838ab4a42d0f0a80a2c36ae9ebadeb98805c4a7955516014a763dc293f6262c84e7327969e49
7
+ data.tar.gz: 51b11f3030dd224fc9cc4ebba9eb4d3fe16148f340d63452f24a5943579e0ea4f5515be482f3026ca2f46e77f1ba07749116a55da1483c26aef40c28519f6a3e
data/.gitignore CHANGED
@@ -8,5 +8,8 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
 
11
+ # ruby version management
12
+ .ruby-version
13
+
11
14
  # rspec failure tracking
12
15
  .rspec_status
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.4.4
3
4
  - 2.3.6
4
- - 2.4.2
5
5
  sudo: false
6
6
  cache: bundler
7
7
  env:
@@ -6,9 +6,6 @@ require 'bundler'
6
6
  Bundler.setup
7
7
 
8
8
  require 'manageiq-appliance_console'
9
- require 'pathname'
10
-
11
- gem_root = Pathname.new(__dir__).join("..")
12
9
 
13
10
  require 'fileutils'
14
11
  require 'highline/import'
@@ -20,15 +17,7 @@ require 'util/postgres_admin'
20
17
  require 'awesome_spawn'
21
18
  include HighLine::SystemExtensions
22
19
 
23
- require 'i18n'
24
- locales_dir = ENV['CONTAINER'] ? "container" : "appliance"
25
- locales_paths = [
26
- gem_root.join("locales", locales_dir, "*.yml"),
27
- File.expand_path(File.join("productization/appliance_console/locales", locales_dir, "*.yml"), ManageIQ::ApplianceConsole::RAILS_ROOT)
28
- ]
29
- locales_paths.each { |p| I18n.load_path += Dir[p].sort }
30
- I18n.enforce_available_locales = true
31
- I18n.backend.load_translations
20
+ require 'manageiq/appliance_console/i18n'
32
21
 
33
22
  SCAP_RULES_DIR = File.expand_path("productization/appliance_console/config", ManageIQ::ApplianceConsole::RAILS_ROOT)
34
23
 
@@ -407,57 +396,17 @@ Static Network Configuration
407
396
  press_any_key
408
397
  end
409
398
 
410
- when I18n.t("advanced_settings.dbrestore")
411
- say("#{selection}\n\n")
412
- task_params = []
413
- uri = nil
414
-
415
- # TODO: merge into 1 prompt
416
- case ask_with_menu("Restore Database File", RESTORE_OPTIONS, RESTORE_LOCAL, nil)
417
- when RESTORE_LOCAL
418
- validate = ->(a) { File.exist?(a) }
419
- uri = just_ask("location of the local restore file", DB_RESTORE_FILE, validate, "file that exists")
420
- task = "evm:db:restore:local"
421
- task_params = ["--", {:local_file => uri}]
422
-
423
- when RESTORE_NFS
424
- uri = ask_for_uri("location of the remote backup file\nExample: #{sample_url('nfs')})", "nfs")
425
- task = "evm:db:restore:remote"
426
- task_params = ["--", {:uri => uri}]
427
-
428
- when RESTORE_SMB
429
- uri = ask_for_uri("location of the remote backup file\nExample: #{sample_url('smb')}", "smb")
430
- user = just_ask("username with access to this file.\nExample: 'mydomain.com/user'")
431
- pass = ask_for_password("password for #{user}")
432
-
433
- task = "evm:db:restore:remote"
434
- task_params = ["--", {:uri => uri, :uri_username => user, :uri_password => pass}]
435
-
436
- when ManageIQ::ApplianceConsole::CANCEL
437
- raise MiqSignalError
438
- end
439
-
440
- clear_screen
441
- say("#{selection}\n\n")
399
+ when I18n.t("advanced_settings.dbbackup")
400
+ db_admin = ManageIQ::ApplianceConsole::DatabaseAdmin.new(:backup)
401
+ db_admin.ask_questions && db_admin.activate
442
402
 
443
- delete_agreed = false
444
- if selection == RESTORE_LOCAL
445
- say "The local database restore file is located at: '#{uri}'.\n"
446
- delete_agreed = agree("Should this file be deleted after completing the restore? (Y/N): ")
447
- end
403
+ when I18n.t("advanced_settings.dbdump")
404
+ db_admin = ManageIQ::ApplianceConsole::DatabaseAdmin.new(:dump)
405
+ db_admin.ask_questions && db_admin.activate
448
406
 
449
- say "\nNote: A database restore cannot be undone. The restore will use the file: #{uri}.\n"
450
- if agree("Are you sure you would like to restore the database? (Y/N): ")
451
- say("\nRestoring the database...")
452
- rake_success = ManageIQ::ApplianceConsole::Utilities.rake(task, task_params)
453
- if rake_success && delete_agreed
454
- say("\nRemoving the database restore file #{DB_RESTORE_FILE}...")
455
- File.delete(DB_RESTORE_FILE)
456
- elsif !rake_success
457
- say("\nDatabase restore failed. Check the logs for more information")
458
- end
459
- end
460
- press_any_key
407
+ when I18n.t("advanced_settings.dbrestore")
408
+ db_admin = ManageIQ::ApplianceConsole::DatabaseAdmin.new(:restore)
409
+ db_admin.ask_questions && db_admin.activate
461
410
 
462
411
  when I18n.t("advanced_settings.key_gen")
463
412
  say("#{selection}\n\n")
@@ -22,6 +22,7 @@ require 'manageiq/appliance_console/version'
22
22
  require 'manageiq/appliance_console/errors'
23
23
  require 'manageiq/appliance_console/logger'
24
24
  require 'manageiq/appliance_console/logging'
25
+ require 'manageiq/appliance_console/prompts'
25
26
 
26
27
  require 'manageiq-gems-pending'
27
28
  require 'highline'
@@ -29,6 +30,7 @@ require 'highline'
29
30
  require 'manageiq/appliance_console/certificate'
30
31
  require 'manageiq/appliance_console/certificate_authority'
31
32
  require 'manageiq/appliance_console/cli'
33
+ require 'manageiq/appliance_console/database_admin'
32
34
  require 'manageiq/appliance_console/database_configuration'
33
35
  require 'manageiq/appliance_console/database_replication'
34
36
  require 'manageiq/appliance_console/database_replication_primary'
@@ -42,7 +44,6 @@ require 'manageiq/appliance_console/key_configuration'
42
44
  require 'manageiq/appliance_console/logfile_configuration'
43
45
  require 'manageiq/appliance_console/logical_volume_management'
44
46
  require 'manageiq/appliance_console/principal'
45
- require 'manageiq/appliance_console/prompts'
46
47
  require 'manageiq/appliance_console/scap'
47
48
  require 'manageiq/appliance_console/temp_storage_configuration'
48
49
  require 'manageiq/appliance_console/timezone_configuration'
@@ -0,0 +1,203 @@
1
+ require 'manageiq/appliance_console/errors'
2
+
3
+ module ManageIQ
4
+ module ApplianceConsole
5
+ class DatabaseAdmin < HighLine
6
+ include ManageIQ::ApplianceConsole::Prompts
7
+
8
+ LOCAL_FILE = "Local file".freeze
9
+ NFS_FILE = "Network File System (NFS)".freeze
10
+ SMB_FILE = "Samba (SMB)".freeze
11
+ FILE_OPTIONS = [LOCAL_FILE, NFS_FILE, SMB_FILE, CANCEL].freeze
12
+
13
+ DB_RESTORE_FILE = "/tmp/evm_db.backup".freeze
14
+ DB_DEFAULT_DUMP_FILE = "/tmp/evm_db.dump".freeze
15
+ LOCAL_FILE_VALIDATOR = ->(a) { File.exist?(a) }.freeze
16
+
17
+ USER_PROMPT = <<-PROMPT.strip_heredoc.chomp
18
+ username with access to this file.
19
+ Example: 'mydomain.com/user'
20
+ PROMPT
21
+
22
+ DB_DUMP_WARNING = <<-WARN.strip_heredoc
23
+ WARNING: This is not the recommended and supported way of running a
24
+ database backup, and is strictly meant for exporting a database for
25
+ support/debugging purposes!
26
+
27
+
28
+ WARN
29
+
30
+ attr_reader :action, :backup_type, :task, :task_params, :delete_agree, :uri, :filename
31
+
32
+ def initialize(action = :restore, input = $stdin, output = $stdout)
33
+ super(input, output)
34
+
35
+ @action = action
36
+ @task_params = []
37
+ end
38
+
39
+ def ask_questions
40
+ setting_header
41
+ say(DB_DUMP_WARNING) if action == :dump
42
+ ask_file_location
43
+ ask_for_tables_to_exclude_in_dump
44
+ end
45
+
46
+ def activate
47
+ clear_screen
48
+ setting_header
49
+
50
+ ask_to_delete_backup_after_restore
51
+ confirm_and_execute
52
+ end
53
+
54
+ def ask_file_location
55
+ case @backup_type = ask_with_menu(*file_menu_args)
56
+ when LOCAL_FILE then ask_local_file_options
57
+ when NFS_FILE then ask_nfs_file_options
58
+ when SMB_FILE then ask_smb_file_options
59
+ when CANCEL then raise MiqSignalError
60
+ end
61
+ end
62
+
63
+ def ask_local_file_options
64
+ @uri = just_ask(*filename_prompt_args)
65
+ @task = "evm:db:#{action}:local"
66
+ @task_params = ["--", {:local_file => uri}]
67
+ end
68
+
69
+ def ask_nfs_file_options
70
+ @filename = just_ask(*filename_prompt_args) unless action == :restore
71
+ @uri = ask_for_uri(*remote_file_prompt_args_for("nfs"))
72
+ @task = "evm:db:#{action}:remote"
73
+
74
+ params = {:uri => uri}
75
+ params[:remote_file_name] = filename if filename
76
+
77
+ @task_params = ["--", params]
78
+ end
79
+
80
+ def ask_smb_file_options
81
+ @filename = just_ask(*filename_prompt_args) unless action == :restore
82
+ @uri = ask_for_uri(*remote_file_prompt_args_for("smb"))
83
+ user = just_ask(USER_PROMPT)
84
+ pass = ask_for_password("password for #{user}")
85
+
86
+ params = {
87
+ :uri => uri,
88
+ :uri_username => user,
89
+ :uri_password => pass
90
+ }
91
+ params[:remote_file_name] = filename if filename
92
+
93
+ @task = "evm:db:#{action}:remote"
94
+ @task_params = ["--", params]
95
+ end
96
+
97
+ def ask_to_delete_backup_after_restore
98
+ if action == :restore && backup_type == LOCAL_FILE
99
+ say("The local database restore file is located at: '#{uri}'.\n")
100
+ @delete_agree = agree("Should this file be deleted after completing the restore? (Y/N): ")
101
+ end
102
+ end
103
+
104
+ def ask_for_tables_to_exclude_in_dump
105
+ if action == :dump && should_exclude_tables?
106
+ say(<<-PROMPT.strip_heredoc)
107
+
108
+ To exclude tables from the dump, enter them in a space separated
109
+ list. For example:
110
+
111
+ > metrics_* vim_performance_states event_streams
112
+
113
+ PROMPT
114
+ table_excludes = ask_for_many("table",
115
+ "tables to exclude",
116
+ "metrics_* vim_performance_states event_streams",
117
+ 255,
118
+ Float::INFINITY)
119
+
120
+ @task_params.last[:"exclude-table-data"] = table_excludes
121
+ end || true
122
+ end
123
+
124
+ def confirm_and_execute
125
+ if allowed_to_execute?
126
+ processing_message
127
+ run_rake
128
+ end
129
+ press_any_key
130
+ end
131
+
132
+ def allowed_to_execute?
133
+ return true unless action == :restore
134
+ say("\nNote: A database restore cannot be undone. The restore will use the file: #{uri}.\n")
135
+ agree("Are you sure you would like to restore the database? (Y/N): ")
136
+ end
137
+
138
+ def file_menu_args
139
+ [
140
+ action == :restore ? "Restore Database File" : "#{action.capitalize} Output File Name",
141
+ FILE_OPTIONS,
142
+ LOCAL_FILE,
143
+ nil
144
+ ]
145
+ end
146
+
147
+ def setting_header
148
+ say("#{I18n.t("advanced_settings.db#{action}")}\n\n")
149
+ end
150
+
151
+ private
152
+
153
+ def should_exclude_tables?
154
+ ask_yn?("Would you like to exclude tables in the dump") do |q|
155
+ q.readline = true
156
+ end
157
+ end
158
+
159
+ def filename_prompt_args
160
+ default = action == :dump ? DB_DEFAULT_DUMP_FILE : DB_RESTORE_FILE
161
+ validator = LOCAL_FILE_VALIDATOR if action == :restore && backup_type == LOCAL_FILE
162
+ [local_file_prompt, default, validator, "file that exists"]
163
+ end
164
+
165
+ def local_file_prompt
166
+ if action == :restore
167
+ "location of the local restore file"
168
+ else
169
+ "location to save the #{action} file to"
170
+ end
171
+ end
172
+
173
+ def remote_file_prompt_args_for(remote_type)
174
+ prompt = if action == :restore
175
+ "location of the remote backup file"
176
+ else
177
+ "location to save the remote #{action} file to"
178
+ end
179
+ prompt += "\nExample: #{SAMPLE_URLS[remote_type]}"
180
+ [prompt, remote_type]
181
+ end
182
+
183
+ def processing_message
184
+ msg = if action == :restore
185
+ "\nRestoring the database..."
186
+ else
187
+ "\nRunning Database #{action} to #{uri}..."
188
+ end
189
+ say(msg)
190
+ end
191
+
192
+ def run_rake
193
+ rake_success = ManageIQ::ApplianceConsole::Utilities.rake(task, task_params)
194
+ if rake_success && action == :restore && delete_agree
195
+ say("\nRemoving the database restore file #{uri}...")
196
+ File.delete(uri)
197
+ elsif !rake_success
198
+ say("\nDatabase #{action} failed. Check the logs for more information")
199
+ end
200
+ end
201
+ end
202
+ end
203
+ end
@@ -68,6 +68,7 @@ module ApplianceConsole
68
68
  begin
69
69
  save
70
70
  success = create_or_join_region
71
+ validate_encryption_key!
71
72
  rescue
72
73
  success = false
73
74
  ensure
@@ -266,6 +267,10 @@ FRIENDLY
266
267
  YAML.load_file(DB_YML)
267
268
  end
268
269
 
270
+ def validate_encryption_key!
271
+ raise "Encryption key invalid" unless ManageIQ::ApplianceConsole::Utilities.rake("evm:validate_encryption_key", {})
272
+ end
273
+
269
274
  def do_save(settings)
270
275
  require 'yaml'
271
276
  File.write(DB_YML, YAML.dump(settings))
@@ -1,5 +1,6 @@
1
1
  require 'pg'
2
2
  require 'English'
3
+ require 'util/postgres_admin'
3
4
 
4
5
  module ManageIQ
5
6
  module ApplianceConsole
@@ -11,7 +12,7 @@ module ApplianceConsole
11
12
  PGPASS_FILE = '/var/lib/pgsql/.pgpass'.freeze
12
13
  NETWORK_INTERFACE = 'eth0'.freeze
13
14
 
14
- attr_accessor :cluster_name, :node_number, :database_name, :database_user,
15
+ attr_accessor :node_number, :database_name, :database_user,
15
16
  :database_password, :primary_host
16
17
 
17
18
  def ask_for_unique_cluster_node_number
@@ -52,34 +53,25 @@ Replication Server Configuration
52
53
  end
53
54
 
54
55
  def config_file_contents(host)
56
+ service_name = PostgresAdmin.service_name
55
57
  <<-EOS.strip_heredoc
56
- cluster=#{cluster_name}
57
- node=#{node_number}
58
+ node_id=#{node_number}
58
59
  node_name=#{host}
59
60
  conninfo='host=#{host} user=#{database_user} dbname=#{database_name}'
60
61
  use_replication_slots=1
61
62
  pg_basebackup_options='--xlog-method=stream'
62
63
  failover=automatic
63
- promote_command='repmgr standby promote'
64
- follow_command='repmgr standby follow'
65
- logfile=#{REPMGR_LOG}
64
+ promote_command='repmgr standby promote -f #{REPMGR_CONFIG} --log-to-file'
65
+ follow_command='repmgr standby follow -f #{REPMGR_CONFIG} --log-to-file --upstream-node-id=%n'
66
+ log_file=#{REPMGR_LOG}
67
+ service_start_command='sudo systemctl start #{service_name}'
68
+ service_stop_command='sudo systemctl stop #{service_name}'
69
+ service_restart_command='sudo systemctl restart #{service_name}'
70
+ service_reload_command='sudo systemctl reload #{service_name}'
71
+ data_directory='#{PostgresAdmin.data_directory}'
66
72
  EOS
67
73
  end
68
74
 
69
- def generate_cluster_name
70
- begin
71
- pg_conn = PG::Connection.new(primary_connection_hash)
72
- primary_region_number =
73
- pg_conn.exec("SELECT last_value FROM miq_databases_id_seq").first["last_value"].to_i / 1_000_000_000_000
74
- self.cluster_name = "miq_region_#{primary_region_number}_cluster"
75
- rescue PG::ConnectionBad, PG::UndefinedTable => e
76
- say("Failed to get primary region number #{e.message}")
77
- logger.error("Failed to get primary region number #{e.message}")
78
- return false
79
- end
80
- true
81
- end
82
-
83
75
  def write_pgpass_file
84
76
  File.open(PGPASS_FILE, "w") do |f|
85
77
  f.write("*:*:#{database_name}:#{database_user}:#{database_password}\n")
@@ -3,10 +3,9 @@ module ApplianceConsole
3
3
  class DatabaseReplicationPrimary < DatabaseReplication
4
4
  include ManageIQ::ApplianceConsole::Logging
5
5
 
6
- REGISTER_CMD = 'repmgr master register'.freeze
6
+ REGISTER_CMD = 'repmgr primary register'.freeze
7
7
 
8
8
  def initialize
9
- self.cluster_name = nil
10
9
  self.node_number = nil
11
10
  self.database_name = "vmdb_production"
12
11
  self.database_user = "root"
@@ -30,30 +29,10 @@ module ApplianceConsole
30
29
 
31
30
  def activate
32
31
  say("Configuring Primary Replication Server...")
33
- generate_cluster_name &&
34
- create_config_file(primary_host) &&
35
- initialize_primary_server &&
32
+ create_config_file(primary_host) &&
33
+ run_repmgr_command(REGISTER_CMD) &&
36
34
  write_pgpass_file
37
35
  end
38
-
39
- def initialize_primary_server
40
- run_repmgr_command(REGISTER_CMD) &&
41
- add_repmgr_schema_to_search_path
42
- end
43
-
44
- def add_repmgr_schema_to_search_path
45
- schema_name = "repmgr_#{cluster_name}"
46
- begin
47
- pg_conn = PG::Connection.new(primary_connection_hash)
48
- new_path = pg_conn.exec("SHOW search_path").first["search_path"].split(",") << schema_name
49
- pg_conn.exec("ALTER ROLE #{database_user} SET search_path = #{new_path.join(",")}")
50
- rescue PG::ConnectionBad => e
51
- say("Failed to add #{schema_name} to search path for #{database_user} #{e.message}")
52
- logger.error("Failed to add #{schema_name} to search path for #{database_user} #{e.message}")
53
- return false
54
- end
55
- true
56
- end
57
36
  end # class DatabaseReplicationPrimary < DatabaseReplication
58
37
  end # module ApplianceConsole
59
38
  end
@@ -13,7 +13,6 @@ module ApplianceConsole
13
13
  attr_accessor :disk, :standby_host, :run_repmgrd_configuration, :resync_data, :force_register
14
14
 
15
15
  def initialize
16
- self.cluster_name = nil
17
16
  self.node_number = nil
18
17
  self.database_name = "vmdb_production"
19
18
  self.database_user = "root"
@@ -64,12 +63,11 @@ module ApplianceConsole
64
63
  initialize_postgresql_disk if disk
65
64
  PostgresAdmin.prep_data_directory if disk || resync_data
66
65
  save_database_yml
67
- generate_cluster_name &&
68
- create_config_file(standby_host) &&
66
+ create_config_file(standby_host) &&
67
+ write_pgpass_file &&
69
68
  clone_standby_server &&
70
69
  start_postgres &&
71
70
  register_standby_server &&
72
- write_pgpass_file &&
73
71
  (run_repmgrd_configuration ? start_repmgrd : true)
74
72
  end
75
73
 
@@ -108,7 +106,7 @@ module ApplianceConsole
108
106
  end
109
107
 
110
108
  def register_standby_server
111
- run_repmgr_command(REGISTER_CMD, :force => nil)
109
+ run_repmgr_command(REGISTER_CMD, :force => nil, :wait_sync= => 60)
112
110
  end
113
111
 
114
112
  def start_repmgrd
@@ -132,7 +130,7 @@ module ApplianceConsole
132
130
  return true if rec.nil?
133
131
  node_state = rec["active"] ? "active" : "inactive"
134
132
 
135
- say("An #{node_state} #{rec["type"]} node (#{rec["name"]}) with the node number #{node_number} already exists")
133
+ say("An #{node_state} #{rec["type"]} node (#{rec["node_name"]}) with the node number #{node_number} already exists")
136
134
  ask_yn?("Would you like to continue configuration by overwriting the existing node", "N")
137
135
 
138
136
  rescue PG::Error => e
@@ -151,8 +149,8 @@ module ApplianceConsole
151
149
  def record_for_node_number
152
150
  c = PG::Connection.new(primary_connection_hash)
153
151
  c.exec_params(<<-SQL, [node_number]).map_types!(PG::BasicTypeMapForResults.new(c)).first
154
- SELECT type, name, active
155
- FROM repl_nodes where id = $1
152
+ SELECT type, node_name, active
153
+ FROM repmgr.nodes where node_id = $1
156
154
  SQL
157
155
  end
158
156
 
@@ -7,9 +7,10 @@ module ApplianceConsole
7
7
  AUTH_PATH = "/authentication".freeze
8
8
 
9
9
  EXT_AUTH_OPTIONS = {
10
- "#{AUTH_PATH}/sso_enabled" => {:label => "Single Sign-On", :logic => true},
11
- "#{AUTH_PATH}/saml_enabled" => {:label => "SAML", :logic => true},
12
- "#{AUTH_PATH}/local_login_disabled" => {:label => "Local Login", :logic => false}
10
+ "#{AUTH_PATH}/sso_enabled" => {:label => "Single Sign-On", :logic => true},
11
+ "#{AUTH_PATH}/saml_enabled" => {:label => "SAML", :logic => true},
12
+ "#{AUTH_PATH}/oidc_enabled" => {:label => "OIDC", :logic => true},
13
+ "#{AUTH_PATH}/local_login_disabled" => {:label => "Local Login", :logic => false}
13
14
  }.freeze
14
15
 
15
16
  include ManageIQ::ApplianceConsole::Logging
@@ -42,6 +43,7 @@ module ApplianceConsole
42
43
  end
43
44
  end
44
45
  @updates = {} if selection == skip
46
+ @updates = {} unless validate_provider_type
45
47
  true
46
48
  end
47
49
 
@@ -79,11 +81,44 @@ module ApplianceConsole
79
81
  if update_hash.present?
80
82
  say("\nUpdating external authentication options on appliance ...")
81
83
  params = update_hash.collect { |key, value| "#{key}=#{value}" }
84
+ params = configure_provider_type!(params)
82
85
  result = ManageIQ::ApplianceConsole::Utilities.rake_run("evm:settings:set", params)
83
86
  raise parse_errors(result).join(', ') if result.failure?
84
87
  end
85
88
  end
86
89
 
90
+ def validate_provider_type
91
+ return true unless @updates["/authentication/oidc_enabled"] == true && @updates["/authentication/saml_enabled"] == true
92
+ say("\Error: Both SAML and OIDC can not be enabled ...")
93
+ false
94
+ end
95
+
96
+ def configure_provider_type!(params)
97
+ if params.include?("/authentication/saml_enabled=true")
98
+ configure_saml!(params)
99
+ elsif params.include?("/authentication/oidc_enabled=true")
100
+ configure_oidc!(params)
101
+ elsif params.include?("/authentication/oidc_enabled=false") || params.include?("/authentication/saml_enabled=false")
102
+ configure_none!(params)
103
+ end
104
+ end
105
+
106
+ def configure_saml!(params)
107
+ params << "/authentication/oidc_enabled=false"
108
+ params << "/authentication/provider_type=saml"
109
+ end
110
+
111
+ def configure_oidc!(params)
112
+ params << "/authentication/saml_enabled=false"
113
+ params << "/authentication/provider_type=oidc"
114
+ end
115
+
116
+ def configure_none!(params)
117
+ params << "/authentication/oidc_enabled=false"
118
+ params << "/authentication/saml_enabled=false"
119
+ params << "/authentication/provider_type=none"
120
+ end
121
+
87
122
  # extauth_opts option parser: syntax is key=value,key=value
88
123
  # key is one of the EXT_AUTH_OPTIONS keys.
89
124
  # value is one of 1, true, 0 or false.
@@ -0,0 +1,13 @@
1
+ require 'i18n'
2
+ require 'pathname'
3
+
4
+ gem_root = Pathname.new(__dir__).join("..", "..", "..")
5
+
6
+ locales_dir = ENV['CONTAINER'] ? "container" : "appliance"
7
+ locales_paths = [
8
+ gem_root.join("locales", locales_dir, "*.yml"),
9
+ File.expand_path(File.join("productization/appliance_console/locales", locales_dir, "*.yml"), ManageIQ::ApplianceConsole::RAILS_ROOT)
10
+ ]
11
+ locales_paths.each { |p| I18n.load_path += Dir[p].sort }
12
+ I18n.enforce_available_locales = true
13
+ I18n.backend.load_translations
@@ -63,6 +63,7 @@ module ApplianceConsole
63
63
  q.default = default if default
64
64
  q.validate = ->(p) { (p.blank? && default) || %w(y n).include?(p.downcase[0]) }
65
65
  q.responses[:not_valid] = "Please provide yes or no."
66
+ yield q if block_given?
66
67
  end.downcase[0] == 'y'
67
68
  end
68
69
 
@@ -1,5 +1,5 @@
1
1
  module ManageIQ
2
2
  module ApplianceConsole
3
- VERSION = '2.0.3'.freeze
3
+ VERSION = '3.0.0'.freeze
4
4
  end
5
5
  end
@@ -7,6 +7,8 @@ en:
7
7
  - networking
8
8
  - timezone
9
9
  - datetime
10
+ - dbbackup
11
+ - dbdump
10
12
  - dbrestore
11
13
  - db_config
12
14
  - db_replication
@@ -24,6 +26,8 @@ en:
24
26
  networking: Configure Network
25
27
  timezone: Set Timezone
26
28
  datetime: Set Date and Time
29
+ dbbackup: Create Database Backup
30
+ dbdump: Create Database Dump
27
31
  dbrestore: Restore Database From Backup
28
32
  db_config: Configure Database
29
33
  db_replication: Configure Database Replication
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manageiq-appliance_console
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ManageIQ Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-03 00:00:00.000000000 Z
11
+ date: 2018-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -247,6 +247,7 @@ files:
247
247
  - lib/manageiq/appliance_console/certificate.rb
248
248
  - lib/manageiq/appliance_console/certificate_authority.rb
249
249
  - lib/manageiq/appliance_console/cli.rb
250
+ - lib/manageiq/appliance_console/database_admin.rb
250
251
  - lib/manageiq/appliance_console/database_configuration.rb
251
252
  - lib/manageiq/appliance_console/database_replication.rb
252
253
  - lib/manageiq/appliance_console/database_replication_primary.rb
@@ -257,6 +258,7 @@ files:
257
258
  - lib/manageiq/appliance_console/external_database_configuration.rb
258
259
  - lib/manageiq/appliance_console/external_httpd_authentication.rb
259
260
  - lib/manageiq/appliance_console/external_httpd_authentication/external_httpd_configuration.rb
261
+ - lib/manageiq/appliance_console/i18n.rb
260
262
  - lib/manageiq/appliance_console/internal_database_configuration.rb
261
263
  - lib/manageiq/appliance_console/key_configuration.rb
262
264
  - lib/manageiq/appliance_console/logfile_configuration.rb
@@ -294,7 +296,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
294
296
  version: '0'
295
297
  requirements: []
296
298
  rubyforge_project:
297
- rubygems_version: 2.7.6
299
+ rubygems_version: 2.7.7
298
300
  signing_key:
299
301
  specification_version: 4
300
302
  summary: ManageIQ Appliance Console