foreman_rh_cloud 10.0.1 → 11.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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/controllers/concerns/insights_cloud/client_authentication.rb +1 -1
  4. data/app/models/concerns/rh_cloud_host.rb +4 -4
  5. data/app/models/insights_client_report_status.rb +8 -8
  6. data/app/models/insights_facet.rb +1 -1
  7. data/app/models/insights_hit.rb +1 -1
  8. data/app/models/inventory_sync/inventory_status.rb +4 -4
  9. data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +2 -1
  10. data/app/services/foreman_rh_cloud/hit_remediations_retriever.rb +1 -1
  11. data/app/services/foreman_rh_cloud/url_remediations_retriever.rb +1 -1
  12. data/config/initializers/zeitwerk.rb +3 -0
  13. data/config/routes.rb +2 -2
  14. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +1 -1
  15. data/lib/foreman_inventory_upload/generators/json_stream.rb +1 -0
  16. data/lib/foreman_inventory_upload/generators/slice.rb +1 -0
  17. data/lib/foreman_rh_cloud/engine.rb +103 -97
  18. data/lib/foreman_rh_cloud/version.rb +1 -1
  19. data/lib/foreman_rh_cloud.rb +7 -7
  20. data/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb +1 -1
  21. data/lib/insights_cloud/async/insights_generate_notifications.rb +1 -1
  22. data/lib/insights_cloud/generators/playbook_progress_generator.rb +1 -0
  23. data/package.json +1 -1
  24. data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +7 -4
  25. data/test/controllers/inventory_upload/api/inventory_controller_test.rb +1 -1
  26. data/test/factories/inventory_upload_factories.rb +1 -1
  27. data/test/jobs/cloud_connector_announce_task_test.rb +1 -2
  28. data/test/jobs/connector_playbook_execution_reporter_task_test.rb +1 -2
  29. data/test/jobs/exponential_backoff_test.rb +2 -1
  30. data/test/test_plugin_helper.rb +8 -0
  31. data/test/unit/rh_cloud_permissions_test.rb +2 -1
  32. data/test/unit/services/foreman_rh_cloud/hit_remediations_retriever_test.rb +2 -2
  33. data/test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb +1 -1
  34. data/test/unit/services/foreman_rh_cloud/url_remediations_retriever_test.rb +2 -2
  35. data/test/unit/tags_generator_test.rb +5 -2
  36. metadata +11 -11
  37. data/lib/foreman_rh_cloud/settings.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ff94b0740c89b0b945f90e7feba658b30341a7f8bb5c1fd2e59cdfc68d05969
4
- data.tar.gz: b25c4f29a021b554b425d6d464971aed419e3021736730b696710c10e9804670
3
+ metadata.gz: fcd4ee874e42e9236bbc4fae540911c372af73f3a336507c9421693b8fb128da
4
+ data.tar.gz: da0c96b9b8fb3d737d0f8902da7176adbd2f1a8810260ddeba547c3a22004ec7
5
5
  SHA512:
6
- metadata.gz: 6c4b8398e71971b211bb7eb5a76f3d4acd2a274eb69cd9c6f33c8961e0824c8f9da3a34e7ae72c438ab9ddc5042f9a4e3aee53bf24c5ad07ce617b3bdba83eee
7
- data.tar.gz: a0f2b3d8d0b1ddf1c0bccd5eeef2c818d8f81bf1a05eaa5e9f0a9bacd70368381d362343f5bc454023b258c238127664f4aaac709fe40feae03ae8b400f80f0c
6
+ metadata.gz: 12343eaac2bfb4c666c156a84a868f02a3b684f4a4bf044f7a838d9134d140ec6fb698b356c35efb8b11618fa0c36b3a61c0cc411caf48ff91b8fc9957528074
7
+ data.tar.gz: 41f578f21a65aee43ade158a99991c1b3b7b37ee2000e0e1c8c7d55cba60ac94d31e734d205e589bfc1bf1850fb98142b91ea975b3d9580361a11803eac8f17b
data/README.md CHANGED
@@ -83,7 +83,7 @@ Fork and send a Pull Request. Thanks!
83
83
 
84
84
  ## Copyright
85
85
 
86
- Copyright (c) *year* *your name*
86
+ Copyright (c) 2013 - 2024 - The Foreman Team
87
87
 
88
88
  This program is free software: you can redistribute it and/or modify
89
89
  it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@ module InsightsCloud
17
17
  end
18
18
 
19
19
  def subscribed_host_by_uuid(uuid)
20
- @host = Host.unscoped.joins(:subscription_facet).where(:katello_subscription_facets => {:uuid => uuid }).first
20
+ @host = Host.unscoped.joins(:subscription_facet).where(:katello_subscription_facets => { :uuid => uuid }).first
21
21
  end
22
22
  end
23
23
  end
@@ -14,12 +14,12 @@ module RhCloudHost
14
14
 
15
15
  has_one :insights_client_report_status_object, :class_name => '::InsightsClientReportStatus', :foreign_key => 'host_id'
16
16
  scoped_search :relation => :insights_client_report_status_object, :on => :status, :rename => :insights_client_report_status,
