foreman_rh_cloud 3.0.24.1 → 3.0.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/services/foreman_rh_cloud/cloud_auth.rb +4 -0
- data/app/services/foreman_rh_cloud/remediations_retriever.rb +5 -0
- data/lib/foreman_inventory_upload/generators/tags.rb +3 -1
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/insights_cloud/async/insights_full_sync.rb +5 -0
- data/lib/insights_cloud/async/insights_resolutions_sync.rb +9 -0
- data/lib/insights_cloud/async/insights_rules_sync.rb +5 -0
- data/lib/inventory_sync/async/inventory_full_sync.rb +5 -0
- data/lib/inventory_sync/async/inventory_hosts_sync.rb +5 -0
- data/lib/inventory_sync/async/inventory_self_host_sync.rb +9 -0
- data/package.json +1 -1
- data/test/jobs/insights_full_sync_test.rb +1 -0
- data/test/jobs/insights_resolutions_sync_test.rb +1 -0
- data/test/jobs/insights_rules_sync_test.rb +1 -0
- data/test/jobs/inventory_full_sync_test.rb +10 -0
- data/test/jobs/inventory_hosts_sync_test.rb +1 -0
- data/test/jobs/inventory_self_host_sync_test.rb +1 -0
- data/test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb +1 -0
- data/test/unit/tags_generator_test.rb +41 -0
- data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.scss +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcdeab4d9295cecfb21182db7a6d67616a89ccf47a1a49b290058bcdfbc0f990
|
4
|
+
data.tar.gz: 0524546fe41d9ca57ce8a881dc011c8d0973a0900c79bdbf51a5ef69577d11c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 129e721b9ff7701d391189631a4782bccabd38d22e1d8bbf25093c9fda21c00d1c260489621a6f42b06dc2357e09cfc126f41deda9d367b931a082548bcb9665
|
7
|
+
data.tar.gz: 4544b0097e5131166c03cd68a35b9320f7ffbe770da6db99edc7693d2da3aafa4eb845a17de8d37bf7635038a8e9b7b26fb87e747317f82032459e4d8d7306e7
|
@@ -12,6 +12,11 @@ module ForemanRhCloud
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def create_playbook
|
15
|
+
unless cloud_auth_available?
|
16
|
+
logger.debug('Cloud authentication is not available, cannot continue')
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
15
20
|
response = query_playbook
|
16
21
|
|
17
22
|
logger.debug("Got playbook response: #{response.body}")
|
@@ -19,7 +19,9 @@ module ForemanInventoryUpload
|
|
19
19
|
def generate_parameters
|
20
20
|
return [] unless Setting[:include_parameter_tags]
|
21
21
|
|
22
|
-
(@host.host_inherited_params_objects || [])
|
22
|
+
(@host.host_inherited_params_objects || [])
|
23
|
+
.map { |item| [item.name, item.value] }
|
24
|
+
.select { |_name, value| value.present? || value.is_a?(FalseClass) }
|
23
25
|
end
|
24
26
|
|
25
27
|
private
|
@@ -6,6 +6,11 @@ module InsightsCloud
|
|
6
6
|
include ::ForemanRhCloud::CloudAuth
|
7
7
|
|
8
8
|
def plan
|
9
|
+
unless cloud_auth_available?
|
10
|
+
logger.debug('Cloud authentication is not available, skipping insights sync')
|
11
|
+
return
|
12
|
+
end
|
13
|
+
|
9
14
|
sequence do
|
10
15
|
# This can be turned off when we enable automatic status syncs
|
11
16
|
# This step will query cloud inventory to retrieve inventory uuids for each host
|
@@ -7,6 +7,15 @@ module InsightsCloud
|
|
7
7
|
|
8
8
|
RULE_ID_REGEX = /[^:]*:(?<id>.*)/
|
9
9
|
|
10
|
+
def plan
|
11
|
+
unless cloud_auth_available?
|
12
|
+
logger.debug('Cloud authentication is not available, skipping resolutions sync')
|
13
|
+
return
|
14
|
+
end
|
15
|
+
|
16
|
+
plan_self
|
17
|
+
end
|
18
|
+
|
10
19
|
def run
|
11
20
|
InsightsResolution.transaction do
|
12
21
|
InsightsResolution.delete_all
|
@@ -5,6 +5,11 @@ module InventorySync
|
|
5
5
|
set_callback :step, :around, :update_statuses_batch
|
6
6
|
|
7
7
|
def plan(organization)
|
8
|
+
unless cloud_auth_available?
|
9
|
+
logger.debug('Cloud authentication is not available, skipping inventory hosts sync')
|
10
|
+
return
|
11
|
+
end
|
12
|
+
|
8
13
|
plan_self(organization_id: organization.id)
|
9
14
|
end
|
10
15
|
|
@@ -5,6 +5,11 @@ module InventorySync
|
|
5
5
|
set_callback :step, :around, :create_facets
|
6
6
|
|
7
7
|
def plan
|
8
|
+
unless cloud_auth_available?
|
9
|
+
logger.debug('Cloud authentication is not available, skipping inventory hosts sync')
|
10
|
+
return
|
11
|
+
end
|
12
|
+
|
8
13
|
# by default the tasks will be executed concurrently
|
9
14
|
plan_self
|
10
15
|
plan_self_host_sync
|
@@ -3,6 +3,15 @@ module InventorySync
|
|
3
3
|
class InventorySelfHostSync < QueryInventoryJob
|
4
4
|
set_callback :step, :around, :create_facets
|
5
5
|
|
6
|
+
def plan
|
7
|
+
unless cloud_auth_available?
|
8
|
+
logger.debug('Cloud authentication is not available, skipping self host sync')
|
9
|
+
return
|
10
|
+
end
|
11
|
+
|
12
|
+
plan_self
|
13
|
+
end
|
14
|
+
|
6
15
|
def create_facets
|
7
16
|
# get the results from the event
|
8
17
|
results = yield
|
data/package.json
CHANGED
@@ -7,6 +7,7 @@ class InsightsFullSyncTest < ActiveSupport::TestCase
|
|
7
7
|
setup do
|
8
8
|
InsightsCloud::Async::InsightsFullSync.any_instance.stubs(:plan_rules_sync)
|
9
9
|
InsightsCloud::Async::InsightsFullSync.any_instance.stubs(:plan_notifications)
|
10
|
+
FactoryBot.create(:setting, name: 'rh_cloud_token', value: 'MOCK_TOKEN')
|
10
11
|
|
11
12
|
uuid1 = 'accdf444-5628-451d-bf3e-cf909ad72756'
|
12
13
|
@host1 = FactoryBot.create(:host, :managed, name: 'host1')
|
@@ -63,6 +63,7 @@ class InsightsResolutionsSyncTest < ActiveSupport::TestCase
|
|
63
63
|
}
|
64
64
|
|
65
65
|
@rule = FactoryBot.create(:insights_rule, rule_id: 'network_tcp_connection_hang|NETWORK_TCP_CONNECTION_HANG_WARN')
|
66
|
+
FactoryBot.create(:setting, name: 'rh_cloud_token', value: 'MOCK_TOKEN')
|
66
67
|
end
|
67
68
|
|
68
69
|
test 'Resolutions data is replaced with data from cloud' do
|
@@ -112,6 +112,7 @@ class InsightsRulesSyncTest < ActiveSupport::TestCase
|
|
112
112
|
@hit = FactoryBot.create(:insights_hit, host_id: @host.id)
|
113
113
|
|
114
114
|
InsightsCloud::Async::InsightsRulesSync.any_instance.stubs(:plan_resolutions)
|
115
|
+
FactoryBot.create(:setting, name: 'rh_cloud_token', value: 'MOCK_TOKEN')
|
115
116
|
end
|
116
117
|
|
117
118
|
test 'Hits data is replaced with data from cloud' do
|
@@ -242,6 +242,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
242
242
|
end
|
243
243
|
|
244
244
|
test 'Host status should be SYNC for inventory hosts' do
|
245
|
+
FactoryBot.create(:setting, name: 'rh_cloud_token', value: 'TEST TOKEN')
|
245
246
|
InventorySync::Async::InventoryFullSync.any_instance.expects(:query_inventory).returns(@inventory)
|
246
247
|
|
247
248
|
ForemanTasks.sync_task(InventorySync::Async::InventoryFullSync, @host2.organization)
|
@@ -253,6 +254,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
253
254
|
end
|
254
255
|
|
255
256
|
test 'Host status should be DISCONNECT for hosts that are not returned from cloud' do
|
257
|
+
FactoryBot.create(:setting, name: 'rh_cloud_token', value: 'TEST TOKEN')
|
256
258
|
InventorySync::Async::InventoryFullSync.any_instance.expects(:query_inventory).returns(@inventory)
|
257
259
|
FactoryBot.create(:fact_value, fact_name: fact_names['virt::uuid'], value: '1234', host: @host2)
|
258
260
|
|
@@ -261,4 +263,12 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
261
263
|
|
262
264
|
assert_equal InventorySync::InventoryStatus::DISCONNECT, InventorySync::InventoryStatus.where(host_id: @host1.id).first.status
|
263
265
|
end
|
266
|
+
|
267
|
+
test 'Task should be aborted if token is not present' do
|
268
|
+
FactoryBot.create(:setting, name: 'rh_cloud_token', value: '')
|
269
|
+
|
270
|
+
InventorySync::Async::InventoryFullSync.any_instance.expects(:plan_self).never
|
271
|
+
|
272
|
+
ForemanTasks.sync_task(InventorySync::Async::InventoryFullSync, @host1.organization)
|
273
|
+
end
|
264
274
|
end
|
@@ -6,6 +6,7 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
6
6
|
|
7
7
|
setup do
|
8
8
|
User.current = User.find_by(login: 'secret_admin')
|
9
|
+
FactoryBot.create(:setting, name: 'rh_cloud_token', value: 'MOCK_TOKEN')
|
9
10
|
|
10
11
|
env = FactoryBot.create(:katello_k_t_environment)
|
11
12
|
cv = env.content_views << FactoryBot.create(:katello_content_view, organization: env.organization)
|
@@ -6,6 +6,7 @@ class InventorySelfHostSyncTest < ActiveSupport::TestCase
|
|
6
6
|
|
7
7
|
setup do
|
8
8
|
User.current = User.find_by(login: 'secret_admin')
|
9
|
+
FactoryBot.create(:setting, name: 'rh_cloud_token', value: 'MOCK_TOKEN')
|
9
10
|
|
10
11
|
# this host would pass our plugin queries, so it could be uploaded to the cloud.
|
11
12
|
@host1 = FactoryBot.create(:host)
|
@@ -8,6 +8,7 @@ class TemplateRendererHelperTest < ActiveSupport::TestCase
|
|
8
8
|
response.stubs(:body).returns('TEST PLAYBOOK')
|
9
9
|
ForemanRhCloud::RemediationsRetriever.any_instance.stubs(:query_playbook).returns(response)
|
10
10
|
@host1 = FactoryBot.create(:host)
|
11
|
+
FactoryBot.create(:setting, name: 'rh_cloud_token', value: 'MOCK_TOKEN')
|
11
12
|
end
|
12
13
|
|
13
14
|
test 'Generates a playbook for hit and remediation' do
|
@@ -62,6 +62,47 @@ class TagsGeneratorTest < ActiveSupport::TestCase
|
|
62
62
|
assert_equal false, actual.key?('content_view')
|
63
63
|
end
|
64
64
|
|
65
|
+
test 'generates parameter tags' do
|
66
|
+
FactoryBot.create(:setting, :name => 'include_parameter_tags', :settings_type => "boolean", :category => "Setting::RhCloud", :default => false, :value => true)
|
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
|
+
]
|
76
|
+
)
|
77
|
+
|
78
|
+
generator = create_generator
|
79
|
+
actual = Hash[generator.generate_parameters]
|
80
|
+
|
81
|
+
assert_equal 3, actual.count
|
82
|
+
assert_equal true, actual['bool_param']
|
83
|
+
assert_equal false, actual['false_param']
|
84
|
+
assert_equal 1, actual['int_param']
|
85
|
+
end
|
86
|
+
|
87
|
+
test 'skips parameter tags if include_parameter_tags setting is off' do
|
88
|
+
FactoryBot.create(:setting, :name => 'include_parameter_tags', :settings_type => "boolean", :category => "Setting::RhCloud", :default => false, :value => false)
|
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
|
+
]
|
98
|
+
)
|
99
|
+
|
100
|
+
generator = create_generator
|
101
|
+
actual = generator.generate_parameters.group_by { |key, value| key }
|
102
|
+
|
103
|
+
assert_equal 0, actual.count
|
104
|
+
end
|
105
|
+
|
65
106
|
private
|
66
107
|
|
67
108
|
def create_generator
|
@@ -6,4 +6,18 @@
|
|
6
6
|
margin-top: 5px;
|
7
7
|
}
|
8
8
|
}
|
9
|
+
|
10
|
+
// applies to the backdrop parent of the modal
|
11
|
+
@at-root .pf-c-backdrop {
|
12
|
+
width: calc(100% - 200px) !important;
|
13
|
+
left: 200px !important;
|
14
|
+
}
|
15
|
+
|
16
|
+
// where the vertical nav breaks: https://github.com/theforeman/foreman/blob/3347fa49d500964f0209122d8d36c920d1feafcc/webpack/assets/javascripts/react_app/components/Layout/components/Toolbar/HeaderToolbar.scss#L26
|
17
|
+
@media (max-width: 768px) {
|
18
|
+
@at-root .pf-c-backdrop {
|
19
|
+
width: 100% !important;
|
20
|
+
left: 0 !important;
|
21
|
+
}
|
22
|
+
}
|
9
23
|
}
|
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: 3.0.
|
4
|
+
version: 3.0.25
|
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-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: katello
|