manageiq-appliance_console 5.4.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +24 -25
  3. data/.rspec_ci +2 -0
  4. data/.rubocop.yml +3 -3
  5. data/.rubocop_cc.yml +3 -4
  6. data/.rubocop_local.yml +1 -1
  7. data/.travis.yml +4 -3
  8. data/Gemfile +1 -3
  9. data/README.md +1 -2
  10. data/Rakefile +20 -1
  11. data/bin/appliance_console +30 -6
  12. data/lib/manageiq-appliance_console.rb +2 -6
  13. data/lib/manageiq/appliance_console/certificate_authority.rb +1 -1
  14. data/lib/manageiq/appliance_console/cli.rb +166 -69
  15. data/lib/manageiq/appliance_console/database_admin.rb +35 -206
  16. data/lib/manageiq/appliance_console/database_configuration.rb +10 -2
  17. data/lib/manageiq/appliance_console/database_replication.rb +1 -1
  18. data/lib/manageiq/appliance_console/database_replication_standby.rb +1 -1
  19. data/lib/manageiq/appliance_console/external_auth_options.rb +3 -13
  20. data/lib/manageiq/appliance_console/internal_database_configuration.rb +4 -12
  21. data/lib/manageiq/appliance_console/key_configuration.rb +8 -1
  22. data/lib/manageiq/appliance_console/logfile_configuration.rb +2 -2
  23. data/lib/manageiq/appliance_console/manageiq_user_mixin.rb +15 -0
  24. data/lib/manageiq/appliance_console/message_configuration.rb +205 -0
  25. data/lib/manageiq/appliance_console/message_configuration_client.rb +98 -0
  26. data/lib/manageiq/appliance_console/message_configuration_server.rb +321 -0
  27. data/lib/manageiq/appliance_console/oidc_authentication.rb +43 -4
  28. data/lib/manageiq/appliance_console/postgres_admin.rb +412 -0
  29. data/lib/manageiq/appliance_console/utilities.rb +55 -1
  30. data/lib/manageiq/appliance_console/version.rb +1 -1
  31. data/locales/appliance/en.yml +1 -17
  32. data/locales/container/en.yml +1 -1
  33. data/manageiq-appliance_console.gemspec +4 -3
  34. metadata +46 -28
  35. data/lib/manageiq/appliance_console/messaging_configuration.rb +0 -92
@@ -1,6 +1,6 @@
1
1
  # TODO: add appropriate requires instead of depending on appliance_console.rb.
2
2
  # TODO: Further refactor these unrelated methods.
3
- require "util/postgres_admin"
3
+ require "manageiq/appliance_console/postgres_admin"
4
4
  require "awesome_spawn"
5
5
 
6
6
  module ManageIQ
@@ -16,6 +16,16 @@ module ApplianceConsole
16
16
  result
17
17
  end
18
18
 
19
+ def self.rake_run!(task, params)
20
+ result = rake_run(task, params)
21
+ if result.failure?
22
+ parsed_errors = result.error.split("\n").select { |line| line.match?(/^error: /i) }.join(', ')
23
+ raise parsed_errors
24
+ end
25
+
26
+ result
27
+ end
28
+
19
29
  def self.db_connections
