foreman_rh_cloud 11.3.0 → 11.4.1
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 +4 -4
- data/app/services/foreman_rh_cloud/cloud_request.rb +4 -0
- data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +17 -1
- data/app/services/foreman_rh_cloud/rules_ingester.rb +12 -1
- data/config/routes.rb +4 -0
- data/lib/foreman_rh_cloud/engine.rb +11 -0
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/package.json +1 -1
- data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +6 -16
- data/test/jobs/inventory_full_sync_test.rb +6 -5
- data/test/jobs/inventory_hosts_sync_test.rb +6 -6
- data/test/test_plugin_helper.rb +14 -0
- data/test/unit/archived_report_generator_test.rb +4 -4
- data/test/unit/services/foreman_rh_cloud/branch_info_test.rb +7 -6
- data/test/unit/slice_generator_test.rb +4 -5
- data/test/unit/tags_generator_test.rb +2 -12
- metadata +35 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f8fc6102624f1f64c8417c8417d1ba48e5db528a0551027ba3fd2fac84cb11e
|
4
|
+
data.tar.gz: 9a8a361d435e8ad403937c50b46c6ed3f56f127342320d00258480bd9dfad194
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3d88a21a8bdb3990d0b5f76b20b9b43e1cac02d1c5f8c1adcbc565fa2291d67ede4c4fd5cc794b83db7569048853bf13dc1fa0eeb7fa0556c1e77c390ebf10e
|
7
|
+
data.tar.gz: 7309c277c4478897a0cf00d5fb2a18cf9007e2231bf6c63e16ee880feed2bc664ab340e9af84d092ae4b31bd8fe1e6e3c4f282a4628a56cd463eea2b3f234b2d
|
@@ -8,6 +8,10 @@ module ForemanRhCloud
|
|
8
8
|
proxy: ForemanRhCloud.transformed_http_proxy_string,
|
9
9
|
}.deep_merge(params)
|
10
10
|
|
11
|
+
if ForemanRhCloud.with_local_advisor_engine?
|
12
|
+
final_params[:ssl_ca_file] ||= ForemanRhCloud.ca_cert
|
13
|
+
end
|
14
|
+
|
11
15
|
response = RestClient::Request.execute(final_params)
|
12
16
|
|
13
17
|
logger.debug("Response headers for request url #{final_params[:url]} are: #{response.headers}")
|
@@ -34,7 +34,13 @@ module ForemanRhCloud
|
|
34
34
|
),
|
35
35
|
}
|
36
36
|
requested_url = original_request.original_fullpath.end_with?('/') ? original_request.path + '/' : original_request.path
|
37
|
-
|
37
|
+
params = path_params(requested_url, certs)
|
38
|
+
|
39
|
+
if ForemanRhCloud.with_local_advisor_engine?
|
40
|
+
params[:ssl_ca_file] = ForemanRhCloud.ca_cert
|
41
|
+
end
|
42
|
+
|
43
|
+
base_params.merge(params)
|
38
44
|
end
|
39
45
|
|
40
46
|
def prepare_forward_payload(original_request, controller_name)
|
@@ -63,6 +69,12 @@ module ForemanRhCloud
|
|
63
69
|
|
64
70
|
def path_params(request_path, certs)
|
65
71
|
case request_path
|
72
|
+
when lightspeed?
|
73
|
+
{
|
74
|
+
url: ForemanRhCloud.cert_base_url + request_path,
|
75
|
+
ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
|
76
|
+
ssl_client_key: OpenSSL::PKey.read(certs[:key]),
|
77
|
+
}
|
66
78
|
when platform_request?
|
67
79
|
{
|
68
80
|
url: ForemanRhCloud.cert_base_url + request_path.sub('/redhat_access/r/insights/platform', '/api'),
|
@@ -95,6 +107,10 @@ module ForemanRhCloud
|
|
95
107
|
headers
|
96
108
|
end
|
97
109
|
|
110
|
+
def lightspeed?
|
111
|
+
->(request_path) { request_path.include? '/lightspeed' }
|
112
|
+
end
|
113
|
+
|
98
114
|
def platform_request?
|
99
115
|
->(request_path) { request_path.include? '/platform' }
|
100
116
|
end
|
@@ -13,7 +13,18 @@ module ForemanRhCloud
|
|
13
13
|
|
14
14
|
def fetch_rules_data
|
15
15
|
advisor_url = "#{ForemanRhCloud.on_premise_url}/r/insights/v1/static/release/content.json"
|
16
|
-
|
16
|
+
uri = URI.parse(advisor_url)
|
17
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
18
|
+
http.use_ssl = true
|
19
|
+
|
20
|
+
# Set CA certificate
|
21
|
+
http.ca_file = ForemanRhCloud.ca_cert
|
22
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
23
|
+
|
24
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
25
|
+
|
26
|
+
response = http.request(request)
|
27
|
+
JSON.parse(response.body, symbolize_names: true)
|
17
28
|
end
|
18
29
|
|
19
30
|
def fetch_rules_and_resolutions
|
data/config/routes.rb
CHANGED
@@ -49,6 +49,10 @@ Rails.application.routes.draw do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
scope :module => :'insights_cloud/api' do
|
53
|
+
match '/api/lightspeed/*path', to: 'machine_telemetries#forward_request', via: :all
|
54
|
+
end
|
55
|
+
|
52
56
|
# API routes
|
53
57
|
|
54
58
|
namespace :api, :defaults => { :format => 'json' } do
|
@@ -212,4 +212,15 @@ module ForemanRhCloud
|
|
212
212
|
def self.with_local_advisor_engine?
|
213
213
|
SETTINGS.dig(:foreman_rh_cloud, :use_local_advisor_engine) || false
|
214
214
|
end
|
215
|
+
|
216
|
+
def self.ca_cert
|
217
|
+
# The reference to candlepin ca_cert_file can be removed
|
218
|
+
# once the setting is dropped. Foreman 3.15 introduces
|
219
|
+
# a single CA file that bundles all CAs.
|
220
|
+
if ::SETTINGS.dig(:katello, :candlepin, :ca_cert_file)
|
221
|
+
::SETTINGS[:katello][:candlepin][:ca_cert_file]
|
222
|
+
else
|
223
|
+
::SETTINGS[:ssl_ca_file]
|
224
|
+
end
|
225
|
+
end
|
215
226
|
end
|
data/package.json
CHANGED
@@ -3,6 +3,8 @@ require 'rest-client'
|
|
3
3
|
|
4
4
|
module InsightsCloud::Api
|
5
5
|
class MachineTelemetriesControllerTest < ActionController::TestCase
|
6
|
+
include KatelloCVEHelper
|
7
|
+
|
6
8
|
setup do
|
7
9
|
FactoryBot.create(:common_parameter, name: InsightsCloud.enable_client_param, key_type: 'boolean', value: true)
|
8
10
|
end
|
@@ -122,9 +124,8 @@ module InsightsCloud::Api
|
|
122
124
|
setup do
|
123
125
|
UpstreamOnlySettingsTestHelper.set_if_available('allow_multiple_content_views')
|
124
126
|
User.current = User.find_by(login: 'secret_admin')
|
125
|
-
|
126
|
-
|
127
|
-
@env2 = FactoryBot.create(:katello_k_t_environment, organization: @env.organization)
|
127
|
+
env = FactoryBot.create(:katello_k_t_environment)
|
128
|
+
env2 = FactoryBot.create(:katello_k_t_environment, organization: env.organization)
|
128
129
|
|
129
130
|
@host = FactoryBot.create(
|
130
131
|
:host,
|
@@ -132,19 +133,8 @@ module InsightsCloud::Api
|
|
132
133
|
:with_content,
|
133
134
|
:with_hostgroup,
|
134
135
|
:with_parameter,
|
135
|
-
content_view_environments: [
|
136
|
-
|
137
|
-
:katello_content_view_environment,
|
138
|
-
content_view: FactoryBot.create(:katello_content_view, organization: @env.organization),
|
139
|
-
lifecycle_environment: @env
|
140
|
-
),
|
141
|
-
FactoryBot.create(
|
142
|
-
:katello_content_view_environment,
|
143
|
-
content_view: FactoryBot.create(:katello_content_view, organization: @env.organization),
|
144
|
-
lifecycle_environment: @env2
|
145
|
-
),
|
146
|
-
],
|
147
|
-
organization: @env.organization
|
136
|
+
content_view_environments: [make_cve(lifecycle_environment: env), make_cve(lifecycle_environment: env2)],
|
137
|
+
organization: env.organization
|
148
138
|
)
|
149
139
|
|
150
140
|
@host.subscription_facet.pools << FactoryBot.create(:katello_pool, account_number: '5678', cp_id: 1)
|
@@ -4,6 +4,7 @@ require 'foreman_tasks/test_helpers'
|
|
4
4
|
class InventoryFullSyncTest < ActiveSupport::TestCase
|
5
5
|
include ForemanTasks::TestHelpers::WithInThreadExecutor
|
6
6
|
include MockCerts
|
7
|
+
include KatelloCVEHelper
|
7
8
|
|
8
9
|
setup do
|
9
10
|
User.current = User.find_by(login: 'secret_admin')
|
@@ -11,15 +12,15 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
11
12
|
InventorySync::Async::InventoryFullSync.any_instance.stubs(:plan_self_host_sync)
|
12
13
|
Organization.any_instance.stubs(:manifest_expired?).returns(false)
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
cve = make_cve
|
16
|
+
env = cve.lifecycle_environment
|
16
17
|
|
17
18
|
# this host would pass our plugin queries, so it could be uploaded to the cloud.
|
18
19
|
@host1 = FactoryBot.create(
|
19
20
|
:host,
|
20
21
|
:with_subscription,
|
21
22
|
:with_content,
|
22
|
-
content_view:
|
23
|
+
content_view: cve.content_view,
|
23
24
|
lifecycle_environment: env,
|
24
25
|
organization: env.organization
|
25
26
|
)
|
@@ -33,7 +34,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
33
34
|
:host,
|
34
35
|
:with_subscription,
|
35
36
|
:with_content,
|
36
|
-
content_view:
|
37
|
+
content_view: cve.content_view,
|
37
38
|
lifecycle_environment: env,
|
38
39
|
organization: env.organization
|
39
40
|
)
|
@@ -46,7 +47,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
46
47
|
:host,
|
47
48
|
:with_subscription,
|
48
49
|
:with_content,
|
49
|
-
content_view:
|
50
|
+
content_view: cve.content_view,
|
50
51
|
lifecycle_environment: env,
|
51
52
|
organization: env.organization
|
52
53
|
)
|
@@ -4,19 +4,19 @@ require 'foreman_tasks/test_helpers'
|
|
4
4
|
class InventoryHostsSyncTest < ActiveSupport::TestCase
|
5
5
|
include ForemanTasks::TestHelpers::WithInThreadExecutor
|
6
6
|
include MockCerts
|
7
|
+
include KatelloCVEHelper
|
7
8
|
|
8
9
|
setup do
|
9
10
|
User.current = User.find_by(login: 'secret_admin')
|
10
|
-
|
11
|
-
env =
|
12
|
-
cv =
|
13
|
-
|
11
|
+
cve = make_cve
|
12
|
+
env = cve.lifecycle_environment
|
13
|
+
cv = cve.content_view
|
14
14
|
# this host would pass our plugin queries, so it could be uploaded to the cloud.
|
15
15
|
@host1 = FactoryBot.create(
|
16
16
|
:host,
|
17
17
|
:with_subscription,
|
18
18
|
:with_content,
|
19
|
-
content_view: cv
|
19
|
+
content_view: cv,
|
20
20
|
lifecycle_environment: env,
|
21
21
|
organization: env.organization
|
22
22
|
)
|
@@ -30,7 +30,7 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
30
30
|
:host,
|
31
31
|
:with_subscription,
|
32
32
|
:with_content,
|
33
|
-
content_view: cv
|
33
|
+
content_view: cv,
|
34
34
|
lifecycle_environment: env,
|
35
35
|
organization: env.organization
|
36
36
|
)
|
data/test/test_plugin_helper.rb
CHANGED
@@ -118,6 +118,20 @@ module CandlepinIsolation
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
+
module KatelloCVEHelper
|
122
|
+
def make_cve(lifecycle_environment: nil, content_view: nil)
|
123
|
+
env = lifecycle_environment || FactoryBot.create(:katello_k_t_environment)
|
124
|
+
content_view ||= FactoryBot.create(:katello_content_view, organization: env.organization)
|
125
|
+
cvv = ::Katello::ContentViewVersion.create!(:major => 2, :content_view => content_view)
|
126
|
+
FactoryBot.create(
|
127
|
+
:katello_content_view_environment,
|
128
|
+
content_view_version: cvv,
|
129
|
+
content_view: content_view,
|
130
|
+
lifecycle_environment: env
|
131
|
+
)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
121
135
|
module UpstreamOnlySettingsTestHelper
|
122
136
|
def self.set_if_available(setting_name, value: true)
|
123
137
|
Setting[setting_name] = value
|
@@ -2,18 +2,18 @@ require 'test_plugin_helper'
|
|
2
2
|
|
3
3
|
class ArchivedReportGeneratorTest < ActiveSupport::TestCase
|
4
4
|
include MockForemanHostname
|
5
|
+
include KatelloCVEHelper
|
5
6
|
|
6
7
|
setup do
|
7
8
|
User.current = User.find_by(login: 'secret_admin')
|
8
|
-
|
9
|
-
env =
|
10
|
-
cv = env.content_views << FactoryBot.create(:katello_content_view, organization: env.organization)
|
9
|
+
cve = make_cve
|
10
|
+
env = cve.lifecycle_environment
|
11
11
|
|
12
12
|
@host = FactoryBot.create(
|
13
13
|
:host,
|
14
14
|
:with_subscription,
|
15
15
|
:with_content,
|
16
|
-
content_view:
|
16
|
+
content_view: cve.content_view,
|
17
17
|
lifecycle_environment: env,
|
18
18
|
organization: env.organization
|
19
19
|
)
|
@@ -1,21 +1,22 @@
|
|
1
1
|
require 'test_plugin_helper'
|
2
2
|
|
3
3
|
class BranchInfoTest < ActiveSupport::TestCase
|
4
|
+
include KatelloCVEHelper
|
5
|
+
|
4
6
|
setup do
|
5
7
|
User.current = User.find_by(login: 'secret_admin')
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
cve = make_cve
|
10
|
+
env = cve.lifecycle_environment
|
10
11
|
@host = FactoryBot.create(
|
11
12
|
:host,
|
12
13
|
:with_subscription,
|
13
14
|
:with_content,
|
14
15
|
:with_hostgroup,
|
15
16
|
:with_parameter,
|
16
|
-
content_view:
|
17
|
-
lifecycle_environment:
|
18
|
-
organization:
|
17
|
+
content_view: cve.content_view,
|
18
|
+
lifecycle_environment: env,
|
19
|
+
organization: env.organization
|
19
20
|
)
|
20
21
|
|
21
22
|
@host.subscription_facet.pools << FactoryBot.create(:katello_pool, account_number: '5678', cp_id: 1)
|
@@ -3,13 +3,12 @@ require 'test_plugin_helper'
|
|
3
3
|
class SliceGeneratorTest < ActiveSupport::TestCase
|
4
4
|
include KatelloLocationFix
|
5
5
|
include CandlepinIsolation
|
6
|
+
include KatelloCVEHelper
|
6
7
|
|
7
8
|
setup do
|
8
9
|
User.current = User.find_by(login: 'secret_admin')
|
9
|
-
|
10
|
-
env =
|
11
|
-
cv = env.content_views << FactoryBot.create(:katello_content_view, organization: env.organization)
|
12
|
-
|
10
|
+
cve = make_cve
|
11
|
+
env = cve.lifecycle_environment
|
13
12
|
location = FactoryBot.create(:location)
|
14
13
|
|
15
14
|
@host = FactoryBot.create(
|
@@ -17,7 +16,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
17
16
|
:redhat,
|
18
17
|
:with_subscription,
|
19
18
|
:with_content,
|
20
|
-
content_view:
|
19
|
+
content_view: cve.content_view,
|
21
20
|
lifecycle_environment: env,
|
22
21
|
organization: env.organization,
|
23
22
|
location: location
|
@@ -3,6 +3,7 @@ require 'test_plugin_helper'
|
|
3
3
|
class TagsGeneratorTest < ActiveSupport::TestCase
|
4
4
|
include KatelloLocationFix
|
5
5
|
include CandlepinIsolation
|
6
|
+
include KatelloCVEHelper
|
6
7
|
|
7
8
|
setup do
|
8
9
|
UpstreamOnlySettingsTestHelper.set_if_available('allow_multiple_content_views')
|
@@ -25,18 +26,7 @@ class TagsGeneratorTest < ActiveSupport::TestCase
|
|
25
26
|
organization: env.organization,
|
26
27
|
location: @location2,
|
27
28
|
hostgroup: @hostgroup2,
|
28
|
-
content_view_environments: [
|
29
|
-
FactoryBot.create(
|
30
|
-
:katello_content_view_environment,
|
31
|
-
content_view: FactoryBot.create(:katello_content_view, organization: env.organization),
|
32
|
-
lifecycle_environment: env
|
33
|
-
),
|
34
|
-
FactoryBot.create(
|
35
|
-
:katello_content_view_environment,
|
36
|
-
content_view: FactoryBot.create(:katello_content_view, organization: env.organization),
|
37
|
-
lifecycle_environment: env2
|
38
|
-
),
|
39
|
-
]
|
29
|
+
content_view_environments: [make_cve(lifecycle_environment: env), make_cve(lifecycle_environment: env2)]
|
40
30
|
)
|
41
31
|
|
42
32
|
@host.organization.pools << FactoryBot.create(:katello_pool, account_number: '1234', cp_id: 1)
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_rh_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 11.
|
4
|
+
version: 11.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Foreman Red Hat Cloud team
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: foreman_ansible
|
@@ -17,6 +16,9 @@ dependencies:
|
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
18
|
version: 15.0.0
|
19
|
+
- - "<"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 16.0.0
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +26,29 @@ dependencies:
|
|
24
26
|
- - ">="
|
25
27
|
- !ruby/object:Gem::Version
|
26
28
|
version: 15.0.0
|
29
|
+
- - "<"
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 16.0.0
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: foreman_remote_execution
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 15.0.0
|
39
|
+
- - "<"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 16.0.0
|
42
|
+
type: :runtime
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 15.0.0
|
49
|
+
- - "<"
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: 16.0.0
|
27
52
|
- !ruby/object:Gem::Dependency
|
28
53
|
name: foreman-tasks
|
29
54
|
requirement: !ruby/object:Gem::Requirement
|
@@ -31,6 +56,9 @@ dependencies:
|
|
31
56
|
- - ">="
|
32
57
|
- !ruby/object:Gem::Version
|
33
58
|
version: 10.0.0
|
59
|
+
- - "<"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 11.0.0
|
34
62
|
type: :runtime
|
35
63
|
prerelease: false
|
36
64
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,6 +66,9 @@ dependencies:
|
|
38
66
|
- - ">="
|
39
67
|
- !ruby/object:Gem::Version
|
40
68
|
version: 10.0.0
|
69
|
+
- - "<"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 11.0.0
|
41
72
|
- !ruby/object:Gem::Dependency
|
42
73
|
name: katello
|
43
74
|
requirement: !ruby/object:Gem::Requirement
|
@@ -649,7 +680,6 @@ homepage: https://github.com/theforeman/foreman_rh_cloud
|
|
649
680
|
licenses:
|
650
681
|
- GPL-3.0
|
651
682
|
metadata: {}
|
652
|
-
post_install_message:
|
653
683
|
rdoc_options: []
|
654
684
|
require_paths:
|
655
685
|
- lib
|
@@ -667,8 +697,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
667
697
|
- !ruby/object:Gem::Version
|
668
698
|
version: '0'
|
669
699
|
requirements: []
|
670
|
-
rubygems_version: 3.
|
671
|
-
signing_key:
|
700
|
+
rubygems_version: 3.6.7
|
672
701
|
specification_version: 4
|
673
702
|
summary: Summary of ForemanRhCloud.
|
674
703
|
test_files:
|