foreman_rh_cloud 4.0.26 → 4.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/foreman_inventory_upload/generators/tags.rb +1 -2
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/foreman_rh_cloud.rb +12 -1
- data/package.json +1 -1
- data/test/unit/foreman_rh_cloud_self_host_test.rb +28 -0
- data/test/unit/tags_generator_test.rb +16 -16
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f58fc1e7e0566050620598b261bb98ae808cacdb65ebff7efd59b483eced6996
|
4
|
+
data.tar.gz: c62e13422b518e22686687e429a5d73185469391d29013cd952d6b631cbf1db8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18ed7b82fa19fb2e5b22466648a31e9cfeb8a6dc8c20e07a9d7db028a61a2304ed663b1f9a3b62ce2ab59ca932fe9e35c6efdf0c41945b57a75d60455a541582
|
7
|
+
data.tar.gz: 12c271cf247328eef9d310f0b85d64a1080ad0321f9b7fd1b6caa44a8a299eb1d4b13a6141b5740b053ecf4622b8269980223bd7ba95cdfa4b6f19765a8782ff
|
@@ -19,8 +19,7 @@ module ForemanInventoryUpload
|
|
19
19
|
def generate_parameters
|
20
20
|
return [] unless Setting[:include_parameter_tags]
|
21
21
|
|
22
|
-
(@host.
|
23
|
-
.map { |item| [item.name, item.value] }
|
22
|
+
(@host.host_params || {})
|
24
23
|
.select { |_name, value| value.present? || value.is_a?(FalseClass) }
|
25
24
|
end
|
26
25
|
|
data/lib/foreman_rh_cloud.rb
CHANGED
@@ -98,7 +98,18 @@ module ForemanRhCloud
|
|
98
98
|
|
99
99
|
# For testing purposes we can override the default hostname with an environment variable SATELLITE_RH_CLOUD_FOREMAN_HOST
|
100
100
|
def self.foreman_host
|
101
|
-
@foreman_host ||=
|
101
|
+
@foreman_host ||= begin
|
102
|
+
fullname = foreman_host_name
|
103
|
+
::Host.unscoped.friendly.find(fullname)
|
104
|
+
rescue ActiveRecord::RecordNotFound
|
105
|
+
# fullname didn't work. Let's try shortname
|
106
|
+
shortname = /(?<shortname>[^\.]*)\.?.*/.match(fullname)[:shortname]
|
107
|
+
::Host.unscoped.friendly.find(shortname)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.foreman_host_name
|
112
|
+
ENV['SATELLITE_RH_CLOUD_FOREMAN_HOST'] || ::SmartProxy.default_capsule.name
|
102
113
|
end
|
103
114
|
|
104
115
|
def self.legacy_insights_ca
|
data/package.json
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class ForemanRhCloudSelfHostTest < ActiveSupport::TestCase
|
4
|
+
setup do
|
5
|
+
# reset cached value
|
6
|
+
ForemanRhCloud.instance_variable_set(:@foreman_host, nil)
|
7
|
+
end
|
8
|
+
|
9
|
+
test 'finds host by fullname' do
|
10
|
+
@domain
|
11
|
+
@host = FactoryBot.create(:host, :managed)
|
12
|
+
ForemanRhCloud.expects(:foreman_host_name).returns(@host.name)
|
13
|
+
|
14
|
+
actual = ForemanRhCloud.foreman_host
|
15
|
+
|
16
|
+
assert_not_nil actual
|
17
|
+
end
|
18
|
+
|
19
|
+
test 'finds host by shortname' do
|
20
|
+
@host = FactoryBot.create(:host, :managed)
|
21
|
+
Host.where(name: @host.name).update_all(name: @host.shortname)
|
22
|
+
ForemanRhCloud.expects(:foreman_host_name).returns(@host.name)
|
23
|
+
|
24
|
+
actual = ForemanRhCloud.foreman_host
|
25
|
+
|
26
|
+
assert_not_nil actual
|
27
|
+
end
|
28
|
+
end
|
@@ -65,14 +65,14 @@ class TagsGeneratorTest < ActiveSupport::TestCase
|
|
65
65
|
test 'generates parameter tags' do
|
66
66
|
FactoryBot.create(:setting, :name => 'include_parameter_tags', :settings_type => "boolean", :category => "Setting::RhCloud", :default => false, :value => true)
|
67
67
|
|
68
|
-
@host.stubs(:
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
68
|
+
@host.stubs(:host_params).returns(
|
69
|
+
{
|
70
|
+
'bool_param' => true,
|
71
|
+
'false_param' => false,
|
72
|
+
'int_param' => 1,
|
73
|
+
'empty_param' => nil,
|
74
|
+
'empty_str_param' => '',
|
75
|
+
}
|
76
76
|
)
|
77
77
|
|
78
78
|
generator = create_generator
|
@@ -87,14 +87,14 @@ class TagsGeneratorTest < ActiveSupport::TestCase
|
|
87
87
|
test 'skips parameter tags if include_parameter_tags setting is off' do
|
88
88
|
FactoryBot.create(:setting, :name => 'include_parameter_tags', :settings_type => "boolean", :category => "Setting::RhCloud", :default => false, :value => false)
|
89
89
|
|
90
|
-
@host.stubs(:
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
90
|
+
@host.stubs(:host_params).returns(
|
91
|
+
{
|
92
|
+
'bool_param' => true,
|
93
|
+
'false_param' => false,
|
94
|
+
'int_param' => 1,
|
95
|
+
'empty_param' => nil,
|
96
|
+
'empty_str_param' => '',
|
97
|
+
}
|
98
98
|
)
|
99
99
|
|
100
100
|
generator = create_generator
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_rh_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Foreman Red Hat Cloud team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: katello
|
@@ -255,6 +255,7 @@ files:
|
|
255
255
|
- test/test_plugin_helper.rb
|
256
256
|
- test/unit/archived_report_generator_test.rb
|
257
257
|
- test/unit/fact_helpers_test.rb
|
258
|
+
- test/unit/foreman_rh_cloud_self_host_test.rb
|
258
259
|
- test/unit/insights_facet_test.rb
|
259
260
|
- test/unit/metadata_generator_test.rb
|
260
261
|
- test/unit/rh_cloud_http_proxy_test.rb
|
@@ -685,6 +686,7 @@ test_files:
|
|
685
686
|
- test/test_plugin_helper.rb
|
686
687
|
- test/unit/archived_report_generator_test.rb
|
687
688
|
- test/unit/fact_helpers_test.rb
|
689
|
+
- test/unit/foreman_rh_cloud_self_host_test.rb
|
688
690
|
- test/unit/insights_facet_test.rb
|
689
691
|
- test/unit/metadata_generator_test.rb
|
690
692
|
- test/unit/rh_cloud_http_proxy_test.rb
|