foreman_rh_cloud 3.0.24 → 3.0.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +5 -3
  3. data/app/models/insights_client_report_status.rb +8 -23
  4. data/app/services/foreman_rh_cloud/cloud_auth.rb +4 -0
  5. data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +10 -0
  6. data/app/services/foreman_rh_cloud/insights_status_cleaner.rb +17 -0
  7. data/app/services/foreman_rh_cloud/remediations_retriever.rb +5 -0
  8. data/config/Gemfile.lock.gh_test +93 -95
  9. data/config/database.yml.example +2 -2
  10. data/config/routes.rb +1 -1
  11. data/db/migrate/20210720000001_remove_old_insights_statuses.foreman_rh_cloud.rb +6 -0
  12. data/lib/foreman_inventory_upload/generators/tags.rb +3 -1
  13. data/lib/foreman_rh_cloud/engine.rb +0 -2
  14. data/lib/foreman_rh_cloud/version.rb +1 -1
  15. data/lib/foreman_rh_cloud.rb +12 -1
  16. data/lib/insights_cloud/async/insights_client_status_aging.rb +9 -3
  17. data/lib/insights_cloud/async/insights_full_sync.rb +5 -0
  18. data/lib/insights_cloud/async/insights_resolutions_sync.rb +12 -2
  19. data/lib/insights_cloud/async/insights_rules_sync.rb +11 -2
  20. data/lib/inventory_sync/async/inventory_full_sync.rb +5 -0
  21. data/lib/inventory_sync/async/inventory_hosts_sync.rb +5 -0
  22. data/lib/inventory_sync/async/inventory_self_host_sync.rb +9 -0
  23. data/lib/tasks/insights.rake +15 -0
  24. data/package.json +3 -3
  25. data/test/jobs/insights_client_status_aging_test.rb +7 -7
  26. data/test/jobs/insights_full_sync_test.rb +1 -0
  27. data/test/jobs/insights_resolutions_sync_test.rb +11 -1
  28. data/test/jobs/insights_rules_sync_test.rb +1 -0
  29. data/test/jobs/inventory_full_sync_test.rb +10 -0
  30. data/test/jobs/inventory_hosts_sync_test.rb +1 -0
  31. data/test/jobs/inventory_self_host_sync_test.rb +1 -0
  32. data/test/models/insights_client_report_status_test.rb +70 -72
  33. data/test/unit/foreman_rh_cloud_self_host_test.rb +28 -0
  34. data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +1 -0
  35. data/test/unit/services/foreman_rh_cloud/insights_status_cleaner_test.rb +31 -0
  36. data/test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb +1 -0
  37. data/test/unit/tags_generator_test.rb +41 -0
  38. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.scss +14 -0
  39. metadata +9 -4
  40. data/app/subscribers/foreman_rh_cloud/insights_subscriber.rb +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a770469a80b05e6f28d320292ff14ec760b24a5b2a564f5bee625adcb1c3589d
4
- data.tar.gz: 0fb9dc4b88422fc28cbf68002e565e49c2deec51eb1edc7e6ecfbfe397f0335b
3
+ metadata.gz: 56cd1d6cfd15e872954f934c6d4da54a0fa7fac6d376dfce68c7df38bbbab7fe
4
+ data.tar.gz: be90bca3b783d987b548a3aa9b2a792a6528fbf7131cd9e130af72c9b4e6c102
5
5
  SHA512:
6
- metadata.gz: a79f98d8fe9e2883bde293b96eb138c68d01fa2e8fffdb2843b8d5a1fefa09d65f76b7ff18a09961c914ab81d0b65e8232c51066ab1729bfcf4a6fd127e0948d
7
- data.tar.gz: e6e8e67014a16817cd4a1b86611541b133b86bc1ef7f588ecc0293f2b81e6682d43a4118a5bec03a3fe8de4c7e4a39dafc7c9c0d223cdc217e01ee97fa400d42
6
+ metadata.gz: 23a052bbb5346617f391a7a3125c5400ad8c2601d6d79f5101e78e17dcaadbdf0b3a071b2845f707f16b94642ce2b4542e585d6e09afade4d06eedc5dbd46c09
7
+ data.tar.gz: 77c1aca4f971996b13067142c932e49dd6fd5df1e5efd6be09dd0e25e086f7859bba47157b826ec6dc2d8e8837dd2bb6e4c36f97e5045f404a2527484c1ed369
@@ -76,9 +76,11 @@ module InsightsCloud::Api
76
76
  return unless request.path == '/redhat_access/r/insights/platform/ingress/v1/upload' ||