17
- :complete_value => { :reporting => ::InsightsClientReportStatus::REPORTING,
18
- :no_report => ::InsightsClientReportStatus::NO_REPORT }
17
+ :complete_value => { :reporting => ::InsightsClientReportStatus::REPORTING,
18
+ :no_report => ::InsightsClientReportStatus::NO_REPORT }
19
19
 
20
20
  has_one :inventory_sync_status_object, :class_name => '::InventorySync::InventoryStatus', :foreign_key => 'host_id'
21
21
  scoped_search :relation => :inventory_sync_status_object, :on => :status, :rename => :insights_inventory_sync_status,
22
- :complete_value => { :disconnect => ::InventorySync::InventoryStatus::DISCONNECT,
23
- :sync => ::InventorySync::InventoryStatus::SYNC }
22
+ :complete_value => { :disconnect => ::InventorySync::InventoryStatus::DISCONNECT,
23
+ :sync => ::InventorySync::InventoryStatus::SYNC }
24
24
  end
25
25
  end
@@ -13,19 +13,19 @@ class InsightsClientReportStatus < HostStatus::Status
13
13
 
14
14
  def to_label(_options = {})
15
15
  case status
16
- when REPORTING
17
- N_('Reporting')
18
- when NO_REPORT
19
- N_('Not reporting')
16
+ when REPORTING
17
+ N_('Reporting')
18
+ when NO_REPORT
19
+ N_('Not reporting')
20
20
  end
21
21
  end
22
22
 
23
23
  def to_global(_options = {})
24
24
  case status
25
- when REPORTING
26
- ::HostStatus::Global::OK
27
- when NO_REPORT
28
- ::HostStatus::Global::ERROR
25
+ when REPORTING
26
+ ::HostStatus::Global::OK
27
+ when NO_REPORT
28
+ ::HostStatus::Global::ERROR
29
29
  end
30
30
  end
31
31
 
@@ -4,5 +4,5 @@ class InsightsFacet < HostFacets::Base
4
4
  primary_key: :host_id,
5
5
  class_name: 'InsightsHit',
6
6
  dependent: :destroy
7
- scope :for_organizations, ->(organization_ids) { joins(:host).where(hosts: { organization_id: organization_ids}) }
7
+ scope :for_organizations, ->(organization_ids) { joins(:host).where(hosts: { organization_id: organization_ids }) }
8
8
  end
@@ -8,7 +8,7 @@ class InsightsHit < ApplicationRecord
8
8
  has_one :rule, class_name: 'InsightsRule', foreign_key: 'rule_id', primary_key: 'rule_id'
9
9
 
10
10
  scope :with_playbook, -> { joins(:rule) }
11
- scope :for_organizations, ->(organization_ids) { joins(:host).where(hosts: { organization_id: organization_ids}) }
11
+ scope :for_organizations, ->(organization_ids) { joins(:host).where(hosts: { organization_id: organization_ids }) }
12
12
 
13
13
  scoped_search on: :title, complete_value: true
14
14
  scoped_search on: :total_risk, complete_value: true
@@ -20,10 +20,10 @@ module InventorySync
20
20
 
21
21
  def to_label
22
22
  case status
23
- when DISCONNECT
24
- N_('Host was not uploaded to your RH cloud inventory')
25
- when SYNC
26
- N_('Successfully uploaded to your RH cloud inventory')
23
+ when DISCONNECT
24
+ N_('Host was not uploaded to your RH cloud inventory')
25
+ when SYNC
26
+ N_('Successfully uploaded to your RH cloud inventory')
27
27
  end
28
28
  end
29
29
 
@@ -30,7 +30,8 @@ module ForemanRhCloud
30
30
  params: forward_params,
31
31
  user_agent: http_user_agent(original_request),
32
32
  content_type: original_request.media_type.presence || original_request.format.to_s,
33
- }),
33
+ }
34
+ ),
34
35
  }
35
36
  base_params.merge(path_params(original_request.path, certs))
36
37
  end
@@ -29,7 +29,7 @@ module ForemanRhCloud
29
29
  def remediations
30
30
  @remediations ||= Hash[
31
31
  InsightsResolution.where(id: remediation_ids).pluck(:id, :resolution_type, :rule_id).map do |id, resolution_type, rule_id|
32
- [id, {resolution_type: resolution_type, rule_id: rule_id}]
32
+ [id, { resolution_type: resolution_type, rule_id: rule_id }]
33
33
  end
34
34
  ]
35
35
  end
@@ -1,5 +1,5 @@
1
1
  module ForemanRhCloud
2
- class UrlRemediationsRetriever < RemediationsRetriever
2
+ class URLRemediationsRetriever < RemediationsRetriever
3
3
  attr_reader :url, :payload, :headers
4
4
 
5
5
  def initialize(url:, organization_id:, payload: '', headers: {}, logger: Logger.new(IO::NULL))
@@ -0,0 +1,3 @@
1
+ Rails.autoloaders.main.ignore(
2
+ ForemanRhCloud::Engine.root.join('lib/foreman_rh_cloud/version.rb')
3
+ )
data/config/routes.rb CHANGED
@@ -47,8 +47,8 @@ Rails.application.routes.draw do
47
47
 
