foreman_rh_cloud 3.0.24.1 → 3.0.25

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0157c9f96dcbfa67895f62e292af8f9171c6d90a60f3eb8fdca5de57bd42918c
4
- data.tar.gz: 24c8de05e245d54d789bacbed59bf7bd8c85d40f7252a59b60b599ab8941f5e9
3
+ metadata.gz: fcdeab4d9295cecfb21182db7a6d67616a89ccf47a1a49b290058bcdfbc0f990
4
+ data.tar.gz: 0524546fe41d9ca57ce8a881dc011c8d0973a0900c79bdbf51a5ef69577d11c4
5
5
  SHA512:
6
- metadata.gz: cd9e22b6176184b7c40d64229170458a59d2e70fbca128b892d299359c3e531afae0ebf760d07f57ba304bc042d86a601ef13472e8e8c3686eb670620185ee70
7
- data.tar.gz: ca49d14fb99c6de0480cf180b1f38d7a70cca26808ef141cc6c504fbfc08daeda3f89127def3cc18e6d8ed2afbef835704d48ef4011442b33f7ec407def79fea
6
+ metadata.gz: 129e721b9ff7701d391189631a4782bccabd38d22e1d8bbf25093c9fda21c00d1c260489621a6f42b06dc2357e09cfc126f41deda9d367b931a082548bcb9665
7
+ data.tar.gz: 4544b0097e5131166c03cd68a35b9320f7ffbe770da6db99edc7693d2da3aafa4eb845a17de8d37bf7635038a8e9b7b26fb87e747317f82032459e4d8d7306e7
@@ -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
@@ -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}")
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '3.0.24.1'.freeze
2
+ VERSION = '3.0.25'.freeze
3
3
  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,6 +7,15 @@ 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
@@ -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 rules sync')
11
+ return
12
+ end
13
+
9
14
  plan_self
10
15
  plan_resolutions
11
16
  end
@@ -5,6 +5,11 @@ 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
 
@@ -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
@@ -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.24.1",
3
+ "version": "3.0.25",
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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')
@@ -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
@@ -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
@@ -242,6 +242,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
242
242
  end
243
243
 
244
244
  test 'Host status should be SYNC for inventory hosts' do
245
+ FactoryBot.create(:setting, name: 'rh_cloud_token', value: 'TEST TOKEN')
245
246
  InventorySync::Async::InventoryFullSync.any_instance.expects(:query_inventory).returns(@inventory)
246
247
 
247
248
  ForemanTasks.sync_task(InventorySync::Async::InventoryFullSync, @host2.organization)
@@ -253,6 +254,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
253
254
  end
254
255
 
255
256
  test 'Host status should be DISCONNECT for hosts that are not returned from cloud' do
257
+ FactoryBot.create(:setting, name: 'rh_cloud_token', value: 'TEST TOKEN')
256
258
  InventorySync::Async::InventoryFullSync.any_instance.expects(:query_inventory).returns(@inventory)
257
259
  FactoryBot.create(:fact_value, fact_name: fact_names['virt::uuid'], value: '1234', host: @host2)
258
260
 
@@ -261,4 +263,12 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
261
263
 
262
264
  assert_equal InventorySync::InventoryStatus::DISCONNECT, InventorySync::InventoryStatus.where(host_id: @host1.id).first.status
263
265
  end
266
+
267
+ test 'Task should be aborted if token is not present' do
268
+ FactoryBot.create(:setting, name: 'rh_cloud_token', value: '')
269
+
270
+ InventorySync::Async::InventoryFullSync.any_instance.expects(:plan_self).never
271
+
272
+ ForemanTasks.sync_task(InventorySync::Async::InventoryFullSync, @host1.organization)
273
+ end
264
274
  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)
@@ -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)
@@ -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.24.1
4
+ version: 3.0.25
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-07-21 00:00:00.000000000 Z
11
+ date: 2021-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katello