foreman_rh_cloud 3.0.24.1 → 3.0.29
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/cloud_request_forwarder.rb +10 -0
- data/app/services/foreman_rh_cloud/remediations_retriever.rb +5 -0
- data/config/Gemfile.lock.gh_test +93 -95
- data/config/database.yml.example +2 -2
- data/config/routes.rb +1 -1
- data/lib/foreman_inventory_upload/generators/tags.rb +3 -1
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/foreman_rh_cloud.rb +12 -1
- data/lib/insights_cloud/async/insights_full_sync.rb +5 -0
- data/lib/insights_cloud/async/insights_resolutions_sync.rb +12 -2
- data/lib/insights_cloud/async/insights_rules_sync.rb +11 -2
- data/lib/inventory_sync/async/host_result.rb +0 -5
- data/lib/inventory_sync/async/inventory_full_sync.rb +19 -9
- data/lib/inventory_sync/async/inventory_hosts_sync.rb +7 -6
- data/lib/inventory_sync/async/inventory_self_host_sync.rb +9 -0
- data/package.json +3 -3
- data/test/jobs/insights_full_sync_test.rb +1 -0
- data/test/jobs/insights_resolutions_sync_test.rb +11 -1
- data/test/jobs/insights_rules_sync_test.rb +1 -0
- data/test/jobs/inventory_full_sync_test.rb +38 -2
- data/test/jobs/inventory_hosts_sync_test.rb +16 -0
- data/test/jobs/inventory_self_host_sync_test.rb +1 -0
- data/test/unit/foreman_rh_cloud_self_host_test.rb +28 -0
- data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_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 +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a50f0107b0ee371ca53cac0aa1cc4efcb4cddb0e71682812fcf14b035298a635
|
4
|
+
data.tar.gz: 90a60ab9b0ad34c6f2afd16f6f1f896352f274fa375151232744c2fae9535430
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6b5ef45a9aaec31e4507245426ec4dd5a27d1cd91ac5df66b5240d9554a3e2282d3f9d2ffb9fbbe0f8ddedcef1e856d31b3dab64ca7da073bf6b61c1cf3b473
|
7
|
+
data.tar.gz: 032f6945342c0bd9868234006b5b50f24986c4397be70152e73a05fb468e725314a768c48bd4c2eb6cf996ed161d035a60c5e45b549e489417e8c691ece43883
|
@@ -62,6 +62,12 @@ module ForemanRhCloud
|
|
62
62
|
ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
|
63
63
|
ssl_client_key: OpenSSL::PKey::RSA.new(certs[:key]),
|
64
64
|
}
|
65
|
+
when connection_test_request?
|
66
|
+
{
|
67
|
+
url: ForemanRhCloud.cert_base_url + '/api/apicast-tests/ping',
|
68
|
+
ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
|
69
|
+
ssl_client_key: OpenSSL::PKey::RSA.new(certs[:key]),
|
70
|
+
}
|
65
71
|
else # Legacy insights API
|
66
72
|
{
|
67
73
|
url: ForemanRhCloud.legacy_insights_url + request_path.sub('/redhat_access/r/insights', '/r/insights'),
|
@@ -76,6 +82,10 @@ module ForemanRhCloud
|
|
76
82
|
->(request_path) { request_path.include? '/platform' }
|
77
83
|
end
|
78
84
|
|
85
|
+
def connection_test_request?
|
86
|
+
->(request_path) { request_path =~ /redhat_access\/r\/insights\/?$/ }
|
87
|
+
end
|
88
|
+
|
79
89
|
def prepare_forward_cloud_url(base_url, request_path)
|
80
90
|
cloud_path = request_path.sub('/redhat_access/r/insights/platform/', '')
|
81
91
|
.sub('/redhat_access/r/insights/', '')
|
@@ -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}")
|
data/config/Gemfile.lock.gh_test
CHANGED
@@ -9,27 +9,27 @@ PATH
|
|
9
9
|
PATH
|
10
10
|
remote: ../katello
|
11
11
|
specs:
|
12
|
-
katello (3.18.
|
12
|
+
katello (3.18.3.1)
|
13
13
|
activerecord-import
|
14
14
|
anemone
|
15
15
|
angular-rails-templates (~> 1.1.0)
|
16
16
|
apipie-rails (>= 0.5.14)
|
17
17
|
deface (>= 1.0.2, < 2.0.0)
|
18
18
|
dynflow (>= 1.2.0)
|
19
|
-
foreman-tasks (>= 0.14.1)
|
19
|
+
foreman-tasks (>= 0.14.1, < 4.0)
|
20
20
|
foreman_remote_execution (>= 3.0)
|
21
21
|
fx (< 1.0)
|
22
22
|
gettext_i18n_rails
|
23
23
|
json
|
24
24
|
oauth
|
25
25
|
pg
|
26
|
-
pulp_2to3_migration_client (>= 0.
|
26
|
+
pulp_2to3_migration_client (>= 0.8.0, < 1.0.0)
|
27
27
|
pulp_ansible_client (>= 0.2, < 0.5)
|
28
28
|
pulp_certguard_client (< 2.0)
|
29
29
|
pulp_container_client (>= 2.0.0, < 2.2.0)
|
30
30
|
pulp_deb_client (>= 2.6.0, < 2.8.0)
|
31
31
|
pulp_file_client (>= 1.2.0, < 1.4.0)
|
32
|
-
pulp_rpm_client (>= 3.
|
32
|
+
pulp_rpm_client (>= 3.10.0, < 3.11.0)
|
33
33
|
pulpcore_client (>= 3.6.0, < 3.8.0)
|
34
34
|
rabl
|
35
35
|
rails
|
@@ -41,51 +41,51 @@ PATH
|
|
41
41
|
GEM
|
42
42
|
remote: https://rubygems.org/
|
43
43
|
specs:
|
44
|
-
actioncable (6.0.3.
|
45
|
-
actionpack (= 6.0.3.
|
44
|
+
actioncable (6.0.3.6)
|
45
|
+
actionpack (= 6.0.3.6)
|
46
46
|
nio4r (~> 2.0)
|
47
47
|
websocket-driver (>= 0.6.1)
|
48
|
-
actionmailbox (6.0.3.
|
49
|
-
actionpack (= 6.0.3.
|
50
|
-
activejob (= 6.0.3.
|
51
|
-
activerecord (= 6.0.3.
|
52
|
-
activestorage (= 6.0.3.
|
53
|
-
activesupport (= 6.0.3.
|
48
|
+
actionmailbox (6.0.3.6)
|
49
|
+
actionpack (= 6.0.3.6)
|
50
|
+
activejob (= 6.0.3.6)
|
51
|
+
activerecord (= 6.0.3.6)
|
52
|
+
activestorage (= 6.0.3.6)
|
53
|
+
activesupport (= 6.0.3.6)
|
54
54
|
mail (>= 2.7.1)
|
55
|
-
actionmailer (6.0.3.
|
56
|
-
actionpack (= 6.0.3.
|
57
|
-
actionview (= 6.0.3.
|
58
|
-
activejob (= 6.0.3.
|
55
|
+
actionmailer (6.0.3.6)
|
56
|
+
actionpack (= 6.0.3.6)
|
57
|
+
actionview (= 6.0.3.6)
|
58
|
+
activejob (= 6.0.3.6)
|
59
59
|
mail (~> 2.5, >= 2.5.4)
|
60
60
|
rails-dom-testing (~> 2.0)
|
61
|
-
actionpack (6.0.3.
|
62
|
-
actionview (= 6.0.3.
|
63
|
-
activesupport (= 6.0.3.
|
61
|
+
actionpack (6.0.3.6)
|
62
|
+
actionview (= 6.0.3.6)
|
63
|
+
activesupport (= 6.0.3.6)
|
64
64
|
rack (~> 2.0, >= 2.0.8)
|
65
65
|
rack-test (>= 0.6.3)
|
66
66
|
rails-dom-testing (~> 2.0)
|
67
67
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
68
|
-
actiontext (6.0.3.
|
69
|
-
actionpack (= 6.0.3.
|
70
|
-
activerecord (= 6.0.3.
|
71
|
-
activestorage (= 6.0.3.
|
72
|
-
activesupport (= 6.0.3.
|
68
|
+
actiontext (6.0.3.6)
|
69
|
+
actionpack (= 6.0.3.6)
|
70
|
+
activerecord (= 6.0.3.6)
|
71
|
+
activestorage (= 6.0.3.6)
|
72
|
+
activesupport (= 6.0.3.6)
|
73
73
|
nokogiri (>= 1.8.5)
|
74
|
-
actionview (6.0.3.
|
75
|
-
activesupport (= 6.0.3.
|
74
|
+
actionview (6.0.3.6)
|
75
|
+
activesupport (= 6.0.3.6)
|
76
76
|
builder (~> 3.1)
|
77
77
|
erubi (~> 1.4)
|
78
78
|
rails-dom-testing (~> 2.0)
|
79
79
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
80
|
-
activejob (6.0.3.
|
81
|
-
activesupport (= 6.0.3.
|
80
|
+
activejob (6.0.3.6)
|
81
|
+
activesupport (= 6.0.3.6)
|
82
82
|
globalid (>= 0.3.6)
|
83
|
-
activemodel (6.0.3.
|
84
|
-
activesupport (= 6.0.3.
|
85
|
-
activerecord (6.0.3.
|
86
|
-
activemodel (= 6.0.3.
|
87
|
-
activesupport (= 6.0.3.
|
88
|
-
activerecord-import (1.0
|
83
|
+
activemodel (6.0.3.6)
|
84
|
+
activesupport (= 6.0.3.6)
|
85
|
+
activerecord (6.0.3.6)
|
86
|
+
activemodel (= 6.0.3.6)
|
87
|
+
activesupport (= 6.0.3.6)
|
88
|
+
activerecord-import (1.1.0)
|
89
89
|
activerecord (>= 3.2)
|
90
90
|
activerecord-nulldb-adapter (0.7.0)
|
91
91
|
activerecord (>= 5.2.0, < 6.3)
|
@@ -95,12 +95,12 @@ GEM
|
|
95
95
|
multi_json (~> 1.11, >= 1.11.2)
|
96
96
|
rack (>= 1.5.2, < 3)
|
97
97
|
railties (>= 4.0)
|
98
|
-
activestorage (6.0.3.
|
99
|
-
actionpack (= 6.0.3.
|
100
|
-
activejob (= 6.0.3.
|
101
|
-
activerecord (= 6.0.3.
|
102
|
-
marcel (~> 0.
|
103
|
-
activesupport (6.0.3.
|
98
|
+
activestorage (6.0.3.6)
|
99
|
+
actionpack (= 6.0.3.6)
|
100
|
+
activejob (= 6.0.3.6)
|
101
|
+
activerecord (= 6.0.3.6)
|
102
|
+
marcel (~> 1.0.0)
|
103
|
+
activesupport (6.0.3.6)
|
104
104
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
105
105
|
i18n (>= 0.7, < 2)
|
106
106
|
minitest (~> 5.1)
|
@@ -109,7 +109,7 @@ GEM
|
|
109
109
|
addressable (2.7.0)
|
110
110
|
public_suffix (>= 2.0.2, < 5.0)
|
111
111
|
algebrick (0.7.5)
|
112
|
-
amazing_print (1.
|
112
|
+
amazing_print (1.3.0)
|
113
113
|
ancestry (3.2.1)
|
114
114
|
activerecord (>= 4.2.0)
|
115
115
|
anemone (0.7.2)
|
@@ -134,15 +134,15 @@ GEM
|
|
134
134
|
execjs
|
135
135
|
bcrypt (3.1.16)
|
136
136
|
benchmark-ips (2.8.4)
|
137
|
-
binding_of_caller (
|
137
|
+
binding_of_caller (0.8.0)
|
138
138
|
debug_inspector (>= 0.0.1)
|
139
|
-
bootsnap (1.7.
|
139
|
+
bootsnap (1.7.3)
|
140
140
|
msgpack (~> 1.0)
|
141
141
|
bootstrap-sass (3.4.1)
|
142
142
|
autoprefixer-rails (>= 5.2.1)
|
143
143
|
sassc (>= 2.0.0)
|
144
144
|
builder (3.2.4)
|
145
|
-
bullet (6.1.
|
145
|
+
bullet (6.1.4)
|
146
146
|
activesupport (>= 3.0.0)
|
147
147
|
uniform_notifier (~> 1.11)
|
148
148
|
byebug (11.1.3)
|
@@ -180,12 +180,12 @@ GEM
|
|
180
180
|
daemons (1.3.1)
|
181
181
|
database_cleaner (1.99.0)
|
182
182
|
deacon (1.0.0)
|
183
|
-
debug_inspector (1.
|
183
|
+
debug_inspector (1.1.0)
|
184
184
|
declarative (0.0.20)
|
185
185
|
declarative-option (0.1.0)
|
186
|
-
deep_cloneable (3.
|
186
|
+
deep_cloneable (3.1.0)
|
187
187
|
activerecord (>= 3.1.0, < 7)
|
188
|
-
deface (1.
|
188
|
+
deface (1.8.1)
|
189
189
|
nokogiri (>= 1.6)
|
190
190
|
polyglot
|
191
191
|
rails (>= 5.2)
|
@@ -193,7 +193,7 @@ GEM
|
|
193
193
|
docile (1.3.5)
|
194
194
|
domain_name (0.5.20190701)
|
195
195
|
unf (>= 0.0.5, < 1.0.0)
|
196
|
-
dynflow (1.
|
196
|
+
dynflow (1.5.0)
|
197
197
|
algebrick (~> 0.7.0)
|
198
198
|
apipie-params
|
199
199
|
concurrent-ruby (~> 1.1.3)
|
@@ -203,7 +203,7 @@ GEM
|
|
203
203
|
erubi (1.10.0)
|
204
204
|
excon (0.79.0)
|
205
205
|
execjs (2.7.0)
|
206
|
-
facter (4.0.
|
206
|
+
facter (4.0.52)
|
207
207
|
hocon (~> 1.3)
|
208
208
|
thor (>= 1.0.1, < 2.0)
|
209
209
|
factory_bot (5.2.0)
|
@@ -270,7 +270,7 @@ GEM
|
|
270
270
|
sinatra
|
271
271
|
foreman-tasks-core (0.3.4)
|
272
272
|
dynflow (>= 1.2.0)
|
273
|
-
foreman_ansible (6.
|
273
|
+
foreman_ansible (6.2.0)
|
274
274
|
deface (< 2.0)
|
275
275
|
foreman_remote_execution (>= 4.2.0)
|
276
276
|
ipaddress (>= 0.8.0, < 1.0)
|
@@ -338,7 +338,7 @@ GEM
|
|
338
338
|
http-cookie (1.0.3)
|
339
339
|
domain_name (~> 0.5)
|
340
340
|
httpclient (2.8.3)
|
341
|
-
i18n (1.8.
|
341
|
+
i18n (1.8.10)
|
342
342
|
concurrent-ruby (~> 1.0)
|
343
343
|
immigrant (0.3.6)
|
344
344
|
activerecord (>= 3.0)
|
@@ -369,16 +369,14 @@ GEM
|
|
369
369
|
nokogiri (>= 1.5.9)
|
370
370
|
mail (2.7.1)
|
371
371
|
mini_mime (>= 0.1.1)
|
372
|
-
marcel (0.
|
373
|
-
mimemagic (~> 0.3.2)
|
372
|
+
marcel (1.0.0)
|
374
373
|
maruku (0.7.3)
|
375
374
|
memoist (0.16.2)
|
376
375
|
method_source (1.0.0)
|
377
376
|
mime-types (3.3.1)
|
378
377
|
mime-types-data (~> 3.2015)
|
379
|
-
mime-types-data (3.
|
380
|
-
|
381
|
-
mini_mime (1.0.2)
|
378
|
+
mime-types-data (3.2021.0225)
|
379
|
+
mini_mime (1.0.3)
|
382
380
|
mini_portile2 (2.5.0)
|
383
381
|
minitest (5.10.3)
|
384
382
|
minitest-reporters (1.4.3)
|
@@ -404,8 +402,8 @@ GEM
|
|
404
402
|
net-ssh (>= 2.6.5, < 7.0.0)
|
405
403
|
net-ssh (4.2.0)
|
406
404
|
netrc (0.11.0)
|
407
|
-
nio4r (2.5.
|
408
|
-
nokogiri (1.11.
|
405
|
+
nio4r (2.5.7)
|
406
|
+
nokogiri (1.11.2)
|
409
407
|
mini_portile2 (~> 2.5.0)
|
410
408
|
racc (~> 1.4)
|
411
409
|
oauth (0.5.5)
|
@@ -415,10 +413,10 @@ GEM
|
|
415
413
|
json (>= 1, < 3)
|
416
414
|
paint (2.2.1)
|
417
415
|
parallel (1.20.1)
|
418
|
-
parallel_tests (3.
|
416
|
+
parallel_tests (3.6.0)
|
419
417
|
parallel
|
420
418
|
parse-cron (0.1.4)
|
421
|
-
parser (3.0.
|
419
|
+
parser (3.0.1.1)
|
422
420
|
ast (~> 2.4.1)
|
423
421
|
patternfly-sass (3.59.5)
|
424
422
|
bootstrap-sass (~> 3.4.0)
|
@@ -430,12 +428,12 @@ GEM
|
|
430
428
|
polyglot (0.3.5)
|
431
429
|
prometheus-client (1.0.0)
|
432
430
|
promise.rb (0.7.4)
|
433
|
-
pry (0.
|
431
|
+
pry (0.14.0)
|
434
432
|
coderay (~> 1.1)
|
435
433
|
method_source (~> 1.0)
|
436
|
-
pry-byebug (3.
|
434
|
+
pry-byebug (3.8.0)
|
437
435
|
byebug (~> 11.0)
|
438
|
-
pry (~> 0.
|
436
|
+
pry (~> 0.10)
|
439
437
|
pry-doc (1.1.0)
|
440
438
|
pry (~> 0.11)
|
441
439
|
yard (~> 0.9.11)
|
@@ -444,20 +442,20 @@ GEM
|
|
444
442
|
pry-remote (0.1.8)
|
445
443
|
pry (~> 0.9)
|
446
444
|
slop (~> 3.0)
|
447
|
-
pry-stack_explorer (0.
|
448
|
-
binding_of_caller (~>
|
445
|
+
pry-stack_explorer (0.4.13)
|
446
|
+
binding_of_caller (~> 0.7)
|
449
447
|
pry (~> 0.13)
|
450
448
|
public_suffix (4.0.6)
|
451
|
-
pulp_2to3_migration_client (0.
|
449
|
+
pulp_2to3_migration_client (0.11.2)
|
452
450
|
faraday (>= 0.14.0)
|
453
451
|
json (~> 2.1, >= 2.1.0)
|
454
452
|
pulp_ansible_client (0.4.3)
|
455
453
|
faraday (>= 0.14.0)
|
456
454
|
json (~> 2.1, >= 2.1.0)
|
457
|
-
pulp_certguard_client (1.
|
455
|
+
pulp_certguard_client (1.3.0)
|
458
456
|
faraday (>= 0.14.0)
|
459
457
|
json (~> 2.1, >= 2.1.0)
|
460
|
-
pulp_container_client (2.1.
|
458
|
+
pulp_container_client (2.1.2)
|
461
459
|
faraday (>= 0.14.0)
|
462
460
|
json (~> 2.1, >= 2.1.0)
|
463
461
|
pulp_deb_client (2.7.0)
|
@@ -466,13 +464,13 @@ GEM
|
|
466
464
|
pulp_file_client (1.3.0)
|
467
465
|
faraday (>= 0.14.0)
|
468
466
|
json (~> 2.1, >= 2.1.0)
|
469
|
-
pulp_rpm_client (3.
|
467
|
+
pulp_rpm_client (3.10.0)
|
470
468
|
faraday (>= 0.14.0)
|
471
469
|
json (~> 2.1, >= 2.1.0)
|
472
|
-
pulpcore_client (3.7.
|
470
|
+
pulpcore_client (3.7.6)
|
473
471
|
faraday (>= 0.14.0)
|
474
472
|
json (~> 2.1, >= 2.1.0)
|
475
|
-
puma (4.3.
|
473
|
+
puma (4.3.8)
|
476
474
|
nio4r (~> 2.0)
|
477
475
|
puma-plugin-systemd (0.1.5)
|
478
476
|
json
|
@@ -492,20 +490,20 @@ GEM
|
|
492
490
|
rack
|
493
491
|
rack-test (1.1.0)
|
494
492
|
rack (>= 1.0, < 3)
|
495
|
-
rails (6.0.3.
|
496
|
-
actioncable (= 6.0.3.
|
497
|
-
actionmailbox (= 6.0.3.
|
498
|
-
actionmailer (= 6.0.3.
|
499
|
-
actionpack (= 6.0.3.
|
500
|
-
actiontext (= 6.0.3.
|
501
|
-
actionview (= 6.0.3.
|
502
|
-
activejob (= 6.0.3.
|
503
|
-
activemodel (= 6.0.3.
|
504
|
-
activerecord (= 6.0.3.
|
505
|
-
activestorage (= 6.0.3.
|
506
|
-
activesupport (= 6.0.3.
|
493
|
+
rails (6.0.3.6)
|
494
|
+
actioncable (= 6.0.3.6)
|
495
|
+
actionmailbox (= 6.0.3.6)
|
496
|
+
actionmailer (= 6.0.3.6)
|
497
|
+
actionpack (= 6.0.3.6)
|
498
|
+
actiontext (= 6.0.3.6)
|
499
|
+
actionview (= 6.0.3.6)
|
500
|
+
activejob (= 6.0.3.6)
|
501
|
+
activemodel (= 6.0.3.6)
|
502
|
+
activerecord (= 6.0.3.6)
|
503
|
+
activestorage (= 6.0.3.6)
|
504
|
+
activesupport (= 6.0.3.6)
|
507
505
|
bundler (>= 1.3.0)
|
508
|
-
railties (= 6.0.3.
|
506
|
+
railties (= 6.0.3.6)
|
509
507
|
sprockets-rails (>= 2.0.0)
|
510
508
|
rails-controller-testing (1.0.5)
|
511
509
|
actionpack (>= 5.0.1.rc1)
|
@@ -519,9 +517,9 @@ GEM
|
|
519
517
|
rails-i18n (6.0.0)
|
520
518
|
i18n (>= 0.7, < 2)
|
521
519
|
railties (>= 6.0.0, < 7)
|
522
|
-
railties (6.0.3.
|
523
|
-
actionpack (= 6.0.3.
|
524
|
-
activesupport (= 6.0.3.
|
520
|
+
railties (6.0.3.6)
|
521
|
+
actionpack (= 6.0.3.6)
|
522
|
+
activesupport (= 6.0.3.6)
|
525
523
|
method_source
|
526
524
|
rake (>= 0.8.7)
|
527
525
|
thor (>= 0.20.3, < 2.0)
|
@@ -541,7 +539,7 @@ GEM
|
|
541
539
|
rdoc (6.3.0)
|
542
540
|
record_tag_helper (1.0.1)
|
543
541
|
actionview (>= 5)
|
544
|
-
redhat_access (2.2.
|
542
|
+
redhat_access (2.2.20)
|
545
543
|
angular-rails-templates (>= 0.0.4)
|
546
544
|
foreman-tasks
|
547
545
|
katello
|
@@ -563,7 +561,7 @@ GEM
|
|
563
561
|
mime-types (>= 1.16, < 4.0)
|
564
562
|
netrc (~> 0.8)
|
565
563
|
retriable (3.1.2)
|
566
|
-
rexml (3.2.
|
564
|
+
rexml (3.2.5)
|
567
565
|
rfauxfactory (0.1.5)
|
568
566
|
roadie (4.0.0)
|
569
567
|
css_parser (~> 1.4)
|
@@ -628,12 +626,12 @@ GEM
|
|
628
626
|
tilt
|
629
627
|
scoped_search (4.1.9)
|
630
628
|
activerecord (>= 4.2.0)
|
631
|
-
sd_notify (0.1.
|
632
|
-
secure_headers (6.3.
|
629
|
+
sd_notify (0.1.1)
|
630
|
+
secure_headers (6.3.2)
|
633
631
|
selenium-webdriver (3.142.7)
|
634
632
|
childprocess (>= 0.5, < 4.0)
|
635
633
|
rubyzip (>= 1.2.2)
|
636
|
-
sequel (5.
|
634
|
+
sequel (5.45.0)
|
637
635
|
sexp_processor (4.15.2)
|
638
636
|
shoulda-context (1.2.2)
|
639
637
|
shoulda-matchers (4.3.0)
|
@@ -645,7 +643,7 @@ GEM
|
|
645
643
|
rack (~> 2.0)
|
646
644
|
rack-protection (>= 1.5.0)
|
647
645
|
redis (>= 3.3.5, < 4.2)
|
648
|
-
signet (0.
|
646
|
+
signet (0.15.0)
|
649
647
|
addressable (~> 2.3)
|
650
648
|
faraday (>= 0.17.3, < 2.0)
|
651
649
|
jwt (>= 1.5, < 3.0)
|
@@ -690,11 +688,11 @@ GEM
|
|
690
688
|
unf_ext
|
691
689
|
unf_ext (0.0.7.7)
|
692
690
|
unicode-display_width (1.6.1)
|
693
|
-
uniform_notifier (1.
|
691
|
+
uniform_notifier (1.14.2)
|
694
692
|
validates_lengths_from_database (0.8.0)
|
695
693
|
activerecord (>= 4)
|
696
694
|
vcr (3.0.3)
|
697
|
-
webmock (3.
|
695
|
+
webmock (3.12.2)
|
698
696
|
addressable (>= 2.3.6)
|
699
697
|
crack (>= 0.3.2)
|
700
698
|
hashdiff (>= 0.4.0, < 2.0.0)
|
data/config/database.yml.example
CHANGED
data/config/routes.rb
CHANGED
@@ -37,7 +37,7 @@ Rails.application.routes.draw do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
scope '/r/insights' do
|
40
|
-
match '/*path', :constraints => lambda { |req| !req.path.include?('view/api') }, to: 'machine_telemetries#forward_request', via: [:get, :post, :delete,:put, :patch]
|
40
|
+
match '(/*path)(/)', :constraints => lambda { |req| !req.path.include?('view/api') }, to: 'machine_telemetries#forward_request', via: [:get, :post, :delete,:put, :patch]
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -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
|
data/lib/foreman_rh_cloud.rb
CHANGED
@@ -98,6 +98,17 @@ 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
|
end
|
@@ -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,11 +7,21 @@ 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
|
13
|
-
|
14
|
-
|
22
|
+
rule_ids = relevant_rules
|
23
|
+
api_response = query_insights_resolutions(rule_ids) unless rule_ids.empty?
|
24
|
+
write_resolutions(api_response) if api_response
|
15
25
|
end
|
16
26
|
end
|
17
27
|
|
@@ -6,8 +6,17 @@ module InsightsCloud
|
|
6
6
|
include ::ForemanRhCloud::CloudAuth
|
7
7
|
|
8
8
|
def plan
|
9
|
-
|
10
|
-
|
9
|
+
unless cloud_auth_available?
|
10
|
+
logger.debug('Cloud authentication is not available, skipping rules sync')
|
11
|
+
return
|
12
|
+
end
|
13
|
+
|
14
|
+
# since the tasks are not connected, we need to force sequence execution here
|
15
|
+
# to make sure we don't run resolutions until we synced all our rules
|
16
|
+
sequence do
|
17
|
+
plan_self
|
18
|
+
plan_resolutions
|
19
|
+
end
|
11
20
|
end
|
12
21
|
|
13
22
|
def plan_resolutions
|
@@ -17,7 +17,6 @@ module InventorySync
|
|
17
17
|
@sub_ids.map do |sub_id|
|
18
18
|
host_id = host_id(sub_id)
|
19
19
|
if host_id
|
20
|
-
touched << host_id
|
21
20
|
{
|
22
21
|
host_id: host_id,
|
23
22
|
status: InventorySync::InventoryStatus::SYNC,
|
@@ -28,10 +27,6 @@ module InventorySync
|
|
28
27
|
end.compact
|
29
28
|
end
|
30
29
|
|
31
|
-
def touched
|
32
|
-
@touched ||= []
|
33
|
-
end
|
34
|
-
|
35
30
|
def host_id(sub_id)
|
36
31
|
hosts[sub_id]
|
37
32
|
end
|
@@ -5,15 +5,16 @@ 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
|
|
11
16
|
def setup_statuses
|
12
|
-
@subscribed_hosts_ids = Set.new(
|
13
|
-
ForemanInventoryUpload::Generators::Queries.for_slice(
|
14
|
-
Host.unscoped.where(organization: input[:organization_id])
|
15
|
-
).pluck(:id)
|
16
|
-
)
|
17
|
+
@subscribed_hosts_ids = Set.new(affected_host_ids)
|
17
18
|
|
18
19
|
InventorySync::InventoryStatus.transaction do
|
19
20
|
InventorySync::InventoryStatus.where(host_id: @subscribed_hosts_ids).delete_all
|
@@ -30,15 +31,18 @@ module InventorySync
|
|
30
31
|
def update_statuses_batch
|
31
32
|
results = yield
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
existing_hosts = results.status_hashes.select { |hash| @subscribed_hosts_ids.include?(hash[:host_id]) }
|
35
|
+
|
36
|
+
update_hosts_status(existing_hosts)
|
37
|
+
host_statuses[:sync] += existing_hosts.size
|
35
38
|
end
|
36
39
|
|
37
40
|
private
|
38
41
|
|
39
|
-
def update_hosts_status(status_hashes
|
42
|
+
def update_hosts_status(status_hashes)
|
40
43
|
InventorySync::InventoryStatus.create(status_hashes)
|
41
|
-
|
44
|
+
updated_ids = status_hashes.map { |hash| hash[:host_id] }
|
45
|
+
@subscribed_hosts_ids.subtract(updated_ids)
|
42
46
|
end
|
43
47
|
|
44
48
|
def add_missing_hosts_statuses(hosts_ids)
|
@@ -59,6 +63,12 @@ module InventorySync
|
|
59
63
|
disconnect: 0,
|
60
64
|
}
|
61
65
|
end
|
66
|
+
|
67
|
+
def affected_host_ids
|
68
|
+
ForemanInventoryUpload::Generators::Queries.for_slice(
|
69
|
+
Host.unscoped.where(organization: input[:organization_id])
|
70
|
+
).pluck(:id)
|
71
|
+
end
|
62
72
|
end
|
63
73
|
end
|
64
74
|
end
|
@@ -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
|
@@ -26,18 +31,14 @@ module InventorySync
|
|
26
31
|
private
|
27
32
|
|
28
33
|
def add_missing_insights_facets(uuids_hash)
|
29
|
-
|
30
|
-
missing_facets = uuids_hash.except(*existing_facets.map(&:first)).map do |host_id, uuid|
|
34
|
+
all_facets = uuids_hash.map do |host_id, uuid|
|
31
35
|
{
|
32
36
|
host_id: host_id,
|
33
37
|
uuid: uuid,
|
34
38
|
}
|
35
39
|
end
|
36
|
-
InsightsFacet.create(missing_facets)
|
37
40
|
|
38
|
-
|
39
|
-
InsightsFacet.where(host_id: host_id).update_all(uuid: uuids_hash[host_id])
|
40
|
-
end
|
41
|
+
InsightsFacet.upsert_all(all_facets, unique_by: :host_id) unless all_facets.empty?
|
41
42
|
end
|
42
43
|
|
43
44
|
def 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
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "foreman_rh_cloud",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.29",
|
4
4
|
"description": "Inventory Upload =============",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -26,7 +26,6 @@
|
|
26
26
|
},
|
27
27
|
"devDependencies": {
|
28
28
|
"@babel/core": "~7.7.0",
|
29
|
-
"@redhat-cloud-services/frontend-components": "^2.5.0",
|
30
29
|
"@theforeman/builder": "~4.14.0",
|
31
30
|
"@theforeman/stories": "~4.14.0",
|
32
31
|
"@theforeman/test": "~4.14.0",
|
@@ -43,6 +42,7 @@
|
|
43
42
|
},
|
44
43
|
"dependencies": {
|
45
44
|
"jed": "~1.1.1",
|
46
|
-
"react-intl": "~2.8.0"
|
45
|
+
"react-intl": "~2.8.0",
|
46
|
+
"@redhat-cloud-services/frontend-components": "^2.5.0"
|
47
47
|
}
|
48
48
|
}
|
@@ -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')
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'test_plugin_helper'
|
2
2
|
require 'foreman_tasks/test_helpers'
|
3
3
|
|
4
4
|
class InsightsResolutionsSyncTest < ActiveSupport::TestCase
|
@@ -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
|
@@ -74,4 +75,13 @@ class InsightsResolutionsSyncTest < ActiveSupport::TestCase
|
|
74
75
|
assert_equal 5, InsightsResolution.all.count
|
75
76
|
assert_equal 2, @rule.resolutions.count
|
76
77
|
end
|
78
|
+
|
79
|
+
test 'Skips pinging the cloud if no rule ids were found' do
|
80
|
+
InsightsCloud::Async::InsightsResolutionsSync.any_instance.expects(:query_insights_resolutions).never
|
81
|
+
InsightsRule.all.delete_all
|
82
|
+
|
83
|
+
ForemanTasks.sync_task(InsightsCloud::Async::InsightsResolutionsSync)
|
84
|
+
|
85
|
+
assert_equal 0, InsightsResolution.all.count
|
86
|
+
end
|
77
87
|
end
|
@@ -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
|
@@ -37,6 +37,18 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
37
37
|
@host2.subscription_facet.pools << pool
|
38
38
|
@host2_inventory_id = '4536bf5c-ff03-4154-a8c9-32ff4b40e40c'
|
39
39
|
|
40
|
+
# this host would pass our plugin queries, so it could be uploaded to the cloud.
|
41
|
+
@host3 = FactoryBot.create(
|
42
|
+
:host,
|
43
|
+
:with_subscription,
|
44
|
+
:with_content,
|
45
|
+
content_view: cv.first,
|
46
|
+
lifecycle_environment: env,
|
47
|
+
organization: env.organization
|
48
|
+
)
|
49
|
+
|
50
|
+
@host3.subscription_facet.pools << pool
|
51
|
+
|
40
52
|
ForemanInventoryUpload::Generators::Queries.instance_variable_set(:@fact_names, nil)
|
41
53
|
|
42
54
|
inventory_json = <<-INVENTORY_JSON
|
@@ -151,7 +163,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
151
163
|
{
|
152
164
|
"insights_id": "b533848e-465f-4f1a-9b2b-b71cb2d5239d",
|
153
165
|
"rhel_machine_id": null,
|
154
|
-
"subscription_manager_id": "
|
166
|
+
"subscription_manager_id": "#{@host3.subscription_facet.uuid}",
|
155
167
|
"satellite_id": "d29bde40-348e-437c-8acf-8fa98320fc1b",
|
156
168
|
"bios_uuid": "3cd5d972-cfb5-451a-8314-fd2f56629d7c",
|
157
169
|
"ip_addresses": [
|
@@ -159,7 +171,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
159
171
|
"fd6e:2298:736e::857",
|
160
172
|
"fd6e:2298:736e:0:2c66:6101:9cc6:2b23"
|
161
173
|
],
|
162
|
-
"fqdn": "
|
174
|
+
"fqdn": "#{@host3.fqdn}",
|
163
175
|
"mac_addresses": [
|
164
176
|
"6e:66:a6:fe:fc:07",
|
165
177
|
"00:00:00:00:00:00"
|
@@ -242,6 +254,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
242
254
|
end
|
243
255
|
|
244
256
|
test 'Host status should be SYNC for inventory hosts' do
|
257
|
+
FactoryBot.create(:setting, name: 'rh_cloud_token', value: 'TEST TOKEN')
|
245
258
|
InventorySync::Async::InventoryFullSync.any_instance.expects(:query_inventory).returns(@inventory)
|
246
259
|
|
247
260
|
ForemanTasks.sync_task(InventorySync::Async::InventoryFullSync, @host2.organization)
|
@@ -253,6 +266,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
253
266
|
end
|
254
267
|
|
255
268
|
test 'Host status should be DISCONNECT for hosts that are not returned from cloud' do
|
269
|
+
FactoryBot.create(:setting, name: 'rh_cloud_token', value: 'TEST TOKEN')
|
256
270
|
InventorySync::Async::InventoryFullSync.any_instance.expects(:query_inventory).returns(@inventory)
|
257
271
|
FactoryBot.create(:fact_value, fact_name: fact_names['virt::uuid'], value: '1234', host: @host2)
|
258
272
|
|
@@ -261,4 +275,26 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
261
275
|
|
262
276
|
assert_equal InventorySync::InventoryStatus::DISCONNECT, InventorySync::InventoryStatus.where(host_id: @host1.id).first.status
|
263
277
|
end
|
278
|
+
|
279
|
+
test 'Task should be aborted if token is not present' do
|
280
|
+
FactoryBot.create(:setting, name: 'rh_cloud_token', value: '')
|
281
|
+
|
282
|
+
InventorySync::Async::InventoryFullSync.any_instance.expects(:plan_self).never
|
283
|
+
|
284
|
+
ForemanTasks.sync_task(InventorySync::Async::InventoryFullSync, @host1.organization)
|
285
|
+
end
|
286
|
+
|
287
|
+
test 'Should skip hosts that are not returned in query' do
|
288
|
+
assert_nil InventorySync::InventoryStatus.where(host_id: @host3.id).first
|
289
|
+
|
290
|
+
FactoryBot.create(:setting, name: 'rh_cloud_token', value: 'TEST TOKEN')
|
291
|
+
InventorySync::Async::InventoryFullSync.any_instance.expects(:query_inventory).returns(@inventory)
|
292
|
+
InventorySync::Async::InventoryFullSync.any_instance.expects(:affected_host_ids).returns([@host1.id, @host2.id])
|
293
|
+
FactoryBot.create(:fact_value, fact_name: fact_names['virt::uuid'], value: '1234', host: @host2)
|
294
|
+
|
295
|
+
ForemanTasks.sync_task(InventorySync::Async::InventoryFullSync, @host1.organization)
|
296
|
+
@host2.reload
|
297
|
+
|
298
|
+
assert_nil InventorySync::InventoryStatus.where(host_id: @host3.id).first
|
299
|
+
end
|
264
300
|
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)
|
@@ -264,4 +265,19 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
264
265
|
|
265
266
|
assert_equal @host2_inventory_id, @host2.insights.uuid
|
266
267
|
end
|
268
|
+
|
269
|
+
test 'Inventory should sync empty facets list' do
|
270
|
+
empty_inventory = @inventory.deep_clone
|
271
|
+
empty_inventory['results'] = []
|
272
|
+
InventorySync::Async::InventoryHostsSync.any_instance.expects(:query_inventory).returns(empty_inventory)
|
273
|
+
InventorySync::Async::InventoryHostsSync.any_instance.expects(:plan_self_host_sync)
|
274
|
+
|
275
|
+
assert_nil @host2.insights
|
276
|
+
|
277
|
+
ForemanTasks.sync_task(InventorySync::Async::InventoryHostsSync)
|
278
|
+
|
279
|
+
@host2.reload
|
280
|
+
|
281
|
+
assert_nil @host2.insights
|
282
|
+
end
|
267
283
|
end
|
@@ -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)
|
@@ -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
|
@@ -48,6 +48,7 @@ class CloudRequestForwarderTest < ActiveSupport::TestCase
|
|
48
48
|
"/redhat_access/r/insights/platform/inventory/v1/hosts" => "https://cert.cloud.redhat.com/api/inventory/v1/hosts",
|
49
49
|
"/redhat_access/r/insights/platform/ingress/v1/upload" => "https://cert.cloud.redhat.com/api/ingress/v1/upload",
|
50
50
|
"/redhat_access/r/insights/uploads/67200803-132b-474b-a6f9-37be74185df4" => "https://cert-api.access.redhat.com/r/insights/uploads/67200803-132b-474b-a6f9-37be74185df4",
|
51
|
+
"/redhat_access/r/insights/" => "https://cert.cloud.redhat.com/api/apicast-tests/ping",
|
51
52
|
}
|
52
53
|
|
53
54
|
paths.each do |key, value|
|
@@ -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.29
|
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-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: katello
|
@@ -267,6 +267,7 @@ files:
|
|
267
267
|
- test/test_plugin_helper.rb
|
268
268
|
- test/unit/archived_report_generator_test.rb
|
269
269
|
- test/unit/fact_helpers_test.rb
|
270
|
+
- test/unit/foreman_rh_cloud_self_host_test.rb
|
270
271
|
- test/unit/insights_facet_test.rb
|
271
272
|
- test/unit/metadata_generator_test.rb
|
272
273
|
- test/unit/rh_cloud_http_proxy_test.rb
|
@@ -671,7 +672,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
671
672
|
- !ruby/object:Gem::Version
|
672
673
|
version: '0'
|
673
674
|
requirements: []
|
674
|
-
rubygems_version: 3.2.
|
675
|
+
rubygems_version: 3.2.22
|
675
676
|
signing_key:
|
676
677
|
specification_version: 4
|
677
678
|
summary: Summary of ForemanRhCloud.
|
@@ -698,6 +699,7 @@ test_files:
|
|
698
699
|
- test/test_plugin_helper.rb
|
699
700
|
- test/unit/archived_report_generator_test.rb
|
700
701
|
- test/unit/fact_helpers_test.rb
|
702
|
+
- test/unit/foreman_rh_cloud_self_host_test.rb
|
701
703
|
- test/unit/insights_facet_test.rb
|
702
704
|
- test/unit/metadata_generator_test.rb
|
703
705
|
- test/unit/rh_cloud_http_proxy_test.rb
|