hammer_cli_foreman_virt_who_configure 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hammer_cli_foreman_virt_who_configure/config.rb +28 -26
  3. data/lib/hammer_cli_foreman_virt_who_configure/i18n.rb +2 -0
  4. data/lib/hammer_cli_foreman_virt_who_configure/system_caller.rb +3 -1
  5. data/lib/hammer_cli_foreman_virt_who_configure/version.rb +3 -1
  6. data/lib/hammer_cli_foreman_virt_who_configure.rb +5 -3
  7. data/locale/bn/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  8. data/locale/bn_IN/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  9. data/locale/bqi/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  10. data/locale/ca/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  11. data/locale/cs_CZ/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  12. data/locale/de/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  13. data/locale/de_AT/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  14. data/locale/de_DE/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  15. data/locale/el/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  16. data/locale/en/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  17. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  18. data/locale/en_US/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  19. data/locale/es/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  20. data/locale/et_EE/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  21. data/locale/fr/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  22. data/locale/gl/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  23. data/locale/gu/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  24. data/locale/he_IL/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  25. data/locale/hi/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  26. data/locale/id/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  27. data/locale/it/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  28. data/locale/ja/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  29. data/locale/ka/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  30. data/locale/kn/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  31. data/locale/ko/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  32. data/locale/ml_IN/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  33. data/locale/mr/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  34. data/locale/nl_NL/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  35. data/locale/or/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  36. data/locale/pa/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  37. data/locale/pl/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  38. data/locale/pl_PL/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  39. data/locale/pt/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  40. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  41. data/locale/ro/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  42. data/locale/ro_RO/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  43. data/locale/ru/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  44. data/locale/sl/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  45. data/locale/sv_SE/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  46. data/locale/ta/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  47. data/locale/ta_IN/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  48. data/locale/te/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  49. data/locale/tr/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  50. data/locale/vi/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  51. data/locale/vi_VN/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  52. data/locale/zh/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  53. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  54. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
  55. data/test/data/3.11/foreman_api.json +1 -0
  56. data/test/functional/config/config_create_test.rb +16 -24
  57. data/test/functional/config/config_deploy_test.rb +16 -14
  58. data/test/functional/config/config_fetch_test.rb +12 -10
  59. data/test/functional/config/config_info_test.rb +45 -43
  60. data/test/functional/config/config_list_test.rb +11 -9
  61. data/test/functional/config/config_update_test.rb +7 -5
  62. data/test/functional/test_helper.rb +22 -20
  63. data/test/test_helper.rb +4 -3
  64. data/test/unit/system_caller_test.rb +3 -1
  65. metadata +187 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa67ec96782ac99c36a99614216817e60422d1b7b7ef99f21152c806a610560f
4
- data.tar.gz: 3f3b9692d4eb19636b444aed17ae030a4dcb31b5a5963eadaab16305c7740832
3
+ metadata.gz: fce0d55b84baaf7c230353820665c88c6053b7f62253231a3e0d17d57663d0bc
4
+ data.tar.gz: 22219b792cfe77a3500a149641a579fd28100ca3b084b75e99137b2415cf26f8
5
5
  SHA512:
6
- metadata.gz: 7b4f624d8ef5af1d65781be5511f292cde27dbc52ba095eec6fd3871b3244466af51fe67d7ca19b36fcea2ca05a51d28d93da195d6fa67759bea337b3019456a
7
- data.tar.gz: 5180c3415c4d94a6721b589a17761cbd04da023ed433075177efb61a73b2cde5fb7c91a7004ff61aed04524684c3c68285a6b116e6a0d12fdc49af470063a930
6
+ metadata.gz: 71786def3416e05021baa313753105a35e6eee7faa2d6fe259a228539a42e8240bce786a7ca5271b9ec2245a450b404f598d3e802879ebf4cb347ea7c47f2536
7
+ data.tar.gz: 8cf7a835c06daedd8c44b7907167b22aa245c727e508f9847c60540a9d81d3067ace69d29f983934bfacf49935b563f8ca9cafdc0b2883c847f074f6bcc6dab4
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'hammer_cli_foreman_virt_who_configure/system_caller'
2
4
 
3
5
  module HammerCLIForemanVirtWhoConfigure
@@ -19,34 +21,34 @@ module HammerCLIForemanVirtWhoConfigure
19
21
 
20
22
  def self.format_status(status)
21
23
  case status
22
- when 'unknown'
23
- _('No Report Yet')
24
- when 'ok', 'out_of_date'
25
- _('OK')
26
- when 'error'
27
- _('Error')
28
- else
29
- _('Unknown configuration status')
24
+ when 'unknown'
25
+ _('No Report Yet')
26
+ when 'ok', 'out_of_date'
27
+ _('OK')
28
+ when 'error'
29
+ _('Error')
30
+ else
31
+ _('Unknown configuration status')
30
32
  end
31
33
  end
32
34
 
33
35
  def self.format_filtering_mode(mode)
34
36
  case mode
35
- when MODE_UNLIMITED
36
- _('Unlimited')
37
- when MODE_WHITELIST
38
- _('Whitelist')
39
- when MODE_BLACKLIST
40
- _('Blacklist')
41
- else
42
- _('Unknown listing mode')
37
+ when MODE_UNLIMITED
38
+ _('Unlimited')
39
+ when MODE_WHITELIST
40
+ _('Whitelist')
41
+ when MODE_BLACKLIST
42
+ _('Blacklist')
43
+ else
44
+ _('Unknown listing mode')
43
45
  end
