foreman_rh_cloud 12.2.10 → 13.0.0

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/foreman_rh_cloud/locale/fr/foreman_rh_cloud.js +17 -50
  3. data/app/assets/javascripts/foreman_rh_cloud/locale/ja/foreman_rh_cloud.js +17 -50
  4. data/app/assets/javascripts/foreman_rh_cloud/locale/ka/foreman_rh_cloud.js +16 -49
  5. data/app/assets/javascripts/foreman_rh_cloud/locale/ko/foreman_rh_cloud.js +17 -50
  6. data/app/assets/javascripts/foreman_rh_cloud/locale/zh_CN/foreman_rh_cloud.js +17 -50
  7. data/app/controllers/concerns/insights_cloud/package_profile_upload_extensions.rb +3 -2
  8. data/app/models/insights_hit.rb +1 -1
  9. data/app/services/foreman_rh_cloud/cert_auth.rb +3 -13
  10. data/app/services/foreman_rh_cloud/gateway_request.rb +26 -0
  11. data/app/services/foreman_rh_cloud/insights_api_forwarder.rb +1 -3
  12. data/app/services/foreman_rh_cloud/tags_auth.rb +1 -2
  13. data/lib/foreman_inventory_upload/async/generate_report_job.rb +8 -13
  14. data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +4 -4
  15. data/lib/foreman_inventory_upload/async/upload_report_job.rb +5 -6
  16. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +2 -2
  17. data/lib/foreman_inventory_upload/generators/slice.rb +3 -3
  18. data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +1 -7
  19. data/lib/foreman_rh_cloud/engine.rb +15 -33
  20. data/lib/foreman_rh_cloud/plugin.rb +9 -9
  21. data/lib/foreman_rh_cloud/version.rb +1 -1
  22. data/lib/tasks/rh_cloud_inventory.rake +31 -14
  23. data/locale/foreman_rh_cloud.pot +152 -219
  24. data/locale/fr/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  25. data/locale/fr/foreman_rh_cloud.po +18 -50
  26. data/locale/ja/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  27. data/locale/ja/foreman_rh_cloud.po +18 -50
  28. data/locale/ka/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  29. data/locale/ka/foreman_rh_cloud.po +17 -49
  30. data/locale/ko/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  31. data/locale/ko/foreman_rh_cloud.po +18 -50
  32. data/locale/zh_CN/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  33. data/locale/zh_CN/foreman_rh_cloud.po +18 -50
  34. data/package.json +1 -1
  35. data/test/jobs/upload_report_job_test.rb +1 -2
  36. data/test/unit/fact_helpers_test.rb +0 -47
  37. data/test/unit/slice_generator_test.rb +0 -57
  38. data/webpack/ForemanRhCloudFills.js +2 -6
  39. data/webpack/ForemanRhCloudHelpers.js +0 -4
  40. data/webpack/InsightsHostDetailsTab/InsightsTab.scss +0 -4
  41. data/webpack/InsightsHostDetailsTab/InsightsTotalRiskChart.js +23 -59
  42. data/webpack/InsightsHostDetailsTab/NewHostDetailsTab.js +16 -3
  43. data/webpack/__tests__/ForemanRhCloudHelpers.test.js +1 -16
  44. data/webpack/__tests__/__snapshots__/ForemanRhCloudHelpers.test.js.snap +0 -6
  45. metadata +4 -10
  46. data/lib/foreman_inventory_upload/async/create_missing_insights_facets.rb +0 -29
  47. data/lib/foreman_inventory_upload/async/generate_host_report.rb +0 -20
  48. data/lib/foreman_inventory_upload/async/host_inventory_report_job.rb +0 -39
  49. data/lib/foreman_inventory_upload/async/single_host_report_job.rb +0 -20
  50. data/test/jobs/queue_for_upload_job_test.rb +0 -63
  51. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTotalRiskChart.test.js +0 -194
@@ -83,27 +83,6 @@ module ForemanRhCloud
83
83
  :description => N_('Configure Cloud Connector on given hosts'),
84
84
  :proxy_selector_override => ::RemoteExecutionProxySelector::INTERNAL_PROXY
