manageiq-appliance_console 5.5.0 → 7.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) 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/certificate_authority.rb +1 -1
  13. data/lib/manageiq/appliance_console/cli.rb +166 -70
  14. data/lib/manageiq/appliance_console/database_admin.rb +35 -206
  15. data/lib/manageiq/appliance_console/database_configuration.rb +10 -2
  16. data/lib/manageiq/appliance_console/database_replication.rb +1 -1
  17. data/lib/manageiq/appliance_console/database_replication_standby.rb +1 -1
  18. data/lib/manageiq/appliance_console/external_auth_options.rb +3 -13
  19. data/lib/manageiq/appliance_console/internal_database_configuration.rb +4 -12
  20. data/lib/manageiq/appliance_console/key_configuration.rb +8 -1
  21. data/lib/manageiq/appliance_console/logfile_configuration.rb +2 -2
  22. data/lib/manageiq/appliance_console/manageiq_user_mixin.rb +15 -0
  23. data/lib/manageiq/appliance_console/message_configuration.rb +205 -0
  24. data/lib/manageiq/appliance_console/message_configuration_client.rb +98 -0
  25. data/lib/manageiq/appliance_console/message_configuration_server.rb +321 -0
  26. data/lib/manageiq/appliance_console/oidc_authentication.rb +27 -1
  27. data/lib/manageiq/appliance_console/postgres_admin.rb +412 -0
  28. data/lib/manageiq/appliance_console/utilities.rb +61 -2
  29. data/lib/manageiq/appliance_console/version.rb +1 -1
  30. data/lib/manageiq-appliance_console.rb +2 -6
  31. data/locales/appliance/en.yml +0 -16
  32. data/manageiq-appliance_console.gemspec +4 -3
  33. metadata +54 -24
  34. 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,9 +16,24 @@ 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
30
+ code = [
31
+ "database ||= ActiveRecord::Base.configurations[Rails.env]['database']",
32
+ "conn = ActiveRecord::Base.connection",
33
+ "exit conn.client_connections.count { |c| c['database'] == database }"
34
+ ]
20
35
  result = AwesomeSpawn.run("bin/rails runner",
21
- :params => ["exit EvmDatabaseOps.database_connections"],
36
+ :params => [code.join("; ")],
22
37
  :chdir => ManageIQ::ApplianceConsole::RAILS_ROOT
23
38
  )
24
39
  Integer(result.exit_status)
@@ -62,6 +77,50 @@ module ApplianceConsole
62
77
  say(" " + h + ': ' + (Net::Ping::External.new(h).ping ? 'Success!' : 'Failure, Check network settings and IP address or hostname provided.'))
63
78
  end
64
79
  end
80
+
81
+ def self.disk_usage(file = nil)
82
+ file_arg = file
83
+ file_arg = "-l" if file.nil? || file == ""
84
+
85
+ unless file_arg == "-l" || File.exist?(file)
86
+ raise "file #{file} does not exist"
87
+ end
88
+
89
+ # Collect bytes
90
+ result = AwesomeSpawn.run!("df", :params => ["-T", "-P", file_arg]).output.lines.each_with_object([]) do |line, array|
91
+ lArray = line.strip.split(" ")
92
+ next if lArray.length != 7
93
+ fsname, type, total, used, free, used_percentage, mount_point = lArray
94
+ next unless total =~ /[0-9]+/
95
+ next if array.detect { |hh| hh[:filesystem] == fsname }
96
+
97
+ array << {
98
+ :filesystem => fsname,
99
+ :type => type,
100
+ :total_bytes => total.to_i * 1024,
101
+ :used_bytes => used.to_i * 1024,
102
+ :available_bytes => free.to_i * 1024,
103
+ :used_bytes_percent => used_percentage.chomp("%").to_i,
104
+ :mount_point => mount_point,
105
+ }
106
+ end
107
+
108
+ # Collect inodes
109
+ AwesomeSpawn.run!("df", :params => ["-T", "-P", "-i", file_arg]).output.lines.each do |line|
110
+ lArray = line.strip.split(" ")
111
+ next if lArray.length != 7
112
+ fsname, _type, total, used, free, used_percentage, _mount_point = lArray
113
+ next unless total =~ /[0-9]+/
114
+ h = result.detect { |hh| hh[:filesystem] == fsname }
115
+ next if h.nil?
116
+
117
+ h[:total_inodes] = total.to_i
118
+ h[:used_inodes] = used.to_i
119
+ h[:available_inodes] = free.to_i
120
+ h[:used_inodes_percent] = used_percentage.chomp("%").to_i
121
+ end
122
+ result
123
+ end
65
124
  end