77
77
  request.path.include?('/redhat_access/r/insights/uploads/')
78
78
 
79
- data = @cloud_response.code.to_s.start_with?('2')
80
- host_status = @host.get_status(InsightsClientReportStatus)
81
- host_status.update(reported_at: Time.now.utc, status: host_status.to_status(data: data))
79
+ return unless @cloud_response.code.to_s.start_with?('2')
80
+
81
+ # create insights status if it wasn't there in the first place and refresh its reporting date
82
+ @host.get_status(InsightsClientReportStatus).refresh!
83
+ @host.refresh_global_status!
82
84
  end
83
85
  end
84
86
  end
@@ -1,14 +1,11 @@
1
1
  class InsightsClientReportStatus < HostStatus::Status
2
2
  REPORT_INTERVAL = 48.hours
3
3
 
4
- REPORTING = 0 # host_registration_insights = true & getting data
5
- NO_REPORT = 1 # host_registration_insights = true & not getting data
6
- NOT_MANAGED = 2 # host_registration_insights = false
7
- NOT_MANAGED_WITH_DATA = 3 # host_registration_insights = false & getting data
4
+ REPORTING = 0
5
+ NO_REPORT = 1
8
6
 
9
7
  scope :stale, -> { where.not(reported_at: (Time.now - REPORT_INTERVAL)..Time.now) }
10
8
  scope :reporting, -> { where(status: REPORTING) }
11
- scope :not_managed_with_data, -> { where(status: NOT_MANAGED_WITH_DATA) }
12
9
 
13
10
  def self.status_name
14
11
  N_('Insights')
@@ -20,10 +17,6 @@ class InsightsClientReportStatus < HostStatus::Status
20
17
  N_('Reporting')
21
18
  when NO_REPORT
22
19
  N_('Not reporting')
23
- when NOT_MANAGED
24
- N_('Not reporting (not set by registration)')
25
- when NOT_MANAGED_WITH_DATA
26
- N_('Reporting (not set by registration)')
27
20
  end
28
21
  end
29
22
 
@@ -33,20 +26,16 @@ class InsightsClientReportStatus < HostStatus::Status
33
26
  ::HostStatus::Global::OK
34
27
  when NO_REPORT
35
28
  ::HostStatus::Global::ERROR
36
- when NOT_MANAGED
37
- ::HostStatus::Global::OK
38
- when NOT_MANAGED_WITH_DATA
39
- ::HostStatus::Global::WARN
40
29
  end
41
30
  end
42
31
 
43
- def to_status(data: false)
44
- if insights_param
45
- return REPORTING if data
46
- return in_interval? ? REPORTING : NO_REPORT
47
- end
32
+ def to_status
33
+ in_interval? ? REPORTING : NO_REPORT
34
+ end
48
35
 
49
- data ? NOT_MANAGED_WITH_DATA : NOT_MANAGED
36
+ # prevent creation of the status on global refresh, but show it if the record already exists
37
+ def relevant?(_options = {})
38
+ persisted?
50
39
  end
51
40
 
52
41
  private
@@ -55,8 +44,4 @@ class InsightsClientReportStatus < HostStatus::Status
55
44
  return false unless reported_at
56
45
  (Time.now.utc - reported_at).to_i < REPORT_INTERVAL.to_i
57
46
  end
58
-
59
- def insights_param
60
- host.host_params_hash.dig('host_registration_insights', :value)
61
- end
62
47
  end
@@ -4,6 +4,10 @@ module ForemanRhCloud
4
4
 
5
5
  include CloudRequest
6
6
 
7
+ def cloud_auth_available?
8
+ Setting[:rh_cloud_token].present?
9
+ end
10
+
7
11
  def rh_credentials