48
48
  # API routes
49
49
 
50
- namespace :api, :defaults => {:format => 'json'} do
51
- scope '(:apiv)', :module => :v2, :defaults => {:apiv => 'v2'}, :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do
50
+ namespace :api, :defaults => { :format => 'json' } do
51
+ scope '(:apiv)', :module => :v2, :defaults => { :apiv => 'v2' }, :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do
52
52
  resources :organizations, :only => [:show] do
53
53
  namespace 'rh_cloud' do
54
54
  get 'missing_hosts', to: 'inventory#get_hosts'
@@ -133,7 +133,7 @@ module ForemanInventoryUpload
133
133
 
134
134
  def uuid_value!(value)
135
135
  uuid = uuid_value(value)
136
- raise Foreman::Exception.new(N_('Value %{value} is not a valid UUID') % {value: value}) if value && uuid.empty?
136
+ raise Foreman::Exception.new(N_('Value %{value} is not a valid UUID') % { value: value }) if value && uuid.empty?
137
137
 
138
138
  uuid
139
139
  end
@@ -2,6 +2,7 @@ module ForemanInventoryUpload
2
2
  module Generators
3
3
  class JsonStream
4
4
  attr_reader :out
5
+
5
6
  def initialize(out)
6
7
  @out = out
7
8
  end
@@ -47,6 +47,7 @@ module ForemanInventoryUpload
47
47
  @stream.simple_field('account', account_id(host.organization).to_s)
48
48
  @stream.simple_field('subscription_manager_id', uuid_value!(host.subscription_facet&.uuid))
49
49
  @stream.simple_field('satellite_id', uuid_value!(host.subscription_facet&.uuid))
50
+ @stream.simple_field('convert2rhel_through_foreman', host.subscription_facet&.convert2rhel_through_foreman)
50
51
  @stream.simple_field('bios_uuid', bios_uuid(host))
51
52
  @stream.simple_field('vm_uuid', uuid_value(fact_value(host, 'virt::uuid')))
52
53
  @stream.simple_field('insights_id', uuid_value(fact_value(host, 'insights_id')))
@@ -20,15 +20,6 @@ module ForemanRhCloud
20
20
  rescue ActiveRecord::TransactionIsolationError
21
21
  end
22
22
 
23
- initializer 'foreman_rh_cloud.load_default_settings', :before => :load_config_initializers do
24
- require_dependency File.expand_path('settings.rb', __dir__)
25
- end
26
-
27
- config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
28
- config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
29
- config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
30
- config.autoload_paths += Dir["#{config.root}/app/services"]
31
- config.autoload_paths += Dir["#{config.root}/app/overrides"]
32
23
  config.autoload_paths += Dir["#{config.root}/lib"]
33
24
 
34
25
  config.eager_load_paths += Dir["#{config.root}/lib"]
@@ -40,109 +31,124 @@ module ForemanRhCloud
40
31
  end
41
32
  end
42
33
 
43
- initializer 'foreman_rh_cloud.register_plugin', :before => :finisher_hook do |_app|
44
- Foreman::Plugin.register :foreman_rh_cloud do
45
- requires_foreman '>= 3.7'
46
- register_gettext
47
-
48
- apipie_documented_controllers ["#{ForemanRhCloud::Engine.root}/app/controllers/api/v2/**/*.rb"]
49
-
50
- # Add permissions
51
- security_block :foreman_rh_cloud do
52
- permission(
53
- :generate_foreman_rh_cloud,
54
- 'foreman_inventory_upload/reports': [:generate],
55
- 'foreman_inventory_upload/tasks': [:create],
56
- 'api/v2/rh_cloud/inventory': [:get_hosts, :remove_hosts, :sync_inventory_status, :download_file, :generate_report, :enable_cloud_connector],
57
- 'foreman_inventory_upload/uploads': [:enable_cloud_connector],
58
- 'foreman_inventory_upload/uploads_settings': [:set_advanced_setting],
59
- 'foreman_inventory_upload/missing_hosts': [:remove_hosts],
60
- 'insights_cloud/settings': [:update],
61
- 'insights_cloud/tasks': [:create]
62
- )
63
- permission(
64
- :view_foreman_rh_cloud,
65
- 'foreman_inventory_upload/accounts': [:index],
66
- 'foreman_inventory_upload/reports': [:last],
67
- 'foreman_inventory_upload/uploads': [:auto_upload, :show_auto_upload, :download_file, :last],
68
- 'foreman_inventory_upload/tasks': [:show],
69
- 'foreman_inventory_upload/cloud_status': [:index],
70
- 'foreman_inventory_upload/uploads_settings': [:index],
71
- 'foreman_inventory_upload/missing_hosts': [:index],
72
- 'react': [:index]
73
- )
74
- permission(
75
- :view_insights_hits,
76
- {
77
- '/foreman_rh_cloud/insights_cloud': [:index], # for bookmarks and later for showing the page
78
- 'insights_cloud/hits': [:index, :show, :auto_complete_search, :resolutions],
79
- 'insights_cloud/settings': [:index, :show],
80
- 'react': [:index],
81
- },
82
- :resource_type => ::InsightsHit.name
83
- )
84
- permission(
85
- :dispatch_cloud_requests,
86
- 'api/v2/rh_cloud/cloud_request': [:update]
87
- )
88
- permission(
89
- :control_organization_insights,
90
- 'insights_cloud/settings': [:set_org_parameter]
91
- )
92
- end
34
+ initializer 'foreman_rh_cloud.register_plugin', :before => :finisher_hook do |app|
35
+ app.reloader.to_prepare do
36
+ Foreman::Plugin.register :foreman_rh_cloud do
37
+ requires_foreman '>= 3.13'
38
+ register_gettext
39
+
40
+ apipie_documented_controllers ["#{ForemanRhCloud::Engine.root}/app/controllers/api/v2/**/*.rb"]
41
+
42
+ settings do
43
+ category(:rh_cloud, N_('RHCloud')) do
44
+ 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'))
45
+ setting('allow_auto_insights_sync', type: :boolean, description: N_('Enable automatic synchronization of Insights recommendations from the Red Hat cloud'), default: false, full_name: N_('Synchronize recommendations Automatically'))
46
+ 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'))
47
+ setting('obfuscate_inventory_hostnames', type: :boolean, description: N_('Obfuscate host names sent to the Red Hat cloud'), default: false, full_name: N_('Obfuscate host names'))
48
+ setting('obfuscate_inventory_ips', type: :boolean, description: N_('Obfuscate ipv4 addresses sent to the Red Hat cloud'), default: false, full_name: N_('Obfuscate host ipv4 addresses'))
49
+ setting('exclude_installed_packages', type: :boolean, description: N_('Exclude installed packages from being uploaded to the Red Hat cloud'), default: false, full_name: N_("Exclude installed Packages"))
50
+ 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'))
51
+ setting('rhc_instance_id', type: :string, description: N_('RHC daemon id'), default: nil, full_name: N_('ID of the RHC(Yggdrasil) daemon'))
52
+ end
53
+ end
93
54
 
