redhat_access 2.2.11 → 2.2.16

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: e94c4f74c8bf19599836bcfa836469540b00cb9680dad9c9a21aaaddb2ef4c4f
4
- data.tar.gz: ec9a734f1907e2ebe6317accdaaa5b23d218eddc60ac2730f38040bd6f204dad
3
+ metadata.gz: fe33c66ba4b918fd0d0a4b643075d656ba00c8f1af2efc387643d181b8b132df
4
+ data.tar.gz: 1b7c7b46ffe75f51142247eac000413b5507f343bcefbeae4d436663adc74ae2
5
5
  SHA512:
6
- metadata.gz: 3119df6ee719a94587de96ed060c8f505fce193c9c40d67555471a8a3176a000501d96a1b725c1bac132fe3e6edd1d9c8ed6f2717982e509bc0974fa7b6e75b6
7
- data.tar.gz: 180a8b8c3b4a528f4d16d7fa3b117851ce527ed646a51491c4928947136608799e49f8dd37858158e732125e5fa53256ac320dcced2e4b5407559d6f9ab965ec
6
+ metadata.gz: 2cfb18c7636c09b3e55bb16c8d848a55ff1d64c87129b0de6291121ac2da3aff83a363b679346c9bbd4dd5b347290a81a4d29aa36c96ab7d7239be9f57ecfd48
7
+ data.tar.gz: 89f7c4b1effd5629d548c82def18385e60e1357729024162daac288524b9fa9561bbdfc1bd317a496182934b82359f90bfa8b14c0f5b995ecd78ca4ec7038f9c
@@ -120,6 +120,18 @@ module RedhatAccess
120
120
  host = get_content_host(uuid)
121
121
  org = get_organization(host)
122
122
 
123
+ # {
124
+ # "Satellite": {
125
+ # "Organization": ["Insights"],
126
+ # "Location": ["North America", "RTP"]
127
+ # },
128
+ #
129
+ # "SatelliteParameter": {
130
+ # "parameter_1": ["value_1"],
131
+ # "parameter_2": ["value_2"]
132
+ # }
133
+ # }
134
+
123
135
  # get organization