20
30
  result = AwesomeSpawn.run("bin/rails runner",
21
31
  :params => ["exit EvmDatabaseOps.database_connections"],
@@ -62,6 +72,50 @@ module ApplianceConsole
62
72
  say(" " + h + ': ' + (Net::Ping::External.new(h).ping ? 'Success!' : 'Failure, Check network settings and IP address or hostname provided.'))
63
73
  end
64
74
  end
75
+
76
+ def self.disk_usage(file = nil)
77
+ file_arg = file
78
+ file_arg = "-l" if file.nil? || file == ""
79
+
80
+ unless file_arg == "-l" || File.exist?(file)
81
+ raise "file #{file} does not exist"
82
+ end
83
+
84
+ # Collect bytes
85
+ result = AwesomeSpawn.run!("df", :params => ["-T", "-P", file_arg]).output.lines.each_with_object([]) do |line, array|
86
+ lArray = line.strip.split(" ")
87
+ next if lArray.length != 7
88
+ fsname, type, total, used, free, used_percentage, mount_point = lArray
89
+ next unless total =~ /[0-9]+/
90
+ next if array.detect { |hh| hh[:filesystem] == fsname }
91
+
92
+ array << {
93
+ :filesystem => fsname,
94
+ :type => type,
95
+ :total_bytes => total.to_i * 1024,
96
+ :used_bytes => used.to_i * 1024,
97
+ :available_bytes => free.to_i * 1024,
98
+ :used_bytes_percent => used_percentage.chomp("%").to_i,
99
+ :mount_point => mount_point,
100
+ }
101
+ end
102
+
103
+ # Collect inodes
104
+ AwesomeSpawn.run!("df", :params => ["-T", "-P", "-i", file_arg]).output.lines.each do |line|
105
+ lArray = line.strip.split(" ")
106
+ next if lArray.length != 7
107
+ fsname, _type, total, used, free, used_percentage, _mount_point = lArray
108
+ next unless total =~ /[0-9]+/
109
+ h = result.detect { |hh| hh[:filesystem] == fsname }
110
+ next if h.nil?
111
+
112
+ h[:total_inodes] = total.to_i
113
+ h[:used_inodes] = used.to_i
114
+ h[:available_inodes] = free.to_i
115
+ h[:used_inodes_percent] = used_percentage.chomp("%").to_i
116
+ end
117
+ result
118
+ end
65
119
  end
66
120
  end
67
121
  end
@@ -1,5 +1,5 @@
1
1
  module ManageIQ
2
2
  module ApplianceConsole
3
- VERSION = '5.4.0'.freeze
3
+ VERSION = '7.0.0'.freeze
4
4
  end
5
5
  end
@@ -28,7 +28,7 @@ en:
28
28
  app_config: Configure Application
29
29
  db_replication: Configure Database Replication
30
30
  log_config: Logfile Configuration
31
- failover_monitor: Configure Application Database Failover Monitor
31
+ failover_monitor: Control Application Database Failover Monitor
32
32
  httpdauth: Configure External Authentication (httpd)
33
33
  extauth_opts: Update External Authentication Options
34
34
  evmstop: Stop EVM Server Processes
@@ -39,22 +39,6 @@ en:
39
39
  summary: Summary Information
40
40
  quit: Quit
41
41
  database_admin:
42
- menu_order:
43
- - local
44
- - nfs
45
- - smb
46
- - s3
47
- - ftp
48
- - swift
49
42
  local: Local file
50
- nfs: Network File System (NFS)
51
- smb: Samba (SMB)
52
- s3: Amazon S3 (S3)
53
- ftp: File Transfer Protocol (FTP)
54
- swift: OpenStack Swift (Swift)
55
43
  sample_url:
56
44
  nfs: nfs://host.mydomain.com/exported/my_exported_folder/db.backup
57
- smb: smb://host.mydomain.com/my_share/daily_backup/db.backup
58
- s3: s3://mybucket/my_subdirectory/daily_backup/db.backup
59
- ftp: ftp://host.mydomain.com/path/to/daily_backup/db.backup
60
- swift: swift://host.mydomain.com/path/to/daily_backup/db.backup
@@ -17,7 +17,7 @@ en:
17
17
  dbrestore: Restore Database From Backup
18
18
  app_config: Configure Application
19
19
  db_replication: Configure Database Replication
20
- failover_monitor: Configure Application Database Failover Monitor
20
+ failover_monitor: Control Application Database Failover Monitor
21
21
  evmstop: Stop EVM Server Processes
22
22
  key_gen: Generate Custom Encryption Key
23
23
  evmstart: Start EVM Server Processes
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_runtime_dependency "activerecord", ">= 4.2.2"
24
- spec.add_runtime_dependency "activesupport", ">= 4.2.2"
23
+ spec.add_runtime_dependency "activerecord", "~> 6.0.3.5"
24
+ spec.add_runtime_dependency "activesupport", "~> 6.0.3.5"
25
25
  spec.add_runtime_dependency "awesome_spawn", "~> 1.4"
26
26
  spec.add_runtime_dependency "bcrypt", "~> 3.1.10"
27
27
  spec.add_runtime_dependency "bcrypt_pbkdf", ">= 1.0", "< 2.0"
@@ -32,11 +32,12 @@ Gem::Specification.new do |spec|
32
32
  spec.add_runtime_dependency "net-scp", "~> 1.2.1"
33
33
  spec.add_runtime_dependency "optimist", "~> 3.0"
34
34
  spec.add_runtime_dependency "pg"
35
+ spec.add_runtime_dependency "pg-logical_replication"
35
36
  spec.add_runtime_dependency "rbnacl", ">= 3.2", "< 5.0"
36
- spec.add_runtime_dependency "rbnacl-libsodium"
37
37
 
38
38
  spec.add_development_dependency "bundler"
39
39
  spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
40
+ spec.add_development_dependency "manageiq-style"
40
41
  spec.add_development_dependency "rake"
41
42
  spec.add_development_dependency "rspec", "~> 3.0"
42
43
  spec.add_development_dependency "rubocop"
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manageiq-appliance_console
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.0
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ManageIQ Developers
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-14 00:00:00.000000000 Z
11
+ date: 2021-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.2
19
+ version: 6.0.3.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 4.2.2
26
+ version: 6.0.3.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 4.2.2
33
+ version: 6.0.3.5
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 4.2.2
40
+ version: 6.0.3.5
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: awesome_spawn
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -185,39 +185,39 @@ dependencies:
185
185
  - !ruby/object:Gem::Version
186
186
  version: '0'
187
187
  - !ruby/object:Gem::Dependency
188
- name: rbnacl
188
+ name: pg-logical_replication
189
189
  requirement: !ruby/object:Gem::Requirement
190
190
  requirements:
191
191
  - - ">="
192
192
  - !ruby/object:Gem::Version
193
- version: '3.2'
194
- - - "<"
195
- - !ruby/object:Gem::Version
196
- version: '5.0'
193
+ version: '0'
197
194
  type: :runtime
198
195
  prerelease: false
199
196
  version_requirements: !ruby/object:Gem::Requirement
200
197
  requirements:
201
198
  - - ">="
202
199
  - !ruby/object:Gem::Version
203
- version: '3.2'
204
- - - "<"
205
- - !ruby/object:Gem::Version
206
- version: '5.0'
200
+ version: '0'
207
201
  - !ruby/object:Gem::Dependency
208
- name: rbnacl-libsodium
202
+ name: rbnacl
209
203
  requirement: !ruby/object:Gem::Requirement
210
204
  requirements:
211
205
  - - ">="
212
206
  - !ruby/object:Gem::Version
213
- version: '0'
207
+ version: '3.2'
208
+ - - "<"
209
+ - !ruby/object:Gem::Version
210
+ version: '5.0'
214
211
  type: :runtime
215
212
  prerelease: false
216
213
  version_requirements: !ruby/object:Gem::Requirement
217
214
  requirements:
218
215
  - - ">="
219
216
  - !ruby/object:Gem::Version
220
- version: '0'
217
+ version: '3.2'
218
+ - - "<"
219
+ - !ruby/object:Gem::Version
220
+ version: '5.0'
221
221
  - !ruby/object:Gem::Dependency
222
222
  name: bundler
223
223
  requirement: !ruby/object:Gem::Requirement
@@ -246,6 +246,20 @@ dependencies:
246
246
  - - "~>"
247
247
  - !ruby/object:Gem::Version
248
248
  version: 1.0.0
249
+ - !ruby/object:Gem::Dependency
250
+ name: manageiq-style
251
+ requirement: !ruby/object:Gem::Requirement
252
+ requirements:
253
+ - - ">="
254
+ - !ruby/object:Gem::Version
255
+ version: '0'
256
+ type: :development
257
+ prerelease: false
258
+ version_requirements: !ruby/object:Gem::Requirement
259
+ requirements:
260
+ - - ">="
261
+ - !ruby/object:Gem::Version
262
+ version: '0'
249
263
  - !ruby/object:Gem::Dependency
250
264
  name: rake
251
265
  requirement: !ruby/object:Gem::Requirement
@@ -303,7 +317,7 @@ dependencies:
303
317
  - !ruby/object:Gem::Version
304
318
  version: '0'
305
319
  description: ManageIQ Appliance Console
306
- email:
320
+ email:
307
321
  executables:
308
322
  - appliance_console
309
323
  - appliance_console_cli
@@ -347,8 +361,12 @@ files:
347
361
  - lib/manageiq/appliance_console/logger.rb
348
362
  - lib/manageiq/appliance_console/logging.rb
349
363
  - lib/manageiq/appliance_console/logical_volume_management.rb
350
- - lib/manageiq/appliance_console/messaging_configuration.rb
364
+ - lib/manageiq/appliance_console/manageiq_user_mixin.rb
365
+ - lib/manageiq/appliance_console/message_configuration.rb
366
+ - lib/manageiq/appliance_console/message_configuration_client.rb
367
+ - lib/manageiq/appliance_console/message_configuration_server.rb
351
368
  - lib/manageiq/appliance_console/oidc_authentication.rb
369
+ - lib/manageiq/appliance_console/postgres_admin.rb
352
370
  - lib/manageiq/appliance_console/principal.rb
353
371
  - lib/manageiq/appliance_console/prompts.rb
354
372
  - lib/manageiq/appliance_console/saml_authentication.rb
@@ -364,7 +382,7 @@ homepage: https://github.com/ManageIQ/manageiq-appliance_console
364
382
  licenses:
365
383
  - Apache-2.0
366
384
  metadata: {}
367
- post_install_message:
385
+ post_install_message:
368
386
  rdoc_options: []
369
387
  require_paths:
370
388
  - lib
@@ -379,8 +397,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
379
397
  - !ruby/object:Gem::Version
380
398
  version: '0'
381
399
  requirements: []
382
- rubygems_version: 3.0.6
383
- signing_key:
400
+ rubygems_version: 3.2.17
401
+ signing_key:
384
402
  specification_version: 4
385
403
  summary: ManageIQ Appliance Console
386
404
  test_files: []
@@ -1,92 +0,0 @@
1
- require "pathname"
2
-
3
- module ManageIQ
4
- module ApplianceConsole
5
- class MessagingConfiguration
6
- include ManageIQ::ApplianceConsole::Logging
7
- include ManageIQ::ApplianceConsole::Prompts
8
-
9
- MESSAGING_YML = ManageIQ::ApplianceConsole::RAILS_ROOT.join("config/messaging.yml")
10
-
11
- attr_accessor :host, :password, :port, :username
12
-
13
- def run_interactive
14
- ask_questions
15
-
16
- clear_screen
17
- say("Activating the configuration using the following settings...\n#{friendly_inspect}\n")
18
-
19
- raise MiqSignalError unless activate
20
-
21
- say("\nConfiguration activated successfully.\n")
22
- rescue RuntimeError => e
23
- puts "Configuration failed#{": " + e.message unless e.class == MiqSignalError}"
24
- press_any_key
25
- raise MiqSignalError
26
- end
27
-
28
- def ask_questions
29
- ask_for_messaging_credentials
30
- end
31
-
32
- def ask_for_messaging_credentials
33
- self.host = ask_for_ip_or_hostname("messaging hostname or IP address")
34
- self.port = ask_for_integer("port number", (1..65_535), 9_092).to_i
35
- self.username = just_ask("username")
36
- count = 0
37
- loop do
38
- password1 = ask_for_password("messaging password on #{host}")
39
-
40
- if password1.strip.empty?
41
- say("\nPassword can not be empty, please try again")
42
- next
43
- end
44
-
45
- password2 = ask_for_password("messaging password again")
46
- if password1 == password2
47
- self.password = password1
48
- break
49
- elsif count > 0 # only reprompt password once
50
- raise "passwords did not match"
51
- else
52
- count += 1
53
- say("\nThe passwords did not match, please try again")
54
- end
55
- end
56
- end
57
-
58
- def friendly_inspect
59
- <<~END_OF_INSPECT
60
- Host: #{host}
61
- Username: #{username}
62
- Port: #{port}
63
- END_OF_INSPECT
64
- end
65
-
66
- def activate
67
- save
68
- true
69
- end
70
-
71
- private
72
-
73
- def settings_from_input
74
- {
75
- "hostname" => host,
76
- "password" => password,
77
- "port" => port,
78
- "username" => username
79
- }
80
- end
81
-
82
- def save(settings = nil)
83
- settings ||= settings_from_input
84
-
85
- settings["password"] = MiqPassword.try_encrypt(settings.delete("password"))
86
-
87
- require 'yaml'
88
- File.write(MESSAGING_YML, YAML.dump("production" => settings))
89
- end
90
- end
91
- end
92
- end