94
- plugin_permissions = [:view_foreman_rh_cloud, :generate_foreman_rh_cloud, :view_insights_hits, :dispatch_cloud_requests, :control_organization_insights]
55
+ # Add permissions
56
+ security_block :foreman_rh_cloud do
57
+ permission(
58
+ :generate_foreman_rh_cloud,
59
+ 'foreman_inventory_upload/reports': [:generate],
60
+ 'foreman_inventory_upload/tasks': [:create],
61
+ 'api/v2/rh_cloud/inventory': [:get_hosts, :remove_hosts, :sync_inventory_status, :download_file, :generate_report, :enable_cloud_connector],
62
+ 'foreman_inventory_upload/uploads': [:enable_cloud_connector],
63
+ 'foreman_inventory_upload/uploads_settings': [:set_advanced_setting],
64
+ 'foreman_inventory_upload/missing_hosts': [:remove_hosts],
65
+ 'insights_cloud/settings': [:update],
66
+ 'insights_cloud/tasks': [:create]
67
+ )
68
+ permission(
69
+ :view_foreman_rh_cloud,
70
+ 'foreman_inventory_upload/accounts': [:index],
71
+ 'foreman_inventory_upload/reports': [:last],
72
+ 'foreman_inventory_upload/uploads': [:auto_upload, :show_auto_upload, :download_file, :last],
73
+ 'foreman_inventory_upload/tasks': [:show],
74
+ 'foreman_inventory_upload/cloud_status': [:index],
75
+ 'foreman_inventory_upload/uploads_settings': [:index],
76
+ 'foreman_inventory_upload/missing_hosts': [:index],
77
+ 'react': [:index]
78
+ )
79
+ permission(
80
+ :view_insights_hits,
81
+ {
82
+ '/foreman_rh_cloud/insights_cloud': [:index], # for bookmarks and later for showing the page
83
+ 'insights_cloud/hits': [:index, :show, :auto_complete_search, :resolutions],
84
+ 'insights_cloud/settings': [:index, :show],
85
+ 'react': [:index],
86
+ },
87
+ :resource_type => ::InsightsHit.name
88
+ )
89
+ permission(
90
+ :dispatch_cloud_requests,
91
+ 'api/v2/rh_cloud/cloud_request': [:update]
92
+ )
93
+ permission(
94
+ :control_organization_insights,
95
+ 'insights_cloud/settings': [:set_org_parameter]
96
+ )
97
+ end
98
+
99
+ plugin_permissions = [:view_foreman_rh_cloud, :generate_foreman_rh_cloud, :view_insights_hits, :dispatch_cloud_requests, :control_organization_insights]
95
100
 
96
- role 'ForemanRhCloud', plugin_permissions, 'Role granting permissions to view the hosts inventory,
97
- generate a report, upload it to the cloud and download it locally'
101
+ role 'ForemanRhCloud', plugin_permissions, 'Role granting permissions to view the hosts inventory,
102
+ generate a report, upload it to the cloud and download it locally'
98
103
 
