hammer_cli_foreman_virt_who_configure 0.0.5 → 0.0.9

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: 0ee53d10c25c7bb73cf7ec8bb3d7f8fc3dcbea957cc4ccde0652ce37c5aa9660
4
- data.tar.gz: 7bde63d3680ca55eedf00df46f800b08d0858c3934b995585ee515cb5e408d66
3
+ metadata.gz: 36e2261f8c32cd0906a348f9920af4f7cbd8acd74ad7c78447c48e020a42a925
4
+ data.tar.gz: cd292789c8ceea3321fb0a091ba190dbe489f2fcc4b7937ba35a58698748af0b
5
5
  SHA512:
6
- metadata.gz: 7794300b03933db3ffa7438863ea2e98c10b9a13608109f567deef76911afe9741e6e755df11d8b6068c7773c3c72a714764e82e8be1d4f41217071dcee5c67c
7
- data.tar.gz: a394bf2a667af20930679c72875164f684cdc2b8116d972de7e73153d58cf0bfb36ff0d000a4ac873d809e6502939fbec02e79f5828d94d17e568bc9c7c7ea10
6
+ metadata.gz: d71a9bf91cde3e5840bf83b4ed13cf00f20ccc5b670fc601b9cce0728806f66bab53ee0b8a5c9a8a5c7b0811648dd3dbc3558f238b2f1055754a37a291814ab2
7
+ data.tar.gz: 93dfa03a8a0fa04c0fca4a90c4f7352d8d949a2862ae7f18cd9937815aec74cca48c99e1a724e3eed7e5c92c4f02d47e6f61d7804756a609bf1cc03ff52a0799
@@ -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_update_interval", "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')
@@ -69,6 +75,10 @@ module HammerCLIForemanVirtWhoConfigure
69
75
  field :hypervisor_type, _('Hypervisor type')
70
76
  field :hypervisor_server, _('Hypervisor server')
71
77
  field :hypervisor_username, _('Hypervisor username')
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_update_interval, _('AHV update frequency'), Fields::Field, :hide_blank => true
81
+ field :ahv_internal_debug, _('Enable AHV debug'), Fields::Boolean
72
82
  field :_status, _('Status')
73
83
  end
74
84
  label _('Schedule') do
@@ -84,8 +94,14 @@ module HammerCLIForemanVirtWhoConfigure
84
94
  field :filter_host_parents, _('Filter host parents'), Fields::Field, :hide_blank => true
85
95
  field :exclude_host_parents, _('Exclude host parents'), Fields::Field, :hide_blank => true
86
96
  field :debug, _('Debug mode'), Fields::Boolean
87
- field :proxy, _('HTTP proxy')
88
- field :no_proxy, _('Ignore proxy')
97
+ field :no_proxy, _('Ignore proxy'), Fields::Field, :hide_blank => true
98
+ end
99
+ label _('HTTP Proxy') do
100
+ from :http_proxy do
101
+ field :id, _('HTTP proxy ID'), Fields::Field, :hide_blank => true
102
+ field :name, _('HTTP proxy name'), Fields::Field, :hide_blank => true
103
+ field :url, _('HTTP proxy URL'), Fields::Field, :hide_blank => true
104
+ end
89
105
  end
90
106
  HammerCLIForeman::References.taxonomies(self)
91
107
  end
@@ -105,7 +121,7 @@ module HammerCLIForemanVirtWhoConfigure
105
121
  else
106
122
  conf['blacklist'] ||= " "
107
123
  end
108
- conf
124
+ VirtWhoConfig.validate_hypervisor_options(conf)
109
125
  end
110
126
 
111
127
  build_options
@@ -1,15 +1,27 @@
1
1
  module HammerCLIForemanVirtWhoConfigure
2
2
  class SystemCaller
3
+ WHITELISTED_VARS = %w[HOME USER LANG].freeze
4
+
3
5
  def initialize(tempfile = nil)
4
6
  @tempfile = tempfile || Tempfile.new('virt_who')
5
7
  end
6
8
 
7
- def system(commad)
9
+ def clean_env_vars
10
+ # Cleaning ENV vars and keeping required vars only because,
11
+ # When using SCL it adds GEM_HOME and GEM_PATH ENV vars.
12
+ # These vars break foreman-maintain tool.
13
+ # This way we use system ruby to execute the bash script.
14
+ cleaned_env = ENV.select { |var| WHITELISTED_VARS.include?(var) || var.start_with?('LC_') }
15
+ cleaned_env['PATH'] = '/sbin:/bin:/usr/sbin:/usr/bin'
16
+ cleaned_env
17
+ end
18
+
19
+ def system(command)
8
20
  result = nil
9
21
  begin
10
- @tempfile.write(commad)
22
+ @tempfile.write(command)
11
23
  @tempfile.flush # to make sure the command is complete
12
- result = Kernel.system("/usr/bin/bash #{@tempfile.path}")
24
+ result = Kernel.system(clean_env_vars, "/usr/bin/bash #{@tempfile.path}", unsetenv_others: true)
13
25
  ensure
14
26
  @tempfile.close
15
27
  @tempfile.unlink
@@ -1,5 +1,5 @@
1
1
  module HammerCLIForemanVirtWhoConfigure
2
2
  def self.version
3
- @version ||= Gem::Version.new '0.0.5'
3
+ @version ||= Gem::Version.new '0.0.9'
4
4
  end
5
5
  end
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.5
4
+ version: 0.0.9
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: 2019-11-27 00:00:00.000000000 Z
11
+ date: 2021-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hammer_cli
@@ -80,7 +80,7 @@ homepage: https://github.com/theforeman/hammer-cli-foreman-virt-who-configure
80
80
  licenses:
81
81
  - GPL-3.0+
82
82
  metadata: {}
83
- post_install_message:
83
+ post_install_message:
84
84
  rdoc_options: []
85
85
  require_paths:
86
86
  - lib
@@ -95,18 +95,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  requirements: []
98
- rubygems_version: 3.0.3
99
- signing_key:
98
+ rubygems_version: 3.1.6
99
+ signing_key:
100
100
  specification_version: 4
101
101
  summary: Plugin for configuring Virt Who
102
102
  test_files:
103
- - test/unit/system_caller_test.rb
104
- - test/test_helper.rb
105
- - test/functional/test_helper.rb
106
103
  - test/functional/config/config_info_test.rb
107
- - test/functional/config/config_deploy_test.rb
108
- - test/functional/config/config_list_test.rb
109
104
  - test/functional/config/config_update_test.rb
110
- - test/functional/config/config_create_test.rb
105
+ - test/functional/config/config_list_test.rb
106
+ - test/functional/config/config_deploy_test.rb
111
107
  - test/functional/config/config_fetch_test.rb
108
+ - test/functional/config/config_create_test.rb
109
+ - test/functional/test_helper.rb
110
+ - test/unit/system_caller_test.rb
111
+ - test/test_helper.rb
112
112
  - test/data/1.15/foreman_api.json