hammer_cli_foreman_virt_who_configure 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7c96871810cee34bc4e5b2ac7ff1b15edf614dbc2619b8b07b65cd1b56370a5
4
- data.tar.gz: 12687b71a396b7c7293c71f4d1c675bd77ba60a90dd84fb6ac42a4b180da2b1c
3
+ metadata.gz: aa67ec96782ac99c36a99614216817e60422d1b7b7ef99f21152c806a610560f
4
+ data.tar.gz: 3f3b9692d4eb19636b444aed17ae030a4dcb31b5a5963eadaab16305c7740832
5
5
  SHA512:
6
- metadata.gz: 24848ae6e6b22fe1ac9d6e20660d0bc7ff59825772bf9d8ed391d8ef4c68a0278e688db91f1a5497df449b9056016e0359a5af5bb6c66840be23a36e99e6d315
7
- data.tar.gz: e26889b6dabf00f5659ce741b6351d8f003d26de15102adde7e554d8cea5eae00197fee6e3b65035a5791c43e369b3b3d43bf176e2f849a0784909ca4958783c
6
+ metadata.gz: 7b4f624d8ef5af1d65781be5511f292cde27dbc52ba095eec6fd3871b3244466af51fe67d7ca19b36fcea2ca05a51d28d93da195d6fa67759bea337b3019456a
7
+ data.tar.gz: 5180c3415c4d94a6721b589a17761cbd04da023ed433075177efb61a73b2cde5fb7c91a7004ff61aed04524684c3c68285a6b116e6a0d12fdc49af470063a930
@@ -43,6 +43,12 @@ module HammerCLIForemanVirtWhoConfigure
43
43
  end
44
44
  end
45
45
 
46
+ 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) }
50
+ end
51
+
46
52
  class ListCommand < HammerCLIForeman::ListCommand
47
53
  output do
48
54
  field :id, _('Id')
@@ -70,6 +76,8 @@ module HammerCLIForemanVirtWhoConfigure
70
76
  field :hypervisor_server, _('Hypervisor server')
71
77
  field :hypervisor_username, _('Hypervisor username')
72
78
  field :kubeconfig_path, _('Configuration file'), Fields::Field, :hide_blank => true
79
+ field :prism_flavor, _('AHV Prism flavor'), Fields::Field, :hide_blank => true
80
+ field :ahv_internal_debug, _('Enable AHV debug'), Fields::Boolean
73
81
  field :_status, _('Status')
74
82
  end
75
83
  label _('Schedule') do
@@ -112,7 +120,7 @@ module HammerCLIForemanVirtWhoConfigure
112
120
  else
113
121
  conf['blacklist'] ||= " "
114
122
  end
115
- conf
123
+ VirtWhoConfig.validate_hypervisor_options(conf)
116
124
  end
117
125
 
118
126
  build_options
@@ -130,7 +138,7 @@ module HammerCLIForemanVirtWhoConfigure
130
138
  data = send_request
131
139
  if option_output
132
140
  path = File.expand_path(option_output)
133
- if File.exists?(path)
141
+ if File.exist?(path)
134
142
  # this could be a security issue, the file should be readable only by the user
135
143
  output.print_error(
136
144
  _('Could not save the script'),
@@ -138,7 +146,7 @@ module HammerCLIForemanVirtWhoConfigure
138
146
  )
139
147
  return HammerCLI::EX_USAGE
140
148
  else
141
- File.write(path, data, { :perm => 0700, :mode => File::RDWR|File::CREAT|File::EXCL })
149
+ File.write(path, data, perm: 0700, mode: File::RDWR|File::CREAT|File::EXCL)
142
150
  return HammerCLI::EX_OK
143
151
  end
144
152
  else
@@ -1,5 +1,5 @@
1
1
  module HammerCLIForemanVirtWhoConfigure
2
2
  def self.version
3
- @version ||= Gem::Version.new '0.0.8'
3
+ @version ||= Gem::Version.new '0.1.0'
4
4
  end
5
5
  end
@@ -29,42 +29,42 @@ describe "virt-who-config" do
29
29
 
30
30
  it "requires --filtering-mode" do
31
31
  params = hash_to_opts(@required_args, :reject => :filtering_mode)
32
- assert_requires_argument(@cmd, params, 'filtering_mode')
32
+ assert_requires_argument(@cmd, params, 'filtering-mode')
33
33
  end
34
34
 
35
35
  it "requires --hypervisor-id" do
36
36
  params = hash_to_opts(@required_args, :reject => :hypervisor_id)
37
- assert_requires_argument(@cmd, params, 'hypervisor_id')
37
+ assert_requires_argument(@cmd, params, 'hypervisor-id')
38
38
  end
39
39
 
40
40
  it "validates --hypervisor-id values" do
41
41
  params = hash_to_opts(@required_args.merge(:hypervisor_id => 'other'))
42
- assert_usage_error(@cmd, params, "option '--hypervisor-id': value must be one of 'hostname', 'uuid', 'hwuuid'")
42
+ assert_usage_error(@cmd, params, "Option '--hypervisor-id': Value must be one of 'hostname', 'uuid', 'hwuuid'..")
43
43
  end
44
44
 
45
45
  it "requires --hypervisor-type" do
46
46
  params = hash_to_opts(@required_args, :reject => :hypervisor_type)
47
- assert_requires_argument(@cmd, params, 'hypervisor_type')
47
+ assert_requires_argument(@cmd, params, 'hypervisor-type')
48
48
  end
49
49
 
50
50
  it "validates --hypervisor-type values" do