99
- add_permissions_to_default_roles Role::ORG_ADMIN => plugin_permissions,
100
- Role::MANAGER => plugin_permissions,
101
- Role::SYSTEM_ADMIN => plugin_permissions
104
+ add_permissions_to_default_roles Role::ORG_ADMIN => plugin_permissions,
105
+ Role::MANAGER => plugin_permissions,
106
+ Role::SYSTEM_ADMIN => plugin_permissions
102
107
 
103
- # Adding a sub menu after hosts menu
104
- divider :top_menu, caption: N_('RH Cloud'), parent: :configure_menu
105
- menu :top_menu, :inventory_upload, caption: N_('Inventory Upload'), url: '/foreman_rh_cloud/inventory_upload', url_hash: { controller: :react, action: :index }, parent: :configure_menu
106
- menu :top_menu, :insights_hits, caption: N_('Insights'), url: '/foreman_rh_cloud/insights_cloud', url_hash: { controller: :react, action: :index }, parent: :configure_menu
108
+ # Adding a sub menu after hosts menu
109
+ divider :top_menu, caption: N_('RH Cloud'), parent: :configure_menu
110
+ menu :top_menu, :inventory_upload, caption: N_('Inventory Upload'), url: '/foreman_rh_cloud/inventory_upload', url_hash: { controller: :react, action: :index }, parent: :configure_menu
111
+ menu :top_menu, :insights_hits, caption: N_('Insights'), url: '/foreman_rh_cloud/insights_cloud', url_hash: { controller: :react, action: :index }, parent: :configure_menu
107
112
 
108
- register_facet InsightsFacet, :insights do
109
- configure_host do
110
- set_dependent_action :destroy
113
+ register_facet InsightsFacet, :insights do
114
+ configure_host do
115
+ set_dependent_action :destroy
116
+ end
111
117
  end
112
- end
113
118
 
114
- register_global_js_file 'global'
119
+ register_global_js_file 'global'
115
120
 
116
- register_custom_status InventorySync::InventoryStatus
117
- register_custom_status InsightsClientReportStatus
121
+ register_custom_status InventorySync::InventoryStatus
122
+ register_custom_status InsightsClientReportStatus
118
123
 
119
- describe_host do
120
- overview_buttons_provider :insights_host_overview_buttons
121
- end
124
+ describe_host do
125
+ overview_buttons_provider :insights_host_overview_buttons
126
+ end
122
127
 
123
- extend_page 'hosts/show' do |context|
124
- context.add_pagelet :main_tabs,
125
- partial: 'hosts/insights_tab',
126
- name: _('Insights'),
127
- id: 'insights',
128
- onlyif: proc { |host| host.insights }
129
- end
128
+ extend_page 'hosts/show' do |context|
129
+ context.add_pagelet :main_tabs,
130
+ partial: 'hosts/insights_tab',
131
+ name: _('Insights'),
132
+ id: 'insights',
133
+ onlyif: proc { |host| host.insights }
134
+ end
130
135
 
131
- extend_page 'hosts/_list' do |context|
132
- context.with_profile :cloud, _('RH Cloud'), default: true do
133
- add_pagelet :hosts_table_column_header, key: :insights_recommendations_count, label: _('Recommendations'), sortable: true, width: '12%', class: 'hidden-xs ellipsis', priority: 100,
134
- export_data: CsvExporter::ExportDefinition.new(:insights_recommendations_count, callback: ->(host) { host&.insights_hits&.count })
135
- add_pagelet :hosts_table_column_content, key: :insights_recommendations_count, callback: ->(host) { hits_counts_cell(host) }, class: 'hidden-xs ellipsis text-center', priority: 100
136
+ extend_page 'hosts/_list' do |context|
137
+ context.with_profile :cloud, _('RH Cloud'), default: true do
138
+ add_pagelet :hosts_table_column_header, key: :insights_recommendations_count, label: _('Recommendations'), sortable: true, width: '12%', class: 'hidden-xs ellipsis', priority: 100,
139
+ export_data: CsvExporter::ExportDefinition.new(:insights_recommendations_count, callback: ->(host) { host&.insights_hits&.count })
140
+ add_pagelet :hosts_table_column_content, key: :insights_recommendations_count, callback: ->(host) { hits_counts_cell(host) }, class: 'hidden-xs ellipsis text-center', priority: 100
141
+ end
136
142
  end
137
- end
138
143
 
139
- extend_template_helpers ForemanRhCloud::TemplateRendererHelper
140
- allowed_template_helpers :remediations_playbook, :download_rh_playbook
141
- end
144
+ extend_template_helpers ForemanRhCloud::TemplateRendererHelper
145
+ allowed_template_helpers :remediations_playbook, :download_rh_playbook
146
+ end
142
147
 
143
- ::Katello::UINotifications::Subscriptions::ManifestImportSuccess.include ForemanInventoryUpload::Notifications::ManifestImportSuccessNotificationOverride if defined?(Katello)
148
+ ::Katello::UINotifications::Subscriptions::ManifestImportSuccess.include ForemanInventoryUpload::Notifications::ManifestImportSuccessNotificationOverride if defined?(Katello)
144
149
 
145
- ::Host::Managed.include RhCloudHost
150
+ ::Host::Managed.include RhCloudHost
151
+ end
146
152
  end
