foreman_rh_cloud 9.0.57 → 10.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/concerns/insights_cloud/client_authentication.rb +1 -1
- data/app/models/concerns/rh_cloud_host.rb +4 -4
- data/app/models/insights_client_report_status.rb +8 -8
- data/app/models/insights_facet.rb +1 -1
- data/app/models/insights_hit.rb +1 -1
- data/app/models/inventory_sync/inventory_status.rb +4 -4
- data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +3 -2
- data/app/services/foreman_rh_cloud/hit_remediations_retriever.rb +1 -1
- data/config/routes.rb +2 -2
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +2 -2
- data/lib/foreman_inventory_upload/generators/json_stream.rb +1 -0
- data/lib/foreman_inventory_upload/generators/slice.rb +1 -0
- data/lib/foreman_inventory_upload.rb +1 -1
- data/lib/foreman_rh_cloud/engine.rb +2 -2
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/foreman_rh_cloud.rb +7 -7
- data/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb +1 -1
- data/lib/insights_cloud/async/insights_generate_notifications.rb +1 -1
- data/lib/insights_cloud/async/insights_resolutions_sync.rb +7 -1
- data/lib/insights_cloud/generators/playbook_progress_generator.rb +1 -0
- data/lib/inventory_sync/async/inventory_hosts_sync.rb +1 -1
- data/lib/tasks/insights.rake +4 -3
- data/package.json +1 -1
- data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +7 -4
- data/test/controllers/inventory_upload/api/inventory_controller_test.rb +1 -1
- data/test/factories/inventory_upload_factories.rb +1 -1
- data/test/jobs/cloud_connector_announce_task_test.rb +1 -2
- data/test/jobs/connector_playbook_execution_reporter_task_test.rb +1 -2
- data/test/jobs/exponential_backoff_test.rb +2 -1
- data/test/jobs/inventory_hosts_sync_test.rb +53 -5
- data/test/test_plugin_helper.rb +8 -0
- data/test/unit/rh_cloud_permissions_test.rb +2 -1
- data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +4 -5
- data/test/unit/services/foreman_rh_cloud/hit_remediations_retriever_test.rb +2 -2
- data/test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb +1 -1
- data/test/unit/slice_generator_test.rb +1 -1
- data/test/unit/tags_generator_test.rb +5 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cacfda4be0f9786225bb206cd63b4a1904867fb49383bb9b9f0e911cc948990
|
4
|
+
data.tar.gz: 3e973105f40419257f6a4555420286ef47955f74962e7798d6f329d7b5b47a01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f30326a06444b4f746b129839a3e228d90cfe0237a26cb251d013e09a64ad9c20d530e7611d102082d1f2c252e19d748b058fab75f44649880395ccaa2fb1ec
|
7
|
+
data.tar.gz: 3b331d263956ff30f8da848ce249ea13a4b16f09a17dce7b70f01d37f92f516aaf2d9ecd4a0db65c5ffb053b02d6d1efa4d6197ad9abc7426a509627dcd70cf1
|
data/README.md
CHANGED
@@ -83,7 +83,7 @@ Fork and send a Pull Request. Thanks!
|
|
83
83
|
|
84
84
|
## Copyright
|
85
85
|
|
86
|
-
Copyright (c)
|
86
|
+
Copyright (c) 2013 - 2024 - The Foreman Team
|
87
87
|
|
88
88
|
This program is free software: you can redistribute it and/or modify
|
89
89
|
it under the terms of the GNU General Public License as published by
|
@@ -17,7 +17,7 @@ module InsightsCloud
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def subscribed_host_by_uuid(uuid)
|
20
|
-
@host = Host.unscoped.joins(:subscription_facet).where(:katello_subscription_facets => {:uuid => uuid }).first
|
20
|
+
@host = Host.unscoped.joins(:subscription_facet).where(:katello_subscription_facets => { :uuid => uuid }).first
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -14,12 +14,12 @@ module RhCloudHost
|
|
14
14
|
|
15
15
|
has_one :insights_client_report_status_object, :class_name => '::InsightsClientReportStatus', :foreign_key => 'host_id'
|
16
16
|
scoped_search :relation => :insights_client_report_status_object, :on => :status, :rename => :insights_client_report_status,
|
17
|
-
|
18
|
-
|
17
|
+
:complete_value => { :reporting => ::InsightsClientReportStatus::REPORTING,
|
18
|
+
:no_report => ::InsightsClientReportStatus::NO_REPORT }
|
19
19
|
|
20
20
|
has_one :inventory_sync_status_object, :class_name => '::InventorySync::InventoryStatus', :foreign_key => 'host_id'
|
21
21
|
scoped_search :relation => :inventory_sync_status_object, :on => :status, :rename => :insights_inventory_sync_status,
|
22
|
-
|
23
|
-
|
22
|
+
:complete_value => { :disconnect => ::InventorySync::InventoryStatus::DISCONNECT,
|
23
|
+
:sync => ::InventorySync::InventoryStatus::SYNC }
|
24
24
|
end
|
25
25
|
end
|
@@ -13,19 +13,19 @@ class InsightsClientReportStatus < HostStatus::Status
|
|
13
13
|
|
14
14
|
def to_label(_options = {})
|
15
15
|
case status
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
when REPORTING
|
17
|
+
N_('Reporting')
|
18
|
+
when NO_REPORT
|
19
|
+
N_('Not reporting')
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
def to_global(_options = {})
|
24
24
|
case status
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
when REPORTING
|
26
|
+
::HostStatus::Global::OK
|
27
|
+
when NO_REPORT
|
28
|
+
::HostStatus::Global::ERROR
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -4,5 +4,5 @@ class InsightsFacet < HostFacets::Base
|
|
4
4
|
primary_key: :host_id,
|
5
5
|
class_name: 'InsightsHit',
|
6
6
|
dependent: :destroy
|
7
|
-
scope :for_organizations, ->(organization_ids) { joins(:host).where(hosts: { organization_id: organization_ids}) }
|
7
|
+
scope :for_organizations, ->(organization_ids) { joins(:host).where(hosts: { organization_id: organization_ids }) }
|
8
8
|
end
|
data/app/models/insights_hit.rb
CHANGED
@@ -8,7 +8,7 @@ class InsightsHit < ApplicationRecord
|
|
8
8
|
has_one :rule, class_name: 'InsightsRule', foreign_key: 'rule_id', primary_key: 'rule_id'
|
9
9
|
|
10
10
|
scope :with_playbook, -> { joins(:rule) }
|
11
|
-
scope :for_organizations, ->(organization_ids) { joins(:host).where(hosts: { organization_id: organization_ids}) }
|
11
|
+
scope :for_organizations, ->(organization_ids) { joins(:host).where(hosts: { organization_id: organization_ids }) }
|
12
12
|
|
13
13
|
scoped_search on: :title, complete_value: true
|
14
14
|
scoped_search on: :total_risk, complete_value: true
|
@@ -20,10 +20,10 @@ module InventorySync
|
|
20
20
|
|
21
21
|
def to_label
|
22
22
|
case status
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
when DISCONNECT
|
24
|
+
N_('Host was not uploaded to your RH cloud inventory')
|
25
|
+
when SYNC
|
26
|
+
N_('Successfully uploaded to your RH cloud inventory')
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -30,7 +30,8 @@ module ForemanRhCloud
|
|
30
30
|
params: forward_params,
|
31
31
|
user_agent: http_user_agent(original_request),
|
32
32
|
content_type: original_request.media_type.presence || original_request.format.to_s,
|
33
|
-
}
|
33
|
+
}
|
34
|
+
),
|
34
35
|
}
|
35
36
|
base_params.merge(path_params(original_request.path, certs))
|
36
37
|
end
|
@@ -38,7 +39,7 @@ module ForemanRhCloud
|
|
38
39
|
def prepare_forward_payload(original_request, controller_name)
|
39
40
|
forward_payload = original_request.request_parameters[controller_name]
|
40
41
|
|
41
|
-
forward_payload = original_request.raw_post.clone if original_request.post? && original_request.raw_post
|
42
|
+
forward_payload = original_request.raw_post.clone if (original_request.post? || original_request.patch?) && original_request.raw_post
|
42
43
|
forward_payload = original_request.body.read if original_request.put?
|
43
44
|
|
44
45
|
forward_payload = original_request.params.slice(:file, :metadata) if original_request.params[:file]
|
@@ -29,7 +29,7 @@ module ForemanRhCloud
|
|
29
29
|
def remediations
|
30
30
|
@remediations ||= Hash[
|
31
31
|
InsightsResolution.where(id: remediation_ids).pluck(:id, :resolution_type, :rule_id).map do |id, resolution_type, rule_id|
|
32
|
-
[id, {resolution_type: resolution_type, rule_id: rule_id}]
|
32
|
+
[id, { resolution_type: resolution_type, rule_id: rule_id }]
|
33
33
|
end
|
34
34
|
]
|
35
35
|
end
|
data/config/routes.rb
CHANGED
@@ -47,8 +47,8 @@ Rails.application.routes.draw do
|
|
47
47
|
|
48
48
|
# API routes
|
49
49
|
|
50
|
-
namespace :api, :defaults => {:format => 'json'} do
|
51
|
-
scope '(:apiv)', :module => :v2, :defaults => {:apiv => 'v2'}, :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do
|
50
|
+
namespace :api, :defaults => { :format => 'json' } do
|
51
|
+
scope '(:apiv)', :module => :v2, :defaults => { :apiv => 'v2' }, :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do
|
52
52
|
resources :organizations, :only => [:show] do
|
53
53
|
namespace 'rh_cloud' do
|
54
54
|
get 'missing_hosts', to: 'inventory#get_hosts'
|
@@ -6,7 +6,7 @@ module ForemanInventoryUpload
|
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
CLOUD_AMAZON = 'aws'
|
9
|
-
CLOUD_GOOGLE = '
|
9
|
+
CLOUD_GOOGLE = 'gcp'
|
10
10
|
CLOUD_AZURE = 'azure'
|
11
11
|
CLOUD_ALIBABA = 'alibaba'
|
12
12
|
|
@@ -133,7 +133,7 @@ module ForemanInventoryUpload
|
|
133
133
|
|
134
134
|
def uuid_value!(value)
|
135
135
|
uuid = uuid_value(value)
|
136
|
-
raise Foreman::Exception.new(N_('Value %{value} is not a valid UUID') % {value: value}) if value && uuid.empty?
|
136
|
+
raise Foreman::Exception.new(N_('Value %{value} is not a valid UUID') % { value: value }) if value && uuid.empty?
|
137
137
|
|
138
138
|
uuid
|
139
139
|
end
|
@@ -47,6 +47,7 @@ module ForemanInventoryUpload
|
|
47
47
|
@stream.simple_field('account', account_id(host.organization).to_s)
|
48
48
|
@stream.simple_field('subscription_manager_id', uuid_value!(host.subscription_facet&.uuid))
|
49
49
|
@stream.simple_field('satellite_id', uuid_value!(host.subscription_facet&.uuid))
|
50
|
+
@stream.simple_field('convert2rhel_through_foreman', host.subscription_facet&.convert2rhel_through_foreman)
|
50
51
|
@stream.simple_field('bios_uuid', bios_uuid(host))
|
51
52
|
@stream.simple_field('vm_uuid', uuid_value(fact_value(host, 'virt::uuid')))
|
52
53
|
@stream.simple_field('insights_id', uuid_value(fact_value(host, 'insights_id')))
|
@@ -75,7 +75,7 @@ module ForemanInventoryUpload
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def self.inventory_export_url
|
78
|
-
tags =
|
78
|
+
tags = CGI.escape("satellite/satellite_instance_id=#{Foreman.instance_id}")
|
79
79
|
inventory_base_url + "?tags=#{tags}"
|
80
80
|
end
|
81
81
|
|
@@ -97,8 +97,8 @@ module ForemanRhCloud
|
|
97
97
|
generate a report, upload it to the cloud and download it locally'
|
98
98
|
|
99
99
|
add_permissions_to_default_roles Role::ORG_ADMIN => plugin_permissions,
|
100
|
-
|
101
|
-
|
100
|
+
Role::MANAGER => plugin_permissions,
|
101
|
+
Role::SYSTEM_ADMIN => plugin_permissions
|
102
102
|
|
103
103
|
# Adding a sub menu after hosts menu
|
104
104
|
divider :top_menu, caption: N_('RH Cloud'), parent: :configure_menu
|
data/lib/foreman_rh_cloud.rb
CHANGED
@@ -94,13 +94,13 @@ module ForemanRhCloud
|
|
94
94
|
# For testing purposes we can override the default hostname with an environment variable SATELLITE_RH_CLOUD_FOREMAN_HOST
|
95
95
|
def self.foreman_host
|
96
96
|
@foreman_host ||= begin
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
97
|
+
fullname = foreman_host_name
|
98
|
+
::Host.unscoped.friendly.find(fullname)
|
99
|
+
rescue ActiveRecord::RecordNotFound
|
100
|
+
# fullname didn't work. Let's try shortname
|
101
|
+
shortname = /(?<shortname>[^\.]*)\.?.*/.match(fullname)[:shortname]
|
102
|
+
::Host.unscoped.friendly.find(shortname)
|
103
|
+
end
|
104
104
|
end
|
105
105
|
|
106
106
|
def self.foreman_host_name
|
@@ -133,7 +133,7 @@ module InsightsCloud
|
|
133
133
|
]
|
134
134
|
end.compact]
|
135
135
|
|
136
|
-
{task_state: {task_done_reported: task_done_state}, hosts_state: hosts_state}
|
136
|
+
{ task_state: { task_done_reported: task_done_state }, hosts_state: hosts_state }
|
137
137
|
end
|
138
138
|
|
139
139
|
def task_status(host_task, host_name)
|
@@ -41,7 +41,7 @@ module InsightsCloud
|
|
41
41
|
Notification.create!(
|
42
42
|
initiator: User.anonymous_admin,
|
43
43
|
audience: ::Notification::AUDIENCE_ADMIN,
|
44
|
-
message: UINotifications::StringParser.new(blueprint.message, {hits_count: hits_count}).to_s,
|
44
|
+
message: UINotifications::StringParser.new(blueprint.message, { hits_count: hits_count }).to_s,
|
45
45
|
notification_blueprint: blueprint,
|
46
46
|
actions: {
|
47
47
|
links: [
|
@@ -60,7 +60,13 @@ module InsightsCloud
|
|
60
60
|
|
61
61
|
def write_resolutions(response)
|
62
62
|
all_resolutions = response.map do |rule_id, rule_details|
|
63
|
-
rule_details
|
63
|
+
if rule_details
|
64
|
+
rule_details['resolutions'].map { |resolution| to_resolution_hash(to_rule_id(rule_id), resolution) }
|
65
|
+
else
|
66
|
+
logger.info("Rules response: #{rule_id} #{rule_details}")
|
67
|
+
logger.debug("Response: #{response}\n Failed id #{rule_id}")
|
68
|
+
[]
|
69
|
+
end
|
64
70
|
end.flatten
|
65
71
|
|
66
72
|
InsightsResolution.create(all_resolutions)
|
@@ -68,7 +68,7 @@ module InventorySync
|
|
68
68
|
|
69
69
|
def to_ip_address_string(ip_addresses)
|
70
70
|
string_size = 0
|
71
|
-
ip_addresses
|
71
|
+
ip_addresses&.take_while { |address| (string_size += address.length) <= MAX_IP_STRING_SIZE }
|
72
72
|
end
|
73
73
|
|
74
74
|
def plan_self_host_sync
|
data/lib/tasks/insights.rake
CHANGED
@@ -15,9 +15,10 @@ namespace :rh_cloud_insights do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
cleaner = ForemanRhCloud::InsightsStatusCleaner.new
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
User.as_anonymous_admin do
|
19
|
+
deleted_count = cleaner.clean(hosts_search)
|
20
|
+
puts "Deleted #{deleted_count} insights statuses"
|
21
|
+
end
|
21
22
|
end
|
22
23
|
|
23
24
|
desc "Re-announce all organizations into Sources on RH cloud."
|
data/package.json
CHANGED
@@ -42,7 +42,7 @@ module InsightsCloud::Api
|
|
42
42
|
end.returns(res)
|
43
43
|
InsightsCloud::Api::MachineTelemetriesController.any_instance.expects(:cp_owner_id).returns('123')
|
44
44
|
|
45
|
-
post :forward_request, as: :json, params: { "path" => "static/v1/test", "machine_telemetry" => {"foo" => "bar"} }
|
45
|
+
post :forward_request, as: :json, params: { "path" => "static/v1/test", "machine_telemetry" => { "foo" => "bar" } }
|
46
46
|
assert_equal @body, @response.body
|
47
47
|
end
|
48
48
|
|
@@ -62,7 +62,7 @@ module InsightsCloud::Api
|
|
62
62
|
|
63
63
|
test "should set etag header to response from cloud" do
|
64
64
|
etag = '12345'
|
65
|
-
req = RestClient::Request.new(:method => 'GET', :url => 'http://test.theforeman.org', :headers => { "If-None-Match": etag})
|
65
|
+
req = RestClient::Request.new(:method => 'GET', :url => 'http://test.theforeman.org', :headers => { "If-None-Match": etag })
|
66
66
|
net_http_resp = Net::HTTPResponse.new(1.0, 200, "OK")
|
67
67
|
net_http_resp[Rack::ETAG] = etag
|
68
68
|
res = RestClient::Response.create(@body, net_http_resp, req)
|
@@ -107,6 +107,7 @@ module InsightsCloud::Api
|
|
107
107
|
|
108
108
|
context '#branch_info' do
|
109
109
|
setup do
|
110
|
+
UpstreamOnlySettingsTestHelper.set_if_available('allow_multiple_content_views')
|
110
111
|
User.current = User.find_by(login: 'secret_admin')
|
111
112
|
|
112
113
|
@env = FactoryBot.create(:katello_k_t_environment)
|
@@ -122,11 +123,13 @@ module InsightsCloud::Api
|
|
122
123
|
FactoryBot.create(
|
123
124
|
:katello_content_view_environment,
|
124
125
|
content_view: FactoryBot.create(:katello_content_view, organization: @env.organization),
|
125
|
-
lifecycle_environment: @env
|
126
|
+
lifecycle_environment: @env
|
127
|
+
),
|
126
128
|
FactoryBot.create(
|
127
129
|
:katello_content_view_environment,
|
128
130
|
content_view: FactoryBot.create(:katello_content_view, organization: @env.organization),
|
129
|
-
lifecycle_environment: @env2
|
131
|
+
lifecycle_environment: @env2
|
132
|
+
),
|
130
133
|
],
|
131
134
|
organization: @env.organization
|
132
135
|
)
|
@@ -14,7 +14,7 @@ module InventoryUpload::Api
|
|
14
14
|
.expects(:start_report_generation)
|
15
15
|
.with(@test_org.id.to_s, @disconnected)
|
16
16
|
|
17
|
-
post :generate_report, params: { organization_id: @test_org.id, disconnected: @disconnected}
|
17
|
+
post :generate_report, params: { organization_id: @test_org.id, disconnected: @disconnected }
|
18
18
|
|
19
19
|
assert_response :success
|
20
20
|
end
|
@@ -56,7 +56,7 @@ end
|
|
56
56
|
|
57
57
|
FactoryBot.define do
|
58
58
|
factory :katello_subscription_facets, :aliases => [:subscription_facet], :class => ::Katello::Host::SubscriptionFacet do
|
59
|
-
sequence(:uuid) { |n| "00000000-%<n>04d-%<r>04d-0000-000000000000" % {n: n, r: rand(500)} }
|
59
|
+
sequence(:uuid) { |n| "00000000-%<n>04d-%<r>04d-0000-000000000000" % { n: n, r: rand(500) } }
|
60
60
|
facts { { 'memory.memtotal' => "12 GB" } }
|
61
61
|
end
|
62
62
|
end
|
@@ -60,8 +60,7 @@ class CloudConnectorAnnounceTaskTest < ActiveSupport::TestCase
|
|
60
60
|
|
61
61
|
template_invocation = FactoryBot.build(:template_invocation,
|
62
62
|
:template => job_template,
|
63
|
-
:job_invocation => job_invocation
|
64
|
-
)
|
63
|
+
:job_invocation => job_invocation)
|
65
64
|
|
66
65
|
template_invocation.input_values << FactoryBot.create(
|
67
66
|
:template_invocation_input_value,
|
@@ -217,8 +217,7 @@ class ConnectorPlaybookExecutionReporterTaskTest < ActiveSupport::TestCase
|
|
217
217
|
|
218
218
|
template_invocation = FactoryBot.build(:template_invocation,
|
219
219
|
:template => job_template,
|
220
|
-
:job_invocation => job_invocation
|
221
|
-
)
|
220
|
+
:job_invocation => job_invocation)
|
222
221
|
|
223
222
|
template_invocation.input_values << FactoryBot.create(
|
224
223
|
:template_invocation_input_value,
|
@@ -44,11 +44,59 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
44
44
|
|
45
45
|
inventory_json = <<-INVENTORY_JSON
|
46
46
|
{
|
47
|
-
"total":
|
48
|
-
"count":
|
47
|
+
"total": 4,
|
48
|
+
"count": 4,
|
49
49
|
"page": 1,
|
50
|
-
"per_page":
|
50
|
+
"per_page": 4,
|
51
51
|
"results": [
|
52
|
+
{
|
53
|
+
"insights_id": "72d29d75-dbbf-4121-9566-2f581ab77f39",
|
54
|
+
"rhel_machine_id": null,
|
55
|
+
"subscription_manager_id": "d29bde40-348e-437c-8acf-8fa98320fc1c",
|
56
|
+
"satellite_id": "bb72bf95-0a19-4090-8009-f0d8c68aca61",
|
57
|
+
"bios_uuid": "b48a7e5f-cb50-4029-a75e-366bf43db642",
|
58
|
+
"fqdn": "rhel81-demo.oss-lab.net",
|
59
|
+
"mac_addresses": [
|
60
|
+
"52:54:00:aa:12:12",
|
61
|
+
"00:00:00:00:00:00"
|
62
|
+
],
|
63
|
+
"external_id": null,
|
64
|
+
"id": "59ab38db-c25b-4fc7-bfb2-c8eb01d865a4",
|
65
|
+
"account": "1460290",
|
66
|
+
"display_name": "insights-rh71.example.com",
|
67
|
+
"ansible_host": null,
|
68
|
+
"facts": [
|
69
|
+
{
|
70
|
+
"namespace": "satellite",
|
71
|
+
"facts": {
|
72
|
+
"virtual_host_name": "virt-who-nobody.home-1",
|
73
|
+
"satellite_instance_id": "fc4d0cb0-a0b0-421e-b096-b028319b8e47",
|
74
|
+
"is_simple_content_access": false,
|
75
|
+
"distribution_version": "7.3",
|
76
|
+
"satellite_version": "6.8.4",
|
77
|
+
"organization_id": 1,
|
78
|
+
"is_hostname_obfuscated": false,
|
79
|
+
"virtual_host_uuid": "a90e6294-4766-420a-8dc0-3ec5b96d60ec"
|
80
|
+
}
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"namespace": "yupana",
|
84
|
+
"facts": {
|
85
|
+
"report_platform_id": "d37afa50-08ce-4efb-a0e5-759c2a016661",
|
86
|
+
"report_slice_id": "5bf791d7-5e30-4a3c-929a-11dd9fa6eb72",
|
87
|
+
"source": "Satellite",
|
88
|
+
"yupana_host_id": "e85958b6-58db-4cfd-aeb6-01ee81bc0f43",
|
89
|
+
"account": "1460290"
|
90
|
+
}
|
91
|
+
}
|
92
|
+
],
|
93
|
+
"reporter": "puptoo",
|
94
|
+
"stale_timestamp": "2021-03-19T07:57:42.466399+00:00",
|
95
|
+
"stale_warning_timestamp": "2021-03-26T07:57:42.466399+00:00",
|
96
|
+
"culled_timestamp": "2021-04-02T07:57:42.466399+00:00",
|
97
|
+
"created": "2021-02-08T14:36:03.613880+00:00",
|
98
|
+
"updated": "2021-03-18T02:57:42.535250+00:00"
|
99
|
+
},
|
52
100
|
{
|
53
101
|
"insights_id": "72d29d75-dbbf-4121-9566-2f581ab77f36",
|
54
102
|
"rhel_machine_id": null,
|
@@ -307,7 +355,7 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
307
355
|
|
308
356
|
ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync, [org])
|
309
357
|
|
310
|
-
assert_equal
|
358
|
+
assert_equal 3, InsightsMissingHost.count
|
311
359
|
end
|
312
360
|
|
313
361
|
test 'Inventory should remove old missing host records' do
|
@@ -324,6 +372,6 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
324
372
|
|
325
373
|
ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync, [org])
|
326
374
|
|
327
|
-
assert_equal
|
375
|
+
assert_equal 3, InsightsMissingHost.count
|
328
376
|
end
|
329
377
|
end
|
data/test/test_plugin_helper.rb
CHANGED
@@ -117,3 +117,11 @@ module CandlepinIsolation
|
|
117
117
|
end
|
118
118
|
end
|
119
119
|
end
|
120
|
+
|
121
|
+
module UpstreamOnlySettingsTestHelper
|
122
|
+
def self.set_if_available(setting_name, value: true)
|
123
|
+
Setting[setting_name] = value
|
124
|
+
rescue Foreman::Exception
|
125
|
+
skip "Setting #{setting_name} is not available in Foreman"
|
126
|
+
end
|
127
|
+
end
|
@@ -10,5 +10,6 @@ class RhCloudPermissionsTest < ActiveSupport::TestCase
|
|
10
10
|
'insights_cloud/api/machine_telemetries/forward_request',
|
11
11
|
'insights_cloud/api/machine_telemetries/branch_info',
|
12
12
|
],
|
13
|
-
skip_patterns: [/^(?!foreman_inventory_upload|insights_cloud|.*rh_cloud).*/]
|
13
|
+
skip_patterns: [/^(?!foreman_inventory_upload|insights_cloud|.*rh_cloud).*/]
|
14
|
+
) # include only plugin paths
|
14
15
|
end
|
@@ -65,16 +65,15 @@ class CloudRequestForwarderTest < ActiveSupport::TestCase
|
|
65
65
|
end
|
66
66
|
|
67
67
|
test 'should forward patch payload' do
|
68
|
-
|
68
|
+
post_data = 'Random PATCH data'
|
69
69
|
req = ActionDispatch::Request.new(
|
70
70
|
'REQUEST_URI' => '/foo/bar?baz=awesome',
|
71
71
|
'REQUEST_METHOD' => 'PATCH',
|
72
72
|
'rack.input' => ::Puma::NullIO.new,
|
73
|
-
'RAW_POST_DATA' =>
|
74
|
-
"action_dispatch.request.path_parameters" => { :format => "json" }
|
75
|
-
"action_dispatch.request.request_parameters" => { 'vegetables' => params }
|
73
|
+
'RAW_POST_DATA' => post_data,
|
74
|
+
"action_dispatch.request.path_parameters" => { :format => "json" }
|
76
75
|
)
|
77
|
-
assert_equal
|
76
|
+
assert_equal post_data, @forwarder.prepare_forward_payload(req, 'Random PATCH data')
|
78
77
|
end
|
79
78
|
|
80
79
|
test 'should forward file with metadata' do
|
@@ -15,7 +15,7 @@ class HitRemediationsRetrieverTest < ActiveSupport::TestCase
|
|
15
15
|
FactoryBot.create(:insights_facet, uuid: 'HOST2', host_id: @host2.id)
|
16
16
|
host2_hit1 = FactoryBot.create(:insights_hit, rule_id: rule1.rule_id, host_id: @host2.id)
|
17
17
|
|
18
|
-
pairs = [{'hit_id' => host1_hit1.id, 'resolution_id' => rule1_remediation1.id}, {'hit_id' => host2_hit1.id, 'resolution_id' => rule1_remediation1.id}]
|
18
|
+
pairs = [{ 'hit_id' => host1_hit1.id, 'resolution_id' => rule1_remediation1.id }, { 'hit_id' => host2_hit1.id, 'resolution_id' => rule1_remediation1.id }]
|
19
19
|
retriever = ForemanRhCloud::HitRemediationsRetriever.new(pairs)
|
20
20
|
|
21
21
|
actual_request = retriever.send(:playbook_request)
|
@@ -38,7 +38,7 @@ class HitRemediationsRetrieverTest < ActiveSupport::TestCase
|
|
38
38
|
FactoryBot.create(:insights_facet, uuid: 'HOST2', host_id: @host2.id)
|
39
39
|
host2_hit1 = FactoryBot.create(:insights_hit, rule_id: rule1.rule_id, host_id: @host2.id)
|
40
40
|
|
41
|
-
pairs = [{'hit_id' => host1_hit1.id, 'resolution_id' => rule1_remediation1.id}, {'hit_id' => host2_hit1.id, 'resolution_id' => rule1_remediation2.id}]
|
41
|
+
pairs = [{ 'hit_id' => host1_hit1.id, 'resolution_id' => rule1_remediation1.id }, { 'hit_id' => host2_hit1.id, 'resolution_id' => rule1_remediation2.id }]
|
42
42
|
retriever = ForemanRhCloud::HitRemediationsRetriever.new(pairs)
|
43
43
|
|
44
44
|
actual_request = retriever.send(:playbook_request)
|
@@ -20,7 +20,7 @@ class TemplateRendererHelperTest < ActiveSupport::TestCase
|
|
20
20
|
hit = FactoryBot.create(:insights_hit, rule: rule, host_id: @host1.id)
|
21
21
|
remediation = FactoryBot.create(:insights_resolution, rule: rule)
|
22
22
|
|
23
|
-
pairs = [{hit_id: hit.id, remediation_id: remediation.id}].to_json
|
23
|
+
pairs = [{ hit_id: hit.id, remediation_id: remediation.id }].to_json
|
24
24
|
|
25
25
|
actual_playbook = remediations_playbook(pairs)
|
26
26
|
|
@@ -594,7 +594,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
594
594
|
assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
|
595
595
|
assert_not_nil(actual_host = actual['hosts'].first)
|
596
596
|
assert_not_nil(actual_profile = actual_host['system_profile'])
|
597
|
-
assert_equal '
|
597
|
+
assert_equal 'gcp', actual_profile['cloud_provider']
|
598
598
|
end
|
599
599
|
|
600
600
|
test 'Identifies Azure cloud provider' do
|
@@ -5,6 +5,7 @@ class TagsGeneratorTest < ActiveSupport::TestCase
|
|
5
5
|
include CandlepinIsolation
|
6
6
|
|
7
7
|
setup do
|
8
|
+
UpstreamOnlySettingsTestHelper.set_if_available('allow_multiple_content_views')
|
8
9
|
User.current = User.find_by(login: 'secret_admin')
|
9
10
|
|
10
11
|
env = FactoryBot.create(:katello_k_t_environment)
|
@@ -28,11 +29,13 @@ class TagsGeneratorTest < ActiveSupport::TestCase
|
|
28
29
|
FactoryBot.create(
|
29
30
|
:katello_content_view_environment,
|
30
31
|
content_view: FactoryBot.create(:katello_content_view, organization: env.organization),
|
31
|
-
lifecycle_environment: env
|
32
|
+
lifecycle_environment: env
|
33
|
+
),
|
32
34
|
FactoryBot.create(
|
33
35
|
:katello_content_view_environment,
|
34
36
|
content_view: FactoryBot.create(:katello_content_view, organization: env.organization),
|
35
|
-
lifecycle_environment: env2
|
37
|
+
lifecycle_environment: env2
|
38
|
+
),
|
36
39
|
]
|
37
40
|
)
|
38
41
|
|
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
|
+
version: 10.0.2
|
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: 2024-
|
11
|
+
date: 2024-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foreman_ansible
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 4.14.0.rc1.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 4.14.0.rc1.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rdoc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.0
|
75
|
+
version: 0.1.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.0
|
82
|
+
version: 0.1.0
|
83
83
|
description: Foreman plugin that process & upload data to Red Hat Cloud
|
84
84
|
email:
|
85
85
|
- rlavi@redhat.com, sshtein@redhat.com
|