66
125
  end
67
126
  end
@@ -1,5 +1,5 @@
1
1
  module ManageIQ
2
2
  module ApplianceConsole
3
- VERSION = '5.5.0'.freeze
3
+ VERSION = '7.0.1'.freeze
4
4
  end
5
5
  end
@@ -11,10 +11,6 @@ module ManageIQ
11
11
  def self.logger
12
12
  @logger ||= ManageIQ::ApplianceConsole::Logger.instance
13
13
  end
14
-
15
- def self.logger=(logger)
16
- @logger = logger
17
- end
18
14
  end
19
15
  end
20
16
 
@@ -24,7 +20,6 @@ require 'manageiq/appliance_console/logger'
24
20
  require 'manageiq/appliance_console/logging'
25
21
  require 'manageiq/appliance_console/prompts'
26
22
 
27
- require 'manageiq-gems-pending'
28
23
  require 'highline'
29
24
 
30
25
  require 'manageiq/appliance_console/auth_utilities'
@@ -43,7 +38,8 @@ require 'manageiq/appliance_console/internal_database_configuration'
43
38
  require 'manageiq/appliance_console/key_configuration'
44
39
  require 'manageiq/appliance_console/logfile_configuration'
45
40
  require 'manageiq/appliance_console/logical_volume_management'
46
- require 'manageiq/appliance_console/messaging_configuration'
41
+ require 'manageiq/appliance_console/message_configuration_client'
42
+ require 'manageiq/appliance_console/message_configuration_server'
47
43
  require 'manageiq/appliance_console/oidc_authentication'
48
44
  require 'manageiq/appliance_console/principal'
49
45
  require 'manageiq/appliance_console/saml_authentication'
@@ -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
@@ -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.4", ">= 6.0.4.1"
24
+ spec.add_runtime_dependency "activesupport", "~> 6.0.4", ">= 6.0.4.1"
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,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manageiq-appliance_console
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.0
4
+ version: 7.0.1
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-05-13 00:00:00.000000000 Z
11
+ date: 2021-09-15 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
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.0.4
17
20
  - - ">="
18
21
  - !ruby/object:Gem::Version
19
- version: 4.2.2
22
+ version: 6.0.4.1
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 6.0.4
24
30
  - - ">="
25
31
  - !ruby/object:Gem::Version
26
- version: 4.2.2
32
+ version: 6.0.4.1
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: activesupport
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 6.0.4
31
40
  - - ">="
32
41
  - !ruby/object:Gem::Version
33
- version: 4.2.2
42
+ version: 6.0.4.1
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: 6.0.4
38
50
  - - ">="
39
51
  - !ruby/object:Gem::Version
40
- version: 4.2.2
52
+ version: 6.0.4.1
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: awesome_spawn
43
55
  requirement: !ruby/object:Gem::Requirement
@@ -185,39 +197,39 @@ dependencies:
185
197
  - !ruby/object:Gem::Version
186
198
  version: '0'
187
199
  - !ruby/object:Gem::Dependency
188
- name: rbnacl
200
+ name: pg-logical_replication
189
201
  requirement: !ruby/object:Gem::Requirement
190
202
  requirements:
191
203
  - - ">="
192
204
  - !ruby/object:Gem::Version
193
- version: '3.2'
194
- - - "<"
195
- - !ruby/object:Gem::Version
196
- version: '5.0'
205
+ version: '0'
197
206
  type: :runtime
198
207
  prerelease: false
199
208
  version_requirements: !ruby/object:Gem::Requirement