147
153
 
148
154
  rake_tasks do
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '10.0.1'.freeze
2
+ VERSION = '11.0.0'.freeze
3
3
  end
@@ -94,13 +94,13 @@ module ForemanRhCloud
94
94
  # For testing purposes we can override the default hostname with an environment variable SATELLITE_RH_CLOUD_FOREMAN_HOST
95
95
  def self.foreman_host
96
96
  @foreman_host ||= begin
97
- fullname = foreman_host_name
98
- ::Host.unscoped.friendly.find(fullname)
99
- rescue ActiveRecord::RecordNotFound
100
- # fullname didn't work. Let's try shortname
101
- shortname = /(?<shortname>[^\.]*)\.?.*/.match(fullname)[:shortname]
102
- ::Host.unscoped.friendly.find(shortname)
103
- end
97
+ fullname = foreman_host_name
98
+ ::Host.unscoped.friendly.find(fullname)
99
+ rescue ActiveRecord::RecordNotFound
100
+ # fullname didn't work. Let's try shortname
101
+ shortname = /(?<shortname>[^\.]*)\.?.*/.match(fullname)[:shortname]
102
+ ::Host.unscoped.friendly.find(shortname)
103
+ end
104
104
  end
105
105
 
106
106
  def self.foreman_host_name
@@ -133,7 +133,7 @@ module InsightsCloud
133
133
  ]
134
134
  end.compact]
135
135
 
136
- {task_state: {task_done_reported: task_done_state}, hosts_state: hosts_state}
136
+ { task_state: { task_done_reported: task_done_state }, hosts_state: hosts_state }
137
137
  end
138
138
 
139
139
  def task_status(host_task, host_name)
@@ -41,7 +41,7 @@ module InsightsCloud
41
41
  Notification.create!(
42
42
  initiator: User.anonymous_admin,
43
43
  audience: ::Notification::AUDIENCE_ADMIN,
44
- message: UINotifications::StringParser.new(blueprint.message, {hits_count: hits_count}).to_s,
44
+ message: UINotifications::StringParser.new(blueprint.message, { hits_count: hits_count }).to_s,
45
45
  notification_blueprint: blueprint,
46
46
  actions: {
47
47
  links: [
@@ -2,6 +2,7 @@ module InsightsCloud
2
2
  module Generators
3
3
  class PlaybookProgressGenerator
4
4
  attr_reader :correlation_id
5
+
5
6
  def initialize(correlation_id)
6
7
  @messages = []
7
8
  @correlation_id = correlation_id
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreman_rh_cloud",
3
- "version": "10.0.1",
3
+ "version": "11.0.0",
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -42,7 +42,7 @@ module InsightsCloud::Api
42
42
  end.returns(res)
43
43
  InsightsCloud::Api::MachineTelemetriesController.any_instance.expects(:cp_owner_id).returns('123')
44
44
 
45
- post :forward_request, as: :json, params: { "path" => "static/v1/test", "machine_telemetry" => {"foo" => "bar"} }
45
+ post :forward_request, as: :json, params: { "path" => "static/v1/test", "machine_telemetry" => { "foo" => "bar" } }
46
46
  assert_equal @body, @response.body
47
47
  end
48
48
 
@@ -62,7 +62,7 @@ module InsightsCloud::Api
62
62
 
63
63
  test "should set etag header to response from cloud" do
64
64
  etag = '12345'
65
- req = RestClient::Request.new(:method => 'GET', :url => 'http://test.theforeman.org', :headers => { "If-None-Match": etag})
65
+ req = RestClient::Request.new(:method => 'GET', :url => 'http://test.theforeman.org', :headers => { "If-None-Match": etag })
66
66
  net_http_resp = Net::HTTPResponse.new(1.0, 200, "OK")
67
67
  net_http_resp[Rack::ETAG] = etag
68
68
  res = RestClient::Response.create(@body, net_http_resp, req)
@@ -107,6 +107,7 @@ module InsightsCloud::Api
107
107
 
108
108
  context '#branch_info' do
109
109
  setup do
110
+ UpstreamOnlySettingsTestHelper.set_if_available('allow_multiple_content_views')
110
111
  User.current = User.find_by(login: 'secret_admin')
111
112
 
112
113
  @env = FactoryBot.create(:katello_k_t_environment)
@@ -122,11 +123,13 @@ module InsightsCloud::Api
122
123
  FactoryBot.create(
123
124
  :katello_content_view_environment,
124
125
  content_view: FactoryBot.create(:katello_content_view, organization: @env.organization),
125
- lifecycle_environment: @env),
126
+ lifecycle_environment: @env
127
+ ),
126
128
  FactoryBot.create(
127
129
  :katello_content_view_environment,
128
130
  content_view: FactoryBot.create(:katello_content_view, organization: @env.organization),
129
- lifecycle_environment: @env2),
131
+ lifecycle_environment: @env2
132
+ ),
130
133
  ],
131
134
  organization: @env.organization
132
135
  )
@@ -14,7 +14,7 @@ module InventoryUpload::Api
14
14
  .expects(:start_report_generation)
