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.
- checksums.yaml +4 -4
- data/lib/hammer_cli_foreman_virt_who_configure/config.rb +28 -26
- data/lib/hammer_cli_foreman_virt_who_configure/i18n.rb +2 -0
- data/lib/hammer_cli_foreman_virt_who_configure/system_caller.rb +3 -1
- data/lib/hammer_cli_foreman_virt_who_configure/version.rb +3 -1
- data/lib/hammer_cli_foreman_virt_who_configure.rb +5 -3
- data/locale/bn/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/bn_IN/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/bqi/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/ca/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/cs_CZ/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/de/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/de_AT/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/de_DE/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/el/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/en/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/en_US/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/es/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/et_EE/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/fr/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/gl/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/gu/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/he_IL/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/hi/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/id/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/it/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/ja/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/ka/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/kn/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/ko/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/ml_IN/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/mr/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/nl_NL/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/or/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/pa/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/pl/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/pl_PL/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/pt/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/ro/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/ro_RO/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/ru/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/sl/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/sv_SE/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/ta/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/ta_IN/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/te/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/tr/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/vi/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/vi_VN/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/zh/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo +0 -0
- data/test/data/3.11/foreman_api.json +1 -0
- data/test/functional/config/config_create_test.rb +16 -24
- data/test/functional/config/config_deploy_test.rb +16 -14
- data/test/functional/config/config_fetch_test.rb +12 -10
- data/test/functional/config/config_info_test.rb +45 -43
- data/test/functional/config/config_list_test.rb +11 -9
- data/test/functional/config/config_update_test.rb +7 -5
- data/test/functional/test_helper.rb +22 -20
- data/test/test_helper.rb +4 -3
- data/test/unit/system_caller_test.rb +3 -1
- metadata +187 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fce0d55b84baaf7c230353820665c88c6053b7f62253231a3e0d17d57663d0bc
|
4
|
+
data.tar.gz: 22219b792cfe77a3500a149641a579fd28100ca3b084b75e99137b2415cf26f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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[
|
48
|
-
options.append(
|
49
|
-
conf.delete_if { |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
|
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
|
-
_(
|
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
|
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,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module HammerCLIForemanVirtWhoConfigure
|
2
4
|
class SystemCaller
|
3
|
-
WHITELISTED_VARS = %w
|
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,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', _(
|
7
|
-
|
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
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|