44
46
  end
45
47
 
46
48
  def self.validate_hypervisor_options(conf)
47
- options = conf["hypervisor_type"] == 'kubevirt' ? %w(hypervisor_server hypervisor_username) : %w(kubeconfig_path)
48
- options.append("prism_flavor", "ahv_internal_debug") unless conf["hypervisor_type"] == 'ahv'
49
- conf.delete_if { |k, v| options.include?(k) }
49
+ options = conf['hypervisor_type'] == 'kubevirt' ? %w(hypervisor_server hypervisor_username) : %w(kubeconfig_path)
50
+ options.append('prism_flavor', 'ahv_internal_debug') unless conf['hypervisor_type'] == 'ahv'
51
+ conf.delete_if { |k, _v| options.include?(k) }
50
52
  end
51
53
 
52
54
  class ListCommand < HammerCLIForeman::ListCommand
@@ -113,12 +115,12 @@ module HammerCLIForemanVirtWhoConfigure
113
115
  if conf['filtering_mode'] != MODE_WHITELIST
114
116
  conf['whitelist'] = nil
115
117
  else
116
- conf['whitelist'] ||= " "
118
+ conf['whitelist'] ||= ' '
117
119
  end
118
120
  if conf['filtering_mode'] != MODE_BLACKLIST
119
121
  conf['blacklist'] = nil
120
122
  else
121
- conf['blacklist'] ||= " "
123
+ conf['blacklist'] ||= ' '
122
124
  end
123
125
  VirtWhoConfig.validate_hypervisor_options(conf)
124
126
  end
@@ -127,7 +129,7 @@ module HammerCLIForemanVirtWhoConfigure
127
129
  end
128
130
 
129
131
  class FetchCommand < HammerCLIForeman::Command
130
- command_name "fetch"
132
+ command_name 'fetch'
131
133
  action :deploy_script
132
134
 
133
135
  failure_message _('Could not fetch the Virt Who configuration')
@@ -142,11 +144,11 @@ module HammerCLIForemanVirtWhoConfigure
142
144
  # this could be a security issue, the file should be readable only by the user
143
145
  output.print_error(
144
146
  _('Could not save the script'),
145
- _("File at %{path} already exists, please specify a different path.") % { :path => path }
147
+ _('File at %{path} already exists, please specify a different path.') % { :path => path }
146
148
  )
147
149
  return HammerCLI::EX_USAGE
148
150
  else
149
- File.write(path, data, perm: 0700, mode: File::RDWR|File::CREAT|File::EXCL)
151
+ File.write(path, data, perm: 0700, mode: File::RDWR | File::CREAT | File::EXCL)
150
152
  return HammerCLI::EX_OK
151
153
  end
152
154
  else
@@ -163,7 +165,7 @@ module HammerCLIForemanVirtWhoConfigure
163
165
  end
164
166
 
165
167
  class DeployCommand < HammerCLIForeman::Command
166
- command_name "deploy"
168
+ command_name 'deploy'
167
169
  desc _('Download and execute script for the specified virt-who configuration')
168
170
  action :deploy_script
169
171
 
@@ -194,7 +196,7 @@ module HammerCLIForemanVirtWhoConfigure
194
196
  'none' => 0,
195
197
  'whitelist' => 1,
196
198
  'blacklist' => 2
197
- }
199
+ }.freeze
198
200
 
199
201
  def self.included(base)
200
202
  base.option '--filtering-mode', 'MODE', _('Hypervisor filtering mode'),
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'hammer_cli/i18n'
2
4
 
3
5
  module HammerCLIForemanVirtWhoConfigure
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module HammerCLIForemanVirtWhoConfigure
2
4
  class SystemCaller
3
- WHITELISTED_VARS = %w[HOME USER LANG].freeze
5
+ WHITELISTED_VARS = %w(HOME USER LANG).freeze
4
6
 
5
7
  def initialize(tempfile = nil)
6
8
  @tempfile = tempfile || Tempfile.new('virt_who')
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module HammerCLIForemanVirtWhoConfigure
2
4
  def self.version
3
- @version ||= Gem::Version.new '0.1.0'
5
+ @version ||= Gem::Version.new '0.1.1'
4
6
  end
5
7
  end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'hammer_cli'
2
4
  require 'hammer_cli_foreman'
3
5
  require 'hammer_cli_foreman_virt_who_configure/i18n'
4
6
 
5
7
  module HammerCLIForemanVirtWhoConfigure
6
- HammerCLI::MainCommand.lazy_subcommand('virt-who-config', _("Manage Virt Who configurations"),
7
- 'HammerCLIForemanVirtWhoConfigure::VirtWhoConfig', 'hammer_cli_foreman_virt_who_configure/config'
8
- )
8
+ HammerCLI::MainCommand.lazy_subcommand('virt-who-config', _('Manage Virt Who configurations'),
9
+ 'HammerCLIForemanVirtWhoConfigure::VirtWhoConfig', 'hammer_cli_foreman_virt_who_configure/config'
10
+ )
9
11
  end