15
15
  .with(@test_org.id.to_s, @disconnected)
16
16
 
17
- post :generate_report, params: { organization_id: @test_org.id, disconnected: @disconnected}
17
+ post :generate_report, params: { organization_id: @test_org.id, disconnected: @disconnected }
18
18
 
19
19
  assert_response :success
20
20
  end
@@ -56,7 +56,7 @@ end
56
56
 
57
57
  FactoryBot.define do
58
58
  factory :katello_subscription_facets, :aliases => [:subscription_facet], :class => ::Katello::Host::SubscriptionFacet do
59
- sequence(:uuid) { |n| "00000000-%<n>04d-%<r>04d-0000-000000000000" % {n: n, r: rand(500)} }
59
+ sequence(:uuid) { |n| "00000000-%<n>04d-%<r>04d-0000-000000000000" % { n: n, r: rand(500) } }
60
60
  facts { { 'memory.memtotal' => "12 GB" } }
61
61
  end
62
62
  end
@@ -60,8 +60,7 @@ class CloudConnectorAnnounceTaskTest < ActiveSupport::TestCase
60
60
 
61
61
  template_invocation = FactoryBot.build(:template_invocation,
62
62
  :template => job_template,
63
- :job_invocation => job_invocation
64
- )
63
+ :job_invocation => job_invocation)
65
64
 
66
65
  template_invocation.input_values << FactoryBot.create(
67
66
  :template_invocation_input_value,
@@ -217,8 +217,7 @@ class ConnectorPlaybookExecutionReporterTaskTest < ActiveSupport::TestCase
217
217
 
218
218
  template_invocation = FactoryBot.build(:template_invocation,
219
219
  :template => job_template,
220
- :job_invocation => job_invocation
221
- )
220
+ :job_invocation => job_invocation)
222
221
 
223
222
  template_invocation.input_values << FactoryBot.create(
224
223
  :template_invocation_input_value,
@@ -27,7 +27,8 @@ class ExponentialBackoffTest < ActiveSupport::TestCase
27
27
  lambda do |instance|
28
28
  instance.done!
29
29
  raise ::Foreman::Exception('Foo')
30
- end)
30
+ end
31
+ )
31
32
 
32
33
  ForemanTasks.sync_task(TestAction)
33
34
  end
@@ -117,3 +117,11 @@ module CandlepinIsolation
117
117
  end
118
118
  end
119
119
  end
120
+
121
+ module UpstreamOnlySettingsTestHelper
122
+ def self.set_if_available(setting_name, value: true)
123
+ Setting[setting_name] = value
124
+ rescue Foreman::Exception
125
+ skip "Setting #{setting_name} is not available in Foreman"
126
+ end
127
+ end
@@ -10,5 +10,6 @@ class RhCloudPermissionsTest < ActiveSupport::TestCase
10
10
  'insights_cloud/api/machine_telemetries/forward_request',
11
11
  'insights_cloud/api/machine_telemetries/branch_info',
12
12
  ],
13
- skip_patterns: [/^(?!foreman_inventory_upload|insights_cloud|.*rh_cloud).*/]) # include only plugin paths
13
+ skip_patterns: [/^(?!foreman_inventory_upload|insights_cloud|.*rh_cloud).*/]
14
+ ) # include only plugin paths
14
15
  end
@@ -15,7 +15,7 @@ class HitRemediationsRetrieverTest < ActiveSupport::TestCase
15
15
  FactoryBot.create(:insights_facet, uuid: 'HOST2', host_id: @host2.id)
16
16
  host2_hit1 = FactoryBot.create(:insights_hit, rule_id: rule1.rule_id, host_id: @host2.id)
17
17
 
18
- pairs = [{'hit_id' => host1_hit1.id, 'resolution_id' => rule1_remediation1.id}, {'hit_id' => host2_hit1.id, 'resolution_id' => rule1_remediation1.id}]
18
+ pairs = [{ 'hit_id' => host1_hit1.id, 'resolution_id' => rule1_remediation1.id }, { 'hit_id' => host2_hit1.id, 'resolution_id' => rule1_remediation1.id }]
19
19
  retriever = ForemanRhCloud::HitRemediationsRetriever.new(pairs)
20
20
 
21
21
  actual_request = retriever.send(:playbook_request)
@@ -38,7 +38,7 @@ class HitRemediationsRetrieverTest < ActiveSupport::TestCase
38
38
  FactoryBot.create(:insights_facet, uuid: 'HOST2', host_id: @host2.id)
39
39
  host2_hit1 = FactoryBot.create(:insights_hit, rule_id: rule1.rule_id, host_id: @host2.id)
40
40
 
41
- pairs = [{'hit_id' => host1_hit1.id, 'resolution_id' => rule1_remediation1.id}, {'hit_id' => host2_hit1.id, 'resolution_id' => rule1_remediation2.id}]
41
+ pairs = [{ 'hit_id' => host1_hit1.id, 'resolution_id' => rule1_remediation1.id }, { 'hit_id' => host2_hit1.id, 'resolution_id' => rule1_remediation2.id }]
42
42
  retriever = ForemanRhCloud::HitRemediationsRetriever.new(pairs)