85
85
  )
86
-
87
- ScopedSearch::AutoCompleteBuilder.class_eval do
88
- # Insights rule IDs always contain a pipe character.
89
- # example: hardening_ssh_config_perms|OPENSSH_HARDENING_CONFIG_PERMS
90
- # We need to override this method of scoped_search so that autocomplete
91
- # will correctly put the value in quotes (otherwise the "|" will be
92
- # interpreted as an OR.)
93
- # The only change from scoped_search code is adding the | to the regex in the final map.
94
- def complete_value_from_db(field, special_values, val)
95
- count = 20 - special_values.count
96
- completer_scope(field)
97
- .where(@options[:value_filter])
98
- .where(value_conditions(field.quoted_field, val))
99
- .select(field.quoted_field)
100
- .limit(count)
101
- .distinct
102
- .map(&field.field)
103
- .compact
104
- .map { |v| v.to_s =~ /\s|\|/ ? "\"#{v.gsub('"', '\"')}\"" : v }
105
- end
106
- end
107
86
  end
108
87
 
109
88
  # Ideally this code belongs to an initializer. The problem is that Katello controllers are not initialized completely until after the end of the to_prepare blocks
@@ -115,20 +94,23 @@ module ForemanRhCloud
115
94
  if defined?(Katello) && !Foreman.in_setup_db_rake?
116
95
  Katello::Api::V2::OrganizationsController.include Foreman::Controller::SmartProxyAuth
117
96
  # patch the callbacks order for :download_debug_certificate, since local_find_taxonomy has to run after the user is already initialized
118
- Katello::Api::V2::OrganizationsController.before_find_taxonomy_actions do
119
- Katello::Api::V2::OrganizationsController.add_smart_proxy_filters(
120
- [:index, :download_debug_certificate],
121
- features: ForemanRhCloud.on_prem_smart_proxy_features
122
- )
123
- end
97
+ Katello::Api::V2::OrganizationsController.skip_before_action(:local_find_taxonomy, only: :download_debug_certificate)
98
+ Katello::Api::V2::OrganizationsController.add_smart_proxy_filters(
99
+ [:index, :download_debug_certificate],
100
+ features: ForemanRhCloud.on_prem_smart_proxy_features
101
+ )
102
+ Katello::Api::V2::OrganizationsController.before_action(:local_find_taxonomy, only: :download_debug_certificate)
103
+
124
104
  Katello::Api::V2::RepositoriesController.include Foreman::Controller::SmartProxyAuth
125
105
  # patch the callbacks order for :index, since find_product has to run after the user is already initialized
126
- Katello::Api::V2::RepositoriesController.before_index_actions do
127
- Katello::Api::V2::RepositoriesController.add_smart_proxy_filters(
128
- :index,
129
- features: ForemanRhCloud.on_prem_smart_proxy_features
130
- )
131
- end
106
+ Katello::Api::V2::RepositoriesController.skip_before_action(:find_product, only: :index)
107
+ Katello::Api::V2::RepositoriesController.skip_before_action(:find_optional_organization, only: :index)
108
+ Katello::Api::V2::RepositoriesController.add_smart_proxy_filters(
109
+ :index,
110
+ features: ForemanRhCloud.on_prem_smart_proxy_features
111
+ )
112
+ Katello::Api::V2::RepositoriesController.before_action(:find_product, only: :index)
113
+ Katello::Api::V2::RepositoriesController.before_action(:find_optional_organization, only: :index)
132
114
  end
133
115
  end
134
116
 
@@ -13,15 +13,15 @@ module ForemanRhCloud
13
13
 
14
14
  settings do
15
15
  category(:rh_cloud, N_('Insights')) do
