hammer_cli_foreman_virt_who_configure 0.0.9 → 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 +29 -28
  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 +21 -29
  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 +23 -21
  63. data/test/test_helper.rb +4 -2
  64. data/test/unit/system_caller_test.rb +5 -2
  65. metadata +193 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36e2261f8c32cd0906a348f9920af4f7cbd8acd74ad7c78447c48e020a42a925
4
- data.tar.gz: cd292789c8ceea3321fb0a091ba190dbe489f2fcc4b7937ba35a58698748af0b
3
+ metadata.gz: fce0d55b84baaf7c230353820665c88c6053b7f62253231a3e0d17d57663d0bc
4
+ data.tar.gz: 22219b792cfe77a3500a149641a579fd28100ca3b084b75e99137b2415cf26f8
5
5
  SHA512:
6
- metadata.gz: d71a9bf91cde3e5840bf83b4ed13cf00f20ccc5b670fc601b9cce0728806f66bab53ee0b8a5c9a8a5c7b0811648dd3dbc3558f238b2f1055754a37a291814ab2
7
- data.tar.gz: 93dfa03a8a0fa04c0fca4a90c4f7352d8d949a2862ae7f18cd9937815aec74cca48c99e1a724e3eed7e5c92c4f02d47e6f61d7804756a609bf1cc03ff52a0799
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_update_interval", "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
@@ -77,7 +79,6 @@ module HammerCLIForemanVirtWhoConfigure
77
79
  field :hypervisor_username, _('Hypervisor username')
78
80
  field :kubeconfig_path, _('Configuration file'), Fields::Field, :hide_blank => true
79
81
  field :prism_flavor, _('AHV Prism flavor'), Fields::Field, :hide_blank => true
80
- field :ahv_update_interval, _('AHV update frequency'), Fields::Field, :hide_blank => true
81
82
  field :ahv_internal_debug, _('Enable AHV debug'), Fields::Boolean
82
83
  field :_status, _('Status')
83
84
  end
@@ -114,12 +115,12 @@ module HammerCLIForemanVirtWhoConfigure
114
115
  if conf['filtering_mode'] != MODE_WHITELIST
115
116
  conf['whitelist'] = nil
116
117
  else
117
- conf['whitelist'] ||= " "
118
+ conf['whitelist'] ||= ' '
118
119
  end
119
120
  if conf['filtering_mode'] != MODE_BLACKLIST
120
121
  conf['blacklist'] = nil
121
122
  else
122
- conf['blacklist'] ||= " "
123
+ conf['blacklist'] ||= ' '
123
124
  end
124
125
  VirtWhoConfig.validate_hypervisor_options(conf)
125
126
  end
@@ -128,7 +129,7 @@ module HammerCLIForemanVirtWhoConfigure
128
129
  end
129
130
 
130
131
  class FetchCommand < HammerCLIForeman::Command
131
- command_name "fetch"
132
+ command_name 'fetch'
132
133
  action :deploy_script
133
134
 
134
135
  failure_message _('Could not fetch the Virt Who configuration')
@@ -139,15 +140,15 @@ module HammerCLIForemanVirtWhoConfigure
139
140
  data = send_request
140
141
  if option_output
141
142
  path = File.expand_path(option_output)
142
- if File.exists?(path)
143
+ if File.exist?(path)
143
144
  # this could be a security issue, the file should be readable only by the user
144
145
  output.print_error(
145
146
  _('Could not save the script'),
146
- _("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 }
147
148
  )
148
149
  return HammerCLI::EX_USAGE
149
150
  else
150
- 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)
151
152
  return HammerCLI::EX_OK
152
153
  end
153
154
  else
@@ -164,7 +165,7 @@ module HammerCLIForemanVirtWhoConfigure
164
165
  end
165
166
 
166
167
  class DeployCommand < HammerCLIForeman::Command
167
- command_name "deploy"
168
+ command_name 'deploy'
168
169
  desc _('Download and execute script for the specified virt-who configuration')
169
170
  action :deploy_script
170
171
 
@@ -195,7 +196,7 @@ module HammerCLIForemanVirtWhoConfigure
195
196
  'none' => 0,
196
197
  'whitelist' => 1,
197
198
  'blacklist' => 2
198
- }
199
+ }.freeze
199
200
 
200
201
  def self.included(base)
201
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.0.9'
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