124
136
  labels = [{
125
137
  :namespace => "Satellite",
@@ -118,7 +118,7 @@ module RedhatAccess
118
118
 
119
119
  client = get_api_client
120
120
  res = client.call_tapi(original_method, URI.escape(resource), original_params, original_payload, {timeout: get_tapi_timeout}, use_subsets)
121
- #401 erros means our proxy is not configured right.
121
+ #401 errors means our proxy is not configured right.
122
122
  #Change it to 502 to distinguish with local applications 401 errors
123
123
  resp_data = res[:data]
124
124
  if res[:code] == 401
@@ -136,6 +136,9 @@ module RedhatAccess
136
136
  if resp_data.headers[:x_resource_count]
137
137
  response.headers['x-resource-count'] = resp_data.headers[:x_resource_count]
138
138
  end
139
+ if resp_data.headers[:x_rh_insights_request_id]
140
+ response.headers['x_rh_insights_request_id'] = resp_data.headers[:x_rh_insights_request_id]
141
+ end
139
142
  render status: res[:code], json: resp_data
140
143
  else
141
144
  render status: res[:code], json: resp_data
@@ -12,7 +12,7 @@ module RedhatAccess
12
12
  def search_by_plan_id(key, operator, value)
13
13
  insights_plan_runner = ForemanAnsible::InsightsPlanRunner.new(Organization.current, value.to_i)
14
14
  hostname_rules_relation = insights_plan_runner.hostname_rules(insights_plan_runner.playbook)
15
- host_ids = Host::Managed.where(:name => hostname_rules_relation.keys).pluck(:id)
15
+ host_ids = Host::Managed.where(:name => hostname_rules_relation.keys.map{|h| h.downcase}).pluck(:id)
16
16
  { :conditions => " hosts.id IN(#{host_ids.join(',')})" }
17
17
  end
18
18
  end
@@ -15,8 +15,7 @@ module RedhatAccess
15
15
  end
16
16
 
17
17
  def can_mask_rules(user)
18
- # #TODO move this to an auth class?
19
- # TODO move this to an auth class?
18
+ 849456 # TODO move this to an auth class?
20
19
  return false if user.nil?
21
20
  return true if user.admin
22
21
  permissions = user.cached_roles.collect(&:permissions).flatten.map!(&:name)
@@ -67,7 +66,8 @@ module RedhatAccess
67
66
  def disconnected_org?(org)
68
67
  if org
69
68
  # TODO: fix hard coding
70
- org.redhat_repository_url != 'https://cdn.redhat.com'
69
+ # disable insights if disconnected orgs aren't enabled and katello doesn't point to redhat's CDN
70
+ !REDHAT_ACCESS_CONFIG[:enable_insights_for_disconnected_orgs] && org.redhat_repository_url != 'https://cdn.redhat.com'
71
71
  else
72
72
  raise(RecordNotFound, 'Organization not found or invalid')
73
73
  end
@@ -201,22 +201,51 @@ module RedhatAccess
201
201
  end
202
202
 
203
203
  def get_portal_http_proxy
204
- proxy = nil
205
- if SETTINGS[:katello][:cdn_proxy] && SETTINGS[:katello][:cdn_proxy][:host]
206
- proxy_config = SETTINGS[:katello][:cdn_proxy]
207
- scheme = URI.parse(proxy_config[:host]).scheme
208
- uri = URI('')
209
- # Ruby's uri parser doesn't handle encoded characters so Katello added two new schemes to handle proxy
210
- # passwords. See https://github.com/Katello/katello/blob/master/app/lib/katello/util/proxy_uri.rb
211
- uri.scheme = 'proxy' if scheme == 'http'
212
- uri.scheme = 'proxys' if scheme == 'https'
213
- uri.host = URI.parse(proxy_config[:host]).host
214
- uri.port = proxy_config[:port] if proxy_config[:port]
215
- uri.user = CGI.escape(proxy_config[:user]) if proxy_config[:user]
216
- uri.password = CGI.escape(proxy_config[:password]) if proxy_config[:password]
217
- proxy = uri.to_s
204
+ begin
205
+ @http_proxy_string ||=
206
+ begin
207
+ proxy_uri = URI('')
208
+
209
+ if Setting[:content_default_http_proxy].present?
210
+ proxy_config = HttpProxy.default_global_content_proxy
211
+ proxy_uri = URI(proxy_config&.url)
212
+ if proxy_config&.username.present?
213
+ proxy_uri.user = CGI.escape(proxy_config&.username)
214
+ if proxy_config&.password.present?
215
+ proxy_uri.password = CGI.escape(proxy_config&.password)
216
+ end
217
+ end
218
+ end
219
+
220
+ if proxy_uri.to_s.blank?
221
+ if SETTINGS[:katello][:cdn_proxy] && SETTINGS[:katello][:cdn_proxy][:host]
222
+ proxy_config = SETTINGS[:katello][:cdn_proxy]
223
+ proxy_uri.scheme = URI.parse(proxy_config[:host]).scheme
224
+ proxy_uri.host = URI.parse(proxy_config[:host]).host
225
+ proxy_uri.port = proxy_config[:port] if proxy_config[:port]
226
+ if proxy_config[:user].present?
227
+ proxy_uri.user = CGI.escape(proxy_config[:user]) if proxy_config[:user]
228
+ if proxy_config[:password].present?
229
+ proxy_uri.password = CGI.escape(proxy_config[:password])
230
+ end
231
+ end
232
+ end
233
+ end
234
+
235
+ # Ruby's uri parser doesn't handle encoded characters so Katello added two new schemes to handle proxy
236
+ # passwords. See https://github.com/Katello/katello/blob/master/app/lib/katello/util/proxy_uri.rb
237
+ proxy_uri.scheme = 'proxy' if proxy_uri.scheme == 'http'
238
+ proxy_uri.scheme = 'proxys' if proxy_uri.scheme == 'https'
239
+
240
+ proxy_uri.to_s
241
+ end
242
+
243
+ Rails.logger.debug("Insights proxy url = #{@http_proxy_string}")
244
+ @http_proxy_string
245
+ rescue
246
+ Rails.logger.debug("insights plugin: Something bad happened trying to get the proxy url")
247
+ raise
218
248
  end
219
- proxy
220
249
  end
221
250
 
222
251
  def get_http_user_agent
@@ -11,6 +11,7 @@
11
11
  # :telemetry_api_timeout_s : 60
12
12
  :telemetry_ssl_verify_peer : true
13
13
  :use_subsets : false
14
+ :enable_insights_for_disconnected_orgs : false
14
15
 
15
16
  :diagnostic_logs :
16
17
  - /var/log/foreman/production.log
@@ -9,6 +9,7 @@
9
9
  :telemetry_api_host : "https://cert-api.access.redhat.com"
10
10
  :telemetry_ssl_verify_peer : true
11
11
 
12
+ :enable_insights_for_disconnected_orgs : false
12
13
  :use_subsets : false
13
14
 
14
15
  :diagnostic_logs :
@@ -1,3 +1,3 @@
1
1
  module RedhatAccess
2
- VERSION = "2.2.11"
2
+ VERSION = "2.2.16"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redhat_access
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.11
4
+ version: 2.2.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lindani Phiri
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-02-21 00:00:00.000000000 Z
12
+ date: 2020-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redhat_access_lib