foreman_rh_cloud 4.0.26 → 4.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 713d1737fd81e7a54efa8a300fe4c0765c1d2a31b796218bcc1f447b473921af
4
- data.tar.gz: a47efbe51980f47c71e57af619f73a08d214f7af3bb84632946189a1aabe81f3
3
+ metadata.gz: f58fc1e7e0566050620598b261bb98ae808cacdb65ebff7efd59b483eced6996
4
+ data.tar.gz: c62e13422b518e22686687e429a5d73185469391d29013cd952d6b631cbf1db8
5
5
  SHA512:
6
- metadata.gz: c7419f0e5583f02038cf784e38d67f15dd0dfa3a392a72cd19000c0f51f41fc97a29ed2e9387bfee4e1fe7a91addb563db53167c98343b640f52e3b17a729387
7
- data.tar.gz: 2eb4fea115c546084e2365807e87933e60a102f1ec7455cfc5a368a1ae5a20587bf7c12206e40816a2893c19d02a035a2cee3c2262982a53f88542599bda629d
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.host_inherited_params_objects || [])
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
 
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '4.0.26'.freeze
2
+ VERSION = '4.0.27'.freeze
3
3
  end
@@ -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 ||= ::Host.unscoped.friendly.find(ENV['SATELLITE_RH_CLOUD_FOREMAN_HOST'] || ::SmartProxy.default_capsule.name)
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreman_rh_cloud",
3
- "version": "4.0.26",
3
+ "version": "4.0.27",
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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(:host_inherited_params_objects).returns(
69
- [
70
- OpenStruct.new(name: 'bool_param', value: true),
71
- OpenStruct.new(name: 'false_param', value: false),
72
- OpenStruct.new(name: 'int_param', value: 1),
73
- OpenStruct.new(name: 'empty_param', value: nil),
74
- OpenStruct.new(name: 'empty_str_param', value: ''),
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(:host_inherited_params_objects).returns(
91
- [
92
- OpenStruct.new(name: 'bool_param', value: true),
93
- OpenStruct.new(name: 'false_param', value: false),
94
- OpenStruct.new(name: 'int_param', value: 1),
95
- OpenStruct.new(name: 'empty_param', value: nil),
96
- OpenStruct.new(name: 'empty_str_param', value: ''),
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.26
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-08-23 00:00:00.000000000 Z
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