8
12
  @rh_credentials ||= query_refresh_token
9
13
  end
@@ -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/', '')
@@ -0,0 +1,17 @@
1
+ module ForemanRhCloud
2
+ class InsightsStatusCleaner
3
+ def clean(host_search)
4
+ host_ids = Host.search_for(host_search).pluck(:id)
5
+
6
+ # delete all insights status records for the hosts
7
+ deleted_count = InsightsClientReportStatus.where(host_id: host_ids).delete_all
8
+
9
+ # refresh global status
10
+ Host.where(id: host_ids).preload(:host_statuses).find_in_batches do |hosts|
11
+ hosts.each { |host| host.refresh_global_status! }
12
+ end
13
+
14
+ deleted_count
15
+ end
16
+ end
17
+ end
@@ -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}")
@@ -9,27 +9,27 @@ PATH
9
9
  PATH
10
10
  remote: ../katello
11
11
  specs:
12
- katello (3.18.0.rc1)
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.3.0, < 0.6.0, != 0.4.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.6.2, < 3.8.0)
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.4)
45
- actionpack (= 6.0.3.4)
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.4)
49
- actionpack (= 6.0.3.4)
50
- activejob (= 6.0.3.4)
51
- activerecord (= 6.0.3.4)
52
- activestorage (= 6.0.3.4)
53
- activesupport (= 6.0.3.4)
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.4)
56
- actionpack (= 6.0.3.4)
57
- actionview (= 6.0.3.4)
58
- activejob (= 6.0.3.4)
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.4)
62
- actionview (= 6.0.3.4)
63
- activesupport (= 6.0.3.4)
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.4)
69
- actionpack (= 6.0.3.4)
70
- activerecord (= 6.0.3.4)
71
- activestorage (= 6.0.3.4)
72
- activesupport (= 6.0.3.4)
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.4)
75
- activesupport (= 6.0.3.4)
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.4)
81
- activesupport (= 6.0.3.4)
80
+ activejob (6.0.3.6)
81
+ activesupport (= 6.0.3.6)
82
82
  globalid (>= 0.3.6)
83
- activemodel (6.0.3.4)
84
- activesupport (= 6.0.3.4)
85
- activerecord (6.0.3.4)
86
- activemodel (= 6.0.3.4)
87
- activesupport (= 6.0.3.4)
88
- activerecord-import (1.0.7)
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.4)
99
- actionpack (= 6.0.3.4)
100
- activejob (= 6.0.3.4)
101
- activerecord (= 6.0.3.4)
102
- marcel (~> 0.3.1)
103
- activesupport (6.0.3.4)
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.2.2)
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 (1.0.0)
137
+ binding_of_caller (0.8.0)
138
138
  debug_inspector (>= 0.0.1)
139
- bootsnap (1.7.1)
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.3)
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.0.0)
183
+ debug_inspector (1.1.0)
184
184
  declarative (0.0.20)
185
185
  declarative-option (0.1.0)
186
- deep_cloneable (3.0.0)
186
+ deep_cloneable (3.1.0)
187
187
  activerecord (>= 3.1.0, < 7)
188
- deface (1.6.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.4.7)
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.50)
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.1.1)
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.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.3.3)
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.2020.1104)
380
- mimemagic (0.3.5)
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.5)
408
- nokogiri (1.11.1)
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.4.0)
416
+ parallel_tests (3.6.0)
419
417
  parallel
420
418
  parse-cron (0.1.4)
421
- parser (3.0.0.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.13.1)
431
+ pry (0.14.0)
434
432
  coderay (~> 1.1)
435
433
  method_source (~> 1.0)
436
- pry-byebug (3.9.0)
434
+ pry-byebug (3.8.0)
437
435
  byebug (~> 11.0)
438
- pry (~> 0.13.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.6.0)
448
- binding_of_caller (~> 1.0)
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.5.1)
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.1.0)
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.0)
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.7.0)
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.3)
470
+ pulpcore_client (3.7.6)
473
471
  faraday (>= 0.14.0)
474
472
  json (~> 2.1, >= 2.1.0)