16
- setting('allow_auto_inventory_upload', type: :boolean, description: N_('Enable automatic upload of your host inventory to the Red Hat cloud. Ignored when using local Insights.'), default: true, full_name: N_('Automatic inventory upload'))
17
- setting('allow_auto_insights_sync', type: :boolean, description: N_('Enable automatic synchronization of Insights recommendations from the Red Hat cloud. Ignored when using local Insights.'), default: true, full_name: N_('Synchronize recommendations Automatically'))
18
- setting('allow_auto_insights_mismatch_delete', type: :boolean, description: N_('Enable automatic deletion of mismatched host records from the Red Hat cloud. Ignored when using local Insights.'), default: false, full_name: N_('Automatic mismatch deletion'))
19
- setting('obfuscate_inventory_hostnames', type: :boolean, description: N_('Obfuscate host names sent to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored because host names are not included in the report.) Ignored when using local Insights.'), default: false, full_name: N_('Obfuscate host names'))
20
- setting('obfuscate_inventory_ips', type: :boolean, description: N_('Obfuscate ipv4 addresses sent to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored because host IPv4 addresses are not included in the report.) Ignored when using local Insights.'), default: false, full_name: N_('Obfuscate host ipv4 addresses.'))
21
- setting('exclude_installed_packages', type: :boolean, description: N_('Exclude installed packages from being uploaded to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored and installed packages are always excluded.) Ignored when using local Insights.'), default: false, full_name: N_("Exclude installed packages"))
22
- setting('include_parameter_tags', type: :boolean, description: N_('Should import include parameter tags from Foreman? Ignored when using local Insights.'), default: false, full_name: N_('Include parameters in insights-client reports'))
23
- setting('rhc_instance_id', type: :string, description: N_('RHC daemon id. Ignored when using local Insights.'), default: nil, full_name: N_('ID of the RHC(Yggdrasil) daemon'))
24
- setting('insights_minimal_data_collection', type: :boolean, default: false, full_name: N_('Minimal data collection'), description: N_('Only include the minimum required data in inventory reports for uploading to Red Hat cloud. When this is true, installed packages are excluded from the report regardless of the exclude_installed_packages setting, and host names and IPv4 addresses are excluded from the report regardless of obfuscation settings. Ignored when using local Insights.'))
16
+ setting('allow_auto_inventory_upload', type: :boolean, description: N_('Enable automatic upload of your host inventory to the Red Hat cloud'), default: true, full_name: N_('Automatic inventory upload'))
17
+ setting('allow_auto_insights_sync', type: :boolean, description: N_('Enable automatic synchronization of Insights recommendations from the Red Hat cloud'), default: true, full_name: N_('Synchronize recommendations Automatically'))
18
+ setting('allow_auto_insights_mismatch_delete', type: :boolean, description: N_('Enable automatic deletion of mismatched host records from the Red Hat cloud'), default: false, full_name: N_('Automatic mismatch deletion'))
19
+ setting('obfuscate_inventory_hostnames', type: :boolean, description: N_('Obfuscate host names sent to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored because host names are not included in the report.)'), default: false, full_name: N_('Obfuscate host names'))
20
+ setting('obfuscate_inventory_ips', type: :boolean, description: N_('Obfuscate ipv4 addresses sent to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored because host IPv4 addresses are not included in the report.)'), default: false, full_name: N_('Obfuscate host ipv4 addresses.'))
21
+ setting('exclude_installed_packages', type: :boolean, description: N_('Exclude installed packages from being uploaded to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored and installed packages are always excluded.)'), default: false, full_name: N_("Exclude installed packages"))
22
+ setting('include_parameter_tags', type: :boolean, description: N_('Should import include parameter tags from Foreman?'), default: false, full_name: N_('Include parameters in insights-client reports'))
23
+ setting('rhc_instance_id', type: :string, description: N_('RHC daemon id'), default: nil, full_name: N_('ID of the RHC(Yggdrasil) daemon'))
24
+ setting('insights_minimal_data_collection', type: :boolean, default: false, full_name: N_('Minimal data collection'), description: N_('Only include the minimum required data in inventory reports for uploading to Red Hat cloud. When this is true, installed packages are excluded from the report regardless of the exclude_installed_packages setting, and host names and IPv4 addresses are excluded from the report regardless of obfuscation settings.'))
25
25
  end
26
26
  end
27
27
 
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '12.2.10'.freeze
2
+ VERSION = '13.0.0'.freeze
3
3
  end
@@ -9,20 +9,22 @@ namespace :rh_cloud_inventory do
9
9
  else