51
51
  params = hash_to_opts(@required_args.merge(:hypervisor_type => 'other'))
52
- assert_usage_error(@cmd, params, "option '--hypervisor-type': value must be one of 'esx', 'rhevm', 'hyperv', 'xen', 'libvirt'")
52
+ assert_usage_error(@cmd, params, "Option '--hypervisor-type': Value must be one of 'esx', 'rhevm', 'hyperv', 'xen', 'libvirt'..")
53
53
  end
54
54
 
55
55
  it "requires --hypervisor-server" do
56
56
  params = hash_to_opts(@required_args, :reject => :hypervisor_server)
57
- assert_requires_argument(@cmd, params, 'hypervisor_server')
57
+ assert_requires_argument(@cmd, params, 'hypervisor-server')
58
58
  end
59
59
 
60
60
  it "requires --hypervisor-username" do
61
61
  params = hash_to_opts(@required_args, :reject => :hypervisor_username)
62
- assert_requires_argument(@cmd, params, 'hypervisor_username')
62
+ assert_requires_argument(@cmd, params, 'hypervisor-username')
63
63
  end
64
64
 
65
65
  it "requires --satellite-url" do
66
66
  params = hash_to_opts(@required_args, :reject => :satellite_url)
67
- assert_requires_argument(@cmd, params, 'satellite_url')
67
+ assert_requires_argument(@cmd, params, 'satellite-url')
68
68
  end
69
69
 
70
70
  it "sends values to api" do
@@ -7,7 +7,7 @@ include HammerCLI::Testing::CommandAssertions
7
7
  include HammerCLI::Testing::OutputMatchers
8
8
 
9
9
  def missing_arguments_result(argument_name)
10
- HammerCLI::Testing::CommandAssertions::CommandExpectation.new('', /Missing arguments for.*\[#{argument_name}\]/, HammerCLI::EX_USAGE)
10
+ HammerCLI::Testing::CommandAssertions::CommandExpectation.new('', /Missing arguments for.*#{argument_name}/, HammerCLI::EX_USAGE)
11
11
  end
12
12
 
13
13
  def assert_requires_argument(cmd, params, required_argument_name)
data/test/test_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
  require 'minitest/spec'
3
3
  require "mocha/setup"
4
+ require "mocha/minitest"
4
5
 
5
6
  require 'hammer_cli'
6
7
  require 'hammer_cli_foreman/testing/api_expectations'
@@ -16,7 +16,8 @@ describe "SystemCaller" do
16
16
 
17
17
  it 'uses tempfile for executing the script' do
18
18
  tmp_file = CaptureContentTempfile.new
19
- Kernel.expects(:system).with("/usr/bin/bash #{tmp_file.path}")
19
+ vars = HammerCLIForemanVirtWhoConfigure::SystemCaller.new.clean_env_vars
20
+ Kernel.expects(:system).with(vars, "/usr/bin/bash #{tmp_file.path}", unsetenv_others: true)
20
21
 
21
22
  sys_caller = HammerCLIForemanVirtWhoConfigure::SystemCaller.new(tmp_file)
22
23
  sys_caller.system(script)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_foreman_virt_who_configure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomáš Strachota
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-12 00:00:00.000000000 Z
11
+ date: 2024-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hammer_cli
@@ -54,6 +54,7 @@ files:
54
54
  - lib/hammer_cli_foreman_virt_who_configure/system_caller.rb
55
55
  - lib/hammer_cli_foreman_virt_who_configure/version.rb
56
56
  - locale/ca/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo
57
+ - locale/cs_CZ/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo
57
58
  - locale/de/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo
58
59
  - locale/en/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo
59
60
  - locale/en_GB/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo
@@ -61,6 +62,7 @@ files:
61
62
  - locale/fr/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo
62
63
  - locale/it/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo
63
64
  - locale/ja/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo
65
+ - locale/ka/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo
64
66
  - locale/ko/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo
65
67
  - locale/pt_BR/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo
66
68
  - locale/ru/LC_MESSAGES/hammer-cli-foreman-virt-who-configure.mo
@@ -80,7 +82,7 @@ homepage: https://github.com/theforeman/hammer-cli-foreman-virt-who-configure
80
82
  licenses:
81
83
  - GPL-3.0+
82
84
  metadata: {}
83
- post_install_message:
85
+ post_install_message:
84
86
  rdoc_options: []
85
87
  require_paths:
86
88
  - lib
@@ -95,18 +97,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
97
  - !ruby/object:Gem::Version
96
98
  version: '0'
97
99
  requirements: []
98
- rubygems_version: 3.1.6
99
- signing_key:
100
+ rubygems_version: 3.2.33
101
+ signing_key:
100
102
  specification_version: 4
101
103
  summary: Plugin for configuring Virt Who
102
104
  test_files:
103
- - test/functional/test_helper.rb
105
+ - test/data/1.15/foreman_api.json
104
106
  - test/functional/config/config_create_test.rb
105
107
  - test/functional/config/config_deploy_test.rb
106
- - test/functional/config/config_list_test.rb
107
108
  - test/functional/config/config_fetch_test.rb
108
109
  - test/functional/config/config_info_test.rb
110
+ - test/functional/config/config_list_test.rb
109
111
  - test/functional/config/config_update_test.rb
110
- - test/unit/system_caller_test.rb
111
- - test/data/1.15/foreman_api.json
112
+ - test/functional/test_helper.rb
112
113
  - test/test_helper.rb
114
+ - test/unit/system_caller_test.rb