200
209
  requirements:
201
210
  - - ">="
202
211
  - !ruby/object:Gem::Version
203
- version: '3.2'
204
- - - "<"
205
- - !ruby/object:Gem::Version
206
- version: '5.0'
212
+ version: '0'
207
213
  - !ruby/object:Gem::Dependency
208
- name: rbnacl-libsodium
214
+ name: rbnacl
209
215
  requirement: !ruby/object:Gem::Requirement
210
216
  requirements:
211
217
  - - ">="
212
218
  - !ruby/object:Gem::Version
213
- version: '0'
219
+ version: '3.2'
220
+ - - "<"
221
+ - !ruby/object:Gem::Version
222
+ version: '5.0'
214
223
  type: :runtime
215
224
  prerelease: false
216
225
  version_requirements: !ruby/object:Gem::Requirement
217
226
  requirements:
218
227
  - - ">="
219
228
  - !ruby/object:Gem::Version
220
- version: '0'
229
+ version: '3.2'
230
+ - - "<"
231
+ - !ruby/object:Gem::Version
232
+ version: '5.0'
221
233
  - !ruby/object:Gem::Dependency
222
234
  name: bundler
223
235
  requirement: !ruby/object:Gem::Requirement
@@ -246,6 +258,20 @@ dependencies:
246
258
  - - "~>"
247
259
  - !ruby/object:Gem::Version
248
260
  version: 1.0.0
261
+ - !ruby/object:Gem::Dependency
262
+ name: manageiq-style
263
+ requirement: !ruby/object:Gem::Requirement
264
+ requirements:
265
+ - - ">="
266
+ - !ruby/object:Gem::Version
267
+ version: '0'
268
+ type: :development
269
+ prerelease: false
270
+ version_requirements: !ruby/object:Gem::Requirement
271
+ requirements:
272
+ - - ">="
273
+ - !ruby/object:Gem::Version
274
+ version: '0'
249
275
  - !ruby/object:Gem::Dependency
250
276
  name: rake
251
277
  requirement: !ruby/object:Gem::Requirement
@@ -303,7 +329,7 @@ dependencies:
303
329
  - !ruby/object:Gem::Version
304
330
  version: '0'
305
331
  description: ManageIQ Appliance Console
306
- email:
332
+ email:
307
333
  executables:
308
334
  - appliance_console
309
335
  - appliance_console_cli
@@ -347,8 +373,12 @@ files:
347
373
  - lib/manageiq/appliance_console/logger.rb
348
374
  - lib/manageiq/appliance_console/logging.rb
349
375
  - lib/manageiq/appliance_console/logical_volume_management.rb
350
- - lib/manageiq/appliance_console/messaging_configuration.rb
376
+ - lib/manageiq/appliance_console/manageiq_user_mixin.rb
377
+ - lib/manageiq/appliance_console/message_configuration.rb
378
+ - lib/manageiq/appliance_console/message_configuration_client.rb
379
+ - lib/manageiq/appliance_console/message_configuration_server.rb
351
380
  - lib/manageiq/appliance_console/oidc_authentication.rb
381
+ - lib/manageiq/appliance_console/postgres_admin.rb
352
382
  - lib/manageiq/appliance_console/principal.rb
353
383
  - lib/manageiq/appliance_console/prompts.rb
354
384
  - lib/manageiq/appliance_console/saml_authentication.rb
@@ -364,7 +394,7 @@ homepage: https://github.com/ManageIQ/manageiq-appliance_console
364
394
  licenses:
365
395
  - Apache-2.0
366
396
  metadata: {}
367
- post_install_message:
397
+ post_install_message:
368
398
  rdoc_options: []
369
399
  require_paths:
370
400
  - lib
@@ -379,8 +409,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
379
409
  - !ruby/object:Gem::Version
380
410
  version: '0'
381
411
  requirements: []
382
- rubygems_version: 3.0.6
383
- signing_key:
412
+ rubygems_version: 3.2.22
413
+ signing_key:
384
414
  specification_version: 4
385
415
  summary: ManageIQ Appliance Console
386
416
  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