43
43
 
44
44
  actual_request = retriever.send(:playbook_request)
@@ -20,7 +20,7 @@ class TemplateRendererHelperTest < ActiveSupport::TestCase
20
20
  hit = FactoryBot.create(:insights_hit, rule: rule, host_id: @host1.id)
21
21
  remediation = FactoryBot.create(:insights_resolution, rule: rule)
22
22
 
23
- pairs = [{hit_id: hit.id, remediation_id: remediation.id}].to_json
23
+ pairs = [{ hit_id: hit.id, remediation_id: remediation.id }].to_json
24
24
 
25
25
  actual_playbook = remediations_playbook(pairs)
26
26
 
@@ -1,8 +1,8 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
- class UrlRemediationsRetrieverTest < ActiveSupport::TestCase
3
+ class URLRemediationsRetrieverTest < ActiveSupport::TestCase
4
4
  test 'Calls the given url' do
5
- retreiver = ForemanRhCloud::UrlRemediationsRetriever.new(
5
+ retreiver = ForemanRhCloud::URLRemediationsRetriever.new(
6
6
  organization_id: FactoryBot.create(:organization).id,
7
7
  url: 'http://test.example.com',
8
8
  payload: 'TEST_PAYLOAD',
@@ -5,6 +5,7 @@ class TagsGeneratorTest < ActiveSupport::TestCase
5
5
  include CandlepinIsolation
6
6
 
7
7
  setup do
8
+ UpstreamOnlySettingsTestHelper.set_if_available('allow_multiple_content_views')
8
9
  User.current = User.find_by(login: 'secret_admin')
9
10
 
10
11
  env = FactoryBot.create(:katello_k_t_environment)
@@ -28,11 +29,13 @@ class TagsGeneratorTest < ActiveSupport::TestCase
28
29
  FactoryBot.create(
29
30
  :katello_content_view_environment,
30
31
  content_view: FactoryBot.create(:katello_content_view, organization: env.organization),
31
- lifecycle_environment: env),
32
+ lifecycle_environment: env
33
+ ),
32
34
  FactoryBot.create(
33
35
  :katello_content_view_environment,
34
36
  content_view: FactoryBot.create(:katello_content_view, organization: env.organization),
35
- lifecycle_environment: env2),
37
+ lifecycle_environment: env2
38
+ ),
36
39
  ]
37
40
  )
38
41
 
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: 10.0.1
4
+ version: 11.0.0
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: 2024-06-21 00:00:00.000000000 Z
11
+ date: 2024-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman_ansible
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 15.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 15.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: foreman-tasks
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 10.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 10.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: katello
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 4.14.0.rc1.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 4.14.0.rc1.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rdoc
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.0.6
75
+ version: 0.1.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.0.6
82
+ version: 0.1.0
83
83
  description: Foreman plugin that process & upload data to Red Hat Cloud
84
84
  email:
85
85
  - rlavi@redhat.com, sshtein@redhat.com
@@ -144,6 +144,7 @@ files:
144
144
  - app/views/job_templates/rh_cloud_remediations.erb
145
145
  - app/views/layouts/foreman_rh_cloud/application.html.erb
146
146
  - config/database.yml.example
147
+ - config/initializers/zeitwerk.rb
147
148
  - config/package-lock.json.plugin
148
149
  - config/rh_cert-api_chain.pem
149
150
  - config/routes.rb
@@ -185,7 +186,6 @@ files:
185
186
  - lib/foreman_rh_cloud.rb
186
187
  - lib/foreman_rh_cloud/async/exponential_backoff.rb
187
188
  - lib/foreman_rh_cloud/engine.rb
188
- - lib/foreman_rh_cloud/settings.rb
189
189
  - lib/foreman_rh_cloud/version.rb
190
190
  - lib/insights_cloud.rb
191
191
  - lib/insights_cloud/async/cloud_connector_announce_task.rb
@@ -1,12 +0,0 @@
1
- Foreman::SettingManager.define(:foreman) do
2
- category(:rh_cloud, N_('RHCloud')) do
3
- 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'))
4
- setting('allow_auto_insights_sync', type: :boolean, description: N_('Enable automatic synchronization of Insights recommendations from the Red Hat cloud'), default: false, full_name: N_('Synchronize recommendations Automatically'))
5
- 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'))
6
- setting('obfuscate_inventory_hostnames', type: :boolean, description: N_('Obfuscate host names sent to the Red Hat cloud'), default: false, full_name: N_('Obfuscate host names'))
7
- setting('obfuscate_inventory_ips', type: :boolean, description: N_('Obfuscate ipv4 addresses sent to the Red Hat cloud'), default: false, full_name: N_('Obfuscate host ipv4 addresses'))
8
- setting('exclude_installed_packages', type: :boolean, description: N_('Exclude installed packages from being uploaded to the Red Hat cloud'), default: false, full_name: N_("Exclude installed Packages"))
9
- 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'))
10
- setting('rhc_instance_id', type: :string, description: N_('RHC daemon id'), default: nil, full_name: N_('ID of the RHC(Yggdrasil) daemon'))
11
- end
12
- end