10
10
  organizations = [Organization.where(:id => ENV['organization_id']).first]
11
11
  end
12
+ disconnected = ForemanRhCloud.with_iop_smart_proxy?
12
13
  User.as_anonymous_admin do
13
14
  organizations.each do |organization|
14
15
  ForemanTasks.async_task(
15
16
  ForemanInventoryUpload::Async::GenerateReportJob,
16
17
  ForemanInventoryUpload.generated_reports_folder,
17
- organization.id
18
+ organization.id,
19
+ disconnected
18
20
  )
19
21
  puts "Generated and uploaded inventory report for organization '#{organization.name}'"
20
22
  end
21
23
  end
22
24
  end
23
25
  desc 'Generate inventory report to be sent to Red Hat cloud'
24
- task generate: [:environment, 'dynflow:client'] do
25
- organization_ids = [ENV['organization_id']]
26
+ task generate: :environment do
27
+ organizations = [ENV['organization_id']]
26
28
  base_folder = ENV['target'] || Dir.pwd
27
29
  filter = ENV['hosts_filter']
28
30
 
@@ -32,22 +34,36 @@ namespace :rh_cloud_inventory do
32
34
  puts "Using #{base_folder} for the output"
33
35
  end
34
36
 
35
- if organization_ids.empty?
37
+ if organizations.empty?
36
38
  puts "Must specify organization_id"
37
39
  return
38
40
  end
39
41
 
40
42
  User.as_anonymous_admin do
41
- organization_ids.each do |organization_id|
42
- ForemanTasks.sync_task(
43
- ForemanInventoryUpload::Async::HostInventoryReportJob,
44
- base_folder,
45
- organization_id,
46
- filter,
47
- false # don't upload; the user ran report:generate and not report:generate_upload
48
- )
43
+ organizations.each do |organization|
44
+ target = File.join(base_folder, ForemanInventoryUpload.facts_archive_name(organization, filter))
45
+ archived_report_generator = ForemanInventoryUpload::Generators::ArchivedReport.new(target, Logger.new(STDOUT))
46
+ archived_report_generator.render(organization: organization, filter: filter)
47
+ puts "Successfully generated #{target} for organization id #{organization}"
48
+
49
+ next unless ForemanRhCloud.with_iop_smart_proxy?
50
+
51
+ puts 'Creating missing insights facets'
52
+ hosts_without_facets = ForemanInventoryUpload::Generators::Queries.for_org(organization, hosts_query: 'null? insights_uuid')
53
+ hosts_without_facets.each do |batch|
54
+ facets = batch.pluck(:id, 'katello_subscription_facets.uuid').map do |host_id, uuid|
55
+ {
56
+ host_id: host_id,
57
+ uuid: uuid,
58
+ }
59
+ end
60
+ # We don't need to validate the facets here as we create the necessary fields.
61
+ # rubocop:disable Rails/SkipsModelValidations
62
+ InsightsFacet.upsert_all(facets, unique_by: :host_id) unless facets.empty?
63
+ # rubocop:enable Rails/SkipsModelValidations
64
+ end
65
+ puts 'Missing Insights facets created'
49
66
  end
50
- puts "Check the Uploading tab for report uploading status." if Setting[:subscription_connection_enabled]
51
67
  end
52
68
  end
53
69
  desc 'Upload generated inventory report to Red Hat cloud'
@@ -55,7 +71,8 @@ namespace :rh_cloud_inventory do
55
71
  base_folder = ENV['target'] || ForemanInventoryUpload.generated_reports_folder
56
72
  organization_id = ENV['organization_id']
57
73
  report_file = ForemanInventoryUpload.facts_archive_name(organization_id)
58
- ForemanTasks.sync_task(ForemanInventoryUpload::Async::QueueForUploadJob, base_folder, report_file, organization_id)
74
+ disconnected = ForemanRhCloud.with_iop_smart_proxy?
75
+ ForemanTasks.sync_task(ForemanInventoryUpload::Async::QueueForUploadJob, base_folder, report_file, organization_id, disconnected)
59
76
  puts "Uploaded #{report_file}"
60
77
  end
61
78
  end