475
- puma (4.3.7)
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.4)
496
- actioncable (= 6.0.3.4)
497
- actionmailbox (= 6.0.3.4)
498
- actionmailer (= 6.0.3.4)
499
- actionpack (= 6.0.3.4)
500
- actiontext (= 6.0.3.4)
501
- actionview (= 6.0.3.4)
502
- activejob (= 6.0.3.4)
503
- activemodel (= 6.0.3.4)
504
- activerecord (= 6.0.3.4)
505
- activestorage (= 6.0.3.4)
506
- activesupport (= 6.0.3.4)
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.4)
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.4)
523
- actionpack (= 6.0.3.4)
524
- activesupport (= 6.0.3.4)
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.18)
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.4)
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.0)
632
- secure_headers (6.3.1)
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.41.0)
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.14.1)
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.13.2)
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.11.2)
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)
@@ -2,9 +2,9 @@
2
2
 
3
3
  default: &default
4
4
  adapter: postgresql
5
- username: foreman
5
+ username: <%= ENV['PGUSER'] || 'foreman' %>
6
6
  password: foreman
7
- host: localhost
7
+ host: <%= ENV['PGHOST'] || 'localhost' %>
8
8
 
9
9
  test:
10
10
  <<: *default
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
 
@@ -0,0 +1,6 @@
1
+ class RemoveOldInsightsStatuses < ActiveRecord::Migration[5.2]
2
+ def up
3
+ InsightsClientReportStatus.where(status: 2).update_all(status: InsightsClientReportStatus::NO_REPORT)
4
+ InsightsClientReportStatus.where(status: 3).update_all(status: InsightsClientReportStatus::REPORTING)
5
+ end
6
+ end
@@ -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 || []).map { |item| [item.name, item.value] }
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
@@ -93,8 +93,6 @@ module ForemanRhCloud
93
93
  register_custom_status InventorySync::InventoryStatus
94
94
  register_custom_status InsightsClientReportStatus
95
95
 
96
- subscribe 'host_created.event.foreman', ForemanRhCloud::InsightsSubscriber
97
-
98
96
  describe_host do
99
97
  overview_buttons_provider :insights_host_overview_buttons
100
98
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '3.0.24'.freeze
2
+ VERSION = '3.0.28'.freeze
3
3
  end
@@ -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 ||= ::Host.unscoped.friendly.find(ENV['SATELLITE_RH_CLOUD_FOREMAN_HOST'] || ::SmartProxy.default_capsule.name)
101
+ @foreman_host ||= begin
102
+ fullname = foreman_host_name
103
+ ::Host.unscoped.friendly.find(fullname)
104
+ rescue ActiveRecord::RecordNotFound
105
+ # fullname didn't work. Let's try shortname
106
+ shortname = /(?<shortname>[^\.]*)\.?.*/.match(fullname)[:shortname]
107
+ ::Host.unscoped.friendly.find(shortname)
108
+ end
109
+ end
110
+
111
+ def self.foreman_host_name
112
+ ENV['SATELLITE_RH_CLOUD_FOREMAN_HOST'] || ::SmartProxy.default_capsule.name
102
113
  end
103
114
  end
@@ -4,9 +4,15 @@ module InsightsCloud
4
4
  include ::Actions::RecurringAction
5
5
 
6
6
  def run
7
- # update all stale records to "not reporting" counterpart
8
- InsightsClientReportStatus.stale.reporting.update_all(status: InsightsClientReportStatus::NO_REPORT)
9
- InsightsClientReportStatus.stale.not_managed_with_data.update_all(status: InsightsClientReportStatus::NOT_MANAGED)
7
+ host_ids = InsightsClientReportStatus.stale.reporting.pluck(:host_id)
8
+
9
+ # update all stale records
10
+ InsightsClientReportStatus.where(host_id: host_ids).update_all(status: InsightsClientReportStatus::NO_REPORT)
11
+
12
+ # refresh global status
13
+ Host.where(id: host_ids).preload(:host_statuses).find_in_batches do |hosts|
14
+ hosts.each { |host| host.refresh_global_status! }
15
+ end
10
16
  end
11
17
 
12
18
  def logger