foreman_rh_cloud 4.0.25.1 → 4.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v2/rh_cloud/inventory_controller.rb +4 -1
  3. data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +8 -0
  4. data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +14 -2
  5. data/config/Gemfile.lock.gh_test +169 -152
  6. data/config/database.yml.example +2 -2
  7. data/config/package-lock.json +41822 -0
  8. data/config/routes.rb +1 -1
  9. data/lib/foreman_inventory_upload/generators/queries.rb +1 -0
  10. data/lib/foreman_inventory_upload/generators/tags.rb +9 -3
  11. data/lib/foreman_rh_cloud/engine.rb +2 -0
  12. data/lib/foreman_rh_cloud/version.rb +1 -1
  13. data/lib/foreman_rh_cloud.rb +12 -1
  14. data/lib/insights_cloud/async/insights_client_status_aging.rb +4 -0
  15. data/lib/insights_cloud/async/insights_full_sync.rb +4 -0
  16. data/lib/insights_cloud/async/insights_generate_notifications.rb +4 -0
  17. data/lib/insights_cloud/async/insights_resolutions_sync.rb +7 -2
  18. data/lib/insights_cloud/async/insights_rules_sync.rb +10 -2
  19. data/lib/inventory_sync/async/host_result.rb +0 -5
  20. data/lib/inventory_sync/async/inventory_full_sync.rb +18 -9
  21. data/lib/inventory_sync/async/inventory_hosts_sync.rb +6 -6
  22. data/lib/inventory_sync/async/inventory_scheduled_sync.rb +4 -0
  23. data/lib/inventory_sync/async/inventory_self_host_sync.rb +4 -0
  24. data/lib/inventory_sync/async/query_inventory_job.rb +4 -0
  25. data/package.json +2 -2
  26. data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +16 -39
  27. data/test/factories/inventory_upload_factories.rb +14 -0
  28. data/test/jobs/insights_resolutions_sync_test.rb +10 -1
  29. data/test/jobs/inventory_full_sync_test.rb +28 -2
  30. data/test/jobs/inventory_hosts_sync_test.rb +15 -0
  31. data/test/unit/foreman_rh_cloud_self_host_test.rb +28 -0
  32. data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +26 -0
  33. data/test/unit/slice_generator_test.rb +36 -4
  34. data/test/unit/tags_generator_test.rb +31 -16
  35. data/webpack/InsightsCloudSync/Components/InsightsHeader/index.js +0 -2
  36. data/webpack/InsightsCloudSync/Components/InsightsSettings/insightsSettings.scss +1 -0
  37. data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/InsightsHeader.test.js.snap +0 -1
  38. data/webpack/InsightsCloudSync/InsightsCloudSync.js +2 -0
  39. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +1 -0
  40. data/webpack/common/Switcher/HelpLabel.js +1 -1
  41. data/webpack/common/Switcher/__tests__/__snapshots__/HelpLabel.test.js.snap +1 -1
  42. metadata +6 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf14938ab96483d5b90b699ad095664ccda999db645f3d0e4b868b8e6066f268
4
- data.tar.gz: 90062d9c4bf632a9d856d17e16639d6920e6a9b9d0bbad1334202041122fd19f
3
+ metadata.gz: d30780fe6dc3c0b25146d8c8b5549179516218ebbf8cfcaa02aa704ee24d9f62
4
+ data.tar.gz: 3a0c1d673a773487565e26493f34fe88dd91f5b7a27f15fa6b532b8ef7a2eb58
5
5
  SHA512:
6
- metadata.gz: 46eb0bfffd3853da3d4d0254756469e07f6f690166e96732bcb77a027d9cf3370cbe3d3f72e59a801cf85338fd2b2a042e45dd4a74907df3b66969a1006cb8c8
7
- data.tar.gz: 1464b0f05e778e6b0a002114175b0c0a3f95b51c78af5fecd00395c42d6cd4196dffb0362724bcc62989403500e9994afe9012552e6e0ad00f0c0fe8f2e2fc5e
6
+ metadata.gz: 80e8f58e6cb5572796af39e096163f151fa1636b92064ab239f16fc439dee10e25c6cf7be17f046670424dcdf2c799fcc497be964585e96ef51070154fe6c6a6
7
+ data.tar.gz: 3233f24be9b101917d12367e6649edf96e52e705db61de109f04a82ac13369018dbdca536bd2b400ed56a23971aaeceb04905b18f80220f8fe702181403c941b
@@ -7,6 +7,7 @@ module Api
7
7
  include InventoryUpload::TaskActions
8
8
 
9
9
  api :GET, "/organizations/:organization_id/rh_cloud/report", N_("Download latest report")
10
+ param :organization_id, Integer, required: true, desc: N_("Set the current organization context for the request")
10
11
  def download_file
11
12
  filename, file = report_file(params[:organization_id])
12
13
 
@@ -16,6 +17,7 @@ module Api
16
17
  end
17
18
 
18
19
  api :POST, "/organizations/:organization_id/rh_cloud/report", N_("Start report generation")
20
+ param :organization_id, Integer, required: true, desc: N_("Set the current organization context for the request")
19
21
  def generate_report
20
22
  organization_id = params[:organization_id]
21
23
 
@@ -27,6 +29,7 @@ module Api
27
29
  end
28
30
 
29
31
  api :POST, "/organizations/:organization_id/rh_cloud/inventory_sync", N_("Start inventory synchronization")
32
+ param :organization_id, Integer, required: true, desc: N_("Set the current organization context for the request")
30
33
  def sync_inventory_status
31
34
  selected_org = Organization.find(params[:organization_id])
32
35
 
@@ -39,7 +42,7 @@ module Api
39
42
  render json: { message: error.message }, status: :bad_request
40
43
  end
41
44
 
42
- api :POST, "rh_cloud/enable_connector", N_("Enable cloud connector")
45
+ api :POST, "/rh_cloud/enable_connector", N_("Enable cloud connector")
43
46
  def enable_cloud_connector
44
47
  cloud_connector = ForemanRhCloud::CloudConnector.new
45
48
  render json: cloud_connector.install.to_json
@@ -25,6 +25,14 @@ module InsightsCloud::Api
25
25
  }, status: :bad_gateway
26
26
  end
27
27
 
28
+ if @cloud_response.code >= 300
29
+ return render json: {
30
+ :message => 'Cloud request failed',
31
+ :headers => {},
32
+ :response => @cloud_response,
33
+ }, status: @cloud_response.code
34
+ end
35
+
28
36
  if @cloud_response.headers[:content_disposition]
29
37
  return send_data @cloud_response, disposition: @cloud_response.headers[:content_disposition], type: @cloud_response.headers[:content_type]
30
38
  end
@@ -17,6 +17,8 @@ module ForemanRhCloud
17
17
  logger.debug("Sending request to: #{request_opts[:url]}")
18
18
 
19
19
  execute_cloud_request(request_opts)
20
+ rescue RestClient::Exception => error_response
21
+ error_response.response
20
22
  end
21
23
 
22
24
  def prepare_request_opts(original_request, forward_payload, forward_params, certs)
@@ -62,6 +64,12 @@ module ForemanRhCloud
62
64
  ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
63
65
  ssl_client_key: OpenSSL::PKey::RSA.new(certs[:key]),
64
66
  }
67
+ when connection_test_request?
68
+ {
69
+ url: ForemanRhCloud.cert_base_url + '/api/apicast-tests/ping',
70
+ ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
71
+ ssl_client_key: OpenSSL::PKey::RSA.new(certs[:key]),
72
+ }
65
73
  else # Legacy insights API
66
74
  {
67
75
  url: ForemanRhCloud.legacy_insights_url + request_path.sub('/redhat_access/r/insights', '/r/insights'),
@@ -76,6 +84,10 @@ module ForemanRhCloud
76
84
  ->(request_path) { request_path.include? '/platform' }
77
85
  end
78
86
 
87
+ def connection_test_request?
88
+ ->(request_path) { request_path =~ /redhat_access\/r\/insights\/?$/ }
89
+ end
90
+
79
91
  def prepare_forward_cloud_url(base_url, request_path)
80
92
  cloud_path = request_path.sub('/redhat_access/r/insights/platform/', '')
81
93
  .sub('/redhat_access/r/insights/', '')
@@ -84,11 +96,11 @@ module ForemanRhCloud
84
96
  end
85
97
 
86
98
  def core_app_name
87
- 'Foreman'
99
+ BranchInfo.new.core_app_name
88
100
  end
89
101
 
90
102
  def core_app_version
91
- Foreman::Version.new
103
+ BranchInfo.new.core_app_version
92
104
  end
93
105
 
94
106
  def http_user_agent(original_request)