redhat_access 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d8750cf42444ac8386cbf05db0d3c86d7f757ec
4
- data.tar.gz: be22286e7bb71815d20a9ad792d1cd926ea6ec67
3
+ metadata.gz: c5bab54004d88ce1ec7130d84eadd5afd5956b88
4
+ data.tar.gz: ecc0e95ad8765e7c36a87240c32892216eec30e6
5
5
  SHA512:
6
- metadata.gz: 9bd5e0e63b593776ea2f3d2e00fd1b36f74836c7a0710c0356d37c04a1cf2d6d7b1583f56db3bf3f2dc84d6355893adc16579f032e43ad6a32fbcb3d4678273e
7
- data.tar.gz: 946a26663defaa6c36fc303c930665d90243c75ec33556ec810ae0fda1fa3cf6ad7b92264a6af05ace0506b4cd2ec13d15d74412b53b25d1f2605b1c1ac0b1c0
6
+ metadata.gz: dbb4c89af2a1b45faabf49edde514595c71f013fe0b6048d1ef72495f06defe1c1f056bfbb1b9523c6ee3801b9956f66c5d412cb105a4595cb9d26a77ee3ad26
7
+ data.tar.gz: 73cd36b923ef356914f0eface777a3d071839df9c08cb36cc6dc519421c1fc179d31a14ce7151579e727e2d2f91866491b743bb9e13281af68b66b5de5e4049a
@@ -80,7 +80,7 @@ angular.module('RedhatAccess', [
80
80
  COMMON_CONFIG.showTitle = true;
81
81
  hideMachinesDropdown.value = true;
82
82
  NEW_DEFAULTS.product = "Red Hat Satellite or Proxy"; //TODO read from server config
83
- NEW_DEFAULTS.version = "6.1"; //TODO read from server config
83
+ NEW_DEFAULTS.version = "6.2"; //TODO read from server config
84
84
  gettextCatalog.currentLanguage = currentLocale;
85
85
  //console.log('Setting language to ' + currentLocale);
86
86
  // $http({
@@ -26,7 +26,7 @@ module RedhatAccess
26
26
  render_telemetry_off unless telemetry_enabled_for_uuid?(User.current.login)
27
27
  end
28
28
 
29
- def get_auth_opts()
29
+ def get_auth_opts(creds)
30
30
  if valid_machine_user?
31
31
  get_ssl_options_for_uuid(User.current.login, nil)
32
32
  else
@@ -16,7 +16,7 @@ module RedhatAccess
16
16
  end
17
17
  end
18
18
 
19
- def get_auth_opts()
19
+ def get_auth_opts(creds)
20
20
  #We only support pass through basic auth @see get_api_client method
21
21
  return {}
22
22
  end
@@ -9,12 +9,9 @@ module RedhatAccess
9
9
  include RedhatAccess::Authentication::ClientAuthentication
10
10
  include RedhatAccess::Telemetry::LookUps
11
11
 
12
- before_filter :check_telemetry_enabled, :only => [:proxy]
13
12
 
14
- UPLOAD_HOST = REDHAT_ACCESS_CONFIG[:telemetry_upload_host]
15
- API_HOST = REDHAT_ACCESS_CONFIG[:telemetry_api_host]
16
- UPLOAD_URL = "#{UPLOAD_HOST}/r/insights/uploads"
17
- STRATA_URL = "#{API_HOST}/r/insights"
13
+
14
+ before_filter :check_telemetry_enabled, :only => [:proxy]
18
15
 
19
16
 
20
17
  def action_permission
@@ -42,7 +39,7 @@ module RedhatAccess
42
39
  #return TelemetryProxyCredentials.limit(1)[0]
43
40
  end
44
41
 
45
- def get_auth_opts()
42
+ def get_auth_opts(creds)
46
43
  return get_ssl_options_for_org(Organization.current ,nil)
47
44
  end
48
45
 
@@ -62,6 +59,11 @@ module RedhatAccess
62
59
  machines
63
60
  end
64
61
 
62
+
63
+ def get_current_organization
64
+ Organization.current
65
+ end
66
+
65
67
  def connection_status
66
68
  client = get_api_client
67
69
  res = client.call_tapi('GET', 'me', nil, nil, nil)
@@ -123,7 +125,7 @@ module RedhatAccess
123
125
  if original_params && original_params["accept"] && original_params["accept"] = "csv"
124
126
  send_data resp_data, type: 'text/csv; charset=utf-8', :filename => "insights_report.csv"
125
127
  else
126
- if resp_data.headers && resp_data.headers[:x_resource_count]
128
+ if resp_data.respond_to?(:headers) && resp_data.headers[:x_resource_count]
127
129
  response.headers['X-Resource-Count'] = resp_data.headers[:x_resource_count]
128
130
  end
129
131
  render status: res[:code] , json: resp_data
@@ -152,9 +154,6 @@ module RedhatAccess
152
154
  params
153
155
  end
154
156
 
155
- def get_http_user_agent
156
- "#{get_plugin_parent_name}/#{get_plugin_parent_version};#{get_rha_plugin_name}/#{get_rha_plugin_version}"
157
- end
158
157
 
159
158
  def get_branch_id
160
159
  get_branch_id_for_org(Organization.current)
@@ -162,12 +161,14 @@ module RedhatAccess
162
161
 
163
162
  def get_api_client
164
163
  Rails.logger.debug("User agent for telemetry is #{get_http_user_agent}")
165
- return RedhatAccess::Telemetry::PortalClient.new(UPLOAD_URL,STRATA_URL,
164
+ if User.current
165
+
166
+ end
167
+ return RedhatAccess::Telemetry::PortalClient.new(nil,
168
+ nil,
166
169
  get_creds,
167
170
  self,
168
- {:logger => Rails.logger,
169
- :http_proxy => get_portal_http_proxy,
170
- :user_agent => get_http_user_agent})
171
+ get_http_options(true))
171
172
  end
172
173
 
173
174
  def api_version
@@ -0,0 +1,64 @@
1
+ module Actions
2
+ module Insights
3
+ class EmailPoller < Actions::Base
4
+ include RedhatAccess::Telemetry::LookUps
5
+ middleware.use Actions::Middleware::RecurringLogic
6
+ class RunOnceCoordinatorLock < Dynflow::Coordinator::LockByWorld
7
+ def initialize(world)
8
+ super
9
+ @data[:id] = 'insights-email-poller'
10
+ end
11
+ end
12
+
13
+ class << self
14
+ attr_reader :triggered_action
15
+ def ensure_running(world = ForemanTasks.dynflow.world)
16
+ world.coordinator.acquire(RunOnceCoordinatorLock.new(world)) do
17
+ unless ForemanTasks::Task::DynflowTask.for_action(self).any?
18
+ params = {:mode => :recurring,
19
+ :input_type => :cronline,
20
+ :cronline => "0 0 * * 6"}
21
+ @triggered_action = ForemanTasks::Triggering.new_from_params(params).trigger(self)
22
+ end
23
+ end
24
+ rescue Dynflow::Coordinator::LockError
25
+ return false
26
+ end
27
+ end
28
+
29
+ def humanized_name
30
+ N_('Insights Email Notifications')
31
+ end
32
+
33
+ def plan
34
+ # Make sure we only have one instance
35
+ Rails.logger.debug("Planning Task ")
36
+ plan_self
37
+ end
38
+
39
+ def run
40
+ Rails.logger.debug("Running Task")
41
+ Organization.all.each do |org|
42
+ if telemetry_enabled?(org) && is_susbcribed_to_redhat?(org)
43
+ weekly_summary(org)
44
+ end
45
+ end
46
+ end
47
+
48
+ def weekly_summary(org)
49
+ message_svc = RedhatAccess::Telemetry::MessagingService.new(org)
50
+ weekly_data_list = message_svc.all_weekly_mail_data
51
+ weekly_data_list.each do |info|
52
+ RedhatAccess::InsightsMailer.weekly_email(info[:user], info[:data], "Insights Weekly Summary",org).deliver_now
53
+ end
54
+ end
55
+
56
+
57
+ def rescue_strategy_for_self
58
+ Dynflow::Action::Rescue::Skip
59
+ end
60
+
61
+ end
62
+ end
63
+
64
+ end
@@ -0,0 +1,22 @@
1
+ module RedhatAccess
2
+ class InsightsMailer < ApplicationMailer
3
+
4
+ def create(user, body, subject, content_type="text/html")
5
+ mail(to: user.mail,
6
+ body: body,
7
+ content_type: content_type,
8
+ subject: subject)
9
+ end
10
+
11
+ def weekly_email(user, data, subject, org)
12
+ @user = user
13
+ @data = data
14
+ @org = org
15
+ @server_url = "#{Setting[:foreman_url]}/redhat_access/insights"
16
+ @email_settings_url = "#{Setting[:foreman_url]}/users/#{user.id}/edit#mail_preferences"
17
+ mail(to: user.mail,
18
+ subject: subject)
19
+
20
+ end
21
+ end
22
+ end
@@ -1,10 +1,3 @@
1
- begin
2
- # TODO: fix dirty hack
3
- require '/usr/share/foreman/lib/satellite/version.rb'
4
- rescue LoadError
5
- # don't need to do anything
6
- Rails.logger.debug("Unable to load version file.")
7
- end
8
1
  module RedhatAccess
9
2
  module Telemetry
10
3
  module LookUps
@@ -201,6 +194,26 @@ module RedhatAccess
201
194
  proxy
202
195
  end
203
196
 
197
+ def get_http_user_agent
198
+ "#{get_plugin_parent_name}/#{get_plugin_parent_version};#{get_rha_plugin_name}/#{get_rha_plugin_version}"
199
+ end
200
+
201
+
202
+ def get_http_options(include_user_id = false)
203
+ headers = {}
204
+ if include_user_id && User.current
205
+ headers = {:INSIGHTS_USER_ID => user_login_to_hash(User.current.login)}
206
+ end
207
+ {:logger => Rails.logger,
208
+ :http_proxy => get_portal_http_proxy,
209
+ :user_agent => get_http_user_agent,
210
+ :headers => headers}
211
+ end
212
+
213
+ def user_login_to_hash(login)
214
+ Digest::SHA1.hexdigest(login)
215
+ end
216
+
204
217
  # TODO: move version and name methods to generic utility
205
218
  def get_rha_plugin_name
206
219
  'redhat_access'
@@ -0,0 +1,131 @@
1
+ require 'redhat_access_lib'
2
+ require 'ostruct'
3
+
4
+ module RedhatAccess
5
+ module Telemetry
6
+ class MessagingService
7
+
8
+ include RedhatAccess::Telemetry::LookUps
9
+
10
+ WEEKLY_SUMMARY_PATH = 'v1/messaging/data/weeklyinfo'
11
+
12
+ def initialize(org)
13
+ @org = org
14
+ @user_map = current_user_map
15
+ @branch_id = get_branch_id_for_org(org)
16
+ end
17
+
18
+
19
+ def all_weekly_mail_data
20
+ data = []
21
+ current_user_map.each do |key,user|
22
+ begin
23
+ user_data = weekly_summary_data(user.login)
24
+ data.push(user_data) unless user_data.nil? || user_data.total_systems = 0
25
+ rescue => e
26
+ Rails.logger.warn("Unable to get weekly email data for user")
27
+ end
28
+ end
29
+ data
30
+ end
31
+
32
+ def weekly_summary_data(username)
33
+ User.as username do
34
+ options = {:method => :GET,
35
+ :resource => WEEKLY_SUMMARY_PATH,
36
+ :params => {},
37
+ :payload => nil,
38
+ :use_subsets => true
39
+ }
40
+ json_data = http_request(options, true)
41
+ # Sample expected output: {
42
+ # "total_systems": 43,
43
+ # "checking_in_pct": 2,
44
+ # "total_actions": 22,
45
+ # "high_severity_hits": 11,
46
+ # "new_rules": [
47
+ # {
48
+ # "rule_id": "vfs_cache_pressure|VFS_CACHE_PRESSURE_TOO_HIGH",
49
+ # "summary": Rule summary,
50
+ # "description": "VFS cache pressue"
51
+ # }
52
+ # ]
53
+ # }
54
+ data = JSON.parse(json_data, object_class: OpenStruct)
55
+ info = {
56
+ user: User.current,
57
+ data: data
58
+ }
59
+ info
60
+ end
61
+ end
62
+
63
+ def get_machines
64
+ machines = get_content_hosts(@org)
65
+ if machines.empty?
66
+ machines = ['NULL_SET']
67
+ end
68
+ machines
69
+ end
70
+
71
+ def get_current_organization
72
+ @org
73
+ end
74
+
75
+ def get_auth_opts(creds)
76
+ get_ssl_options_for_org(@org, nil)
77
+ end
78
+
79
+ def get_creds
80
+ #legacy
81
+ nil
82
+ end
83
+
84
+
85
+
86
+ private
87
+
88
+ def current_user_map
89
+ map = {}
90
+ users = ::User.select do |user|
91
+ user.receives?(:insights_notifications) && user.mail_enabled? && user.allowed_organizations.include?(@org)
92
+ end
93
+ users.each do |user|
94
+ map[user_login_to_hash(user.login)] = user
95
+ end
96
+ map
97
+ end
98
+
99
+ def user_hash_to_login(user_hash)
100
+ @user_map[user_hash]
101
+ end
102
+
103
+ def http_request(options, add_user_header=false)
104
+ unless options[:params]
105
+ options[:params] = {}
106
+ end
107
+ res = new_api_client(add_user_header).call_tapi(options[:method],
108
+ URI.escape(options[:resource]),
109
+ #{:branch_id => @branch_id}.merge(options[:params]),
110
+ options[:params],
111
+ options[:payload],
112
+ nil,
113
+ options[:use_subsets])
114
+ resp_data = res[:data]
115
+ if res[:code] != 200
116
+ raise "Unable to read data code #{res[:code]}"
117
+ end
118
+ resp_data
119
+ end
120
+
121
+ def new_api_client(add_user_header)
122
+ options = get_http_options(add_user_header)
123
+ RedhatAccess::Telemetry::PortalClient.new(nil,
124
+ nil,
125
+ get_creds,
126
+ self,
127
+ options)
128
+ end
129
+ end
130
+ end
131
+ end
@@ -1,39 +1,31 @@
1
1
  require 'redhat_access_lib'
2
+ require 'forwardable'
2
3
 
3
4
  module RedhatAccess
4
5
  module Telemetry
5
6
  class PortalClient < RedHatSupportLib::TelemetryApi::Client
6
-
7
+ extend Forwardable
7
8
  include RedhatAccess::Telemetry::LookUps
9
+ UPLOAD_HOST = REDHAT_ACCESS_CONFIG[:telemetry_upload_host]
10
+ API_HOST = REDHAT_ACCESS_CONFIG[:telemetry_api_host]
11
+ UPLOAD_URL = "#{UPLOAD_HOST}/r/insights/uploads"
12
+ STRATA_URL = "#{API_HOST}/r/insights"
8
13
 
9
- def initialize(upload_url,api_url, creds, context, optional)
10
- super(upload_url,api_url, creds, optional)
11
- @context = context
12
- end
14
+ delegate [:get_machines,:get_auth_opts,:get_current_organization] => :@context
13
15
 
14
- def get_machines
15
- @context.get_machines
16
+ def initialize(upload_url, strata_url, creds, context, optional)
17
+ upload_url = UPLOAD_URL if upload_url.nil?
18
+ strata_url = STRATA_URL if strata_url.nil?
19
+ super(upload_url, strata_url, creds, optional)
20
+ @context = context
16
21
  end
17
22
 
18
23
  # Returns the branch id of the current org/account
19
24
  def get_branch_id
20
- return get_branch_id_for_org(Organization.current)
25
+ organization = get_current_organization
26
+ return get_branch_id_for_org(organization)
21
27
  end
22
28
 
23
- def get_auth_opts(creds)
24
- # #temp implementation##########################
25
- # if creds.is_a?(User) and User.current.is_a? RedhatAccess::Authentication::CertUser
26
- # opts = get_ssl_options_for_uuid(User.current.login)
27
- # elsif creds.is_a?(TelemetryProxyCredentials)
28
- # opts = {
29
- # :user => creds.username,
30
- # :password => creds.password
31
- # }
32
- # end
33
- #end temp implementation######################
34
- #TODO enable below for cert based auth
35
- return @context.get_auth_opts()
36
- end
37
29
  end
38
30
  end
39
31
  end
@@ -0,0 +1,11 @@
1
+
2
+ <% new_rules.each do |rule| %>
3
+ <tr>
4
+ <th style='text-align:left'>
5
+ <a href="<%=@server_url%>/rules/<%= rule[:rule_id] %>"><%= rule[:description]%></a>
6
+ </th>
7
+ </tr>
8
+ <tr>
9
+ <td style='text-align:left'><span style="font-size: 12px"><%= rule[:summary]%></span></td>
10
+ </tr>
11
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <table>
2
+ <%= render partial: "new_rule_list", locals: { new_rules: new_rules , server_url: server_url} %>
3
+ </table>
@@ -0,0 +1,254 @@
1
+ <body style="background-color: #687079; margin: 0; padding: 0;">
2
+ <table id="outermost-table" cellpadding="0" cellspacing="0" style="border: 0; margin: 0; padding: 0; width: 100%;">
3
+ <tbody>
4
+ <tr>
5
+ <td align="center" valign="top">
6
+ <table width="640" cellspacing="0" cellpadding="0">
7
+ <tbody>
8
+ <tr>
9
+ <td height="20"></td>
10
+ </tr>
11
+ <tr>
12
+ <td width="640" valign="top">
13
+ <div id="header">
14
+ <!-- HEADER -->
15
+ <table width="640" border="0" cellspacing="0" cellpadding="20" background="https://access.redhat.com/insightsbeta/images/email_bg.jpg">
16
+ <tbody>
17
+ <tr>
18
+ <td valign="top">
19
+ <table border="0" cellspacing="0" cellpadding="0" width="600">
20
+ <tbody>
21
+ <tr>
22
+ <td align="left" width="50%">
23
+ <img id="rh-logo" src="https://access.redhat.com/insightsbeta/images/email_logo.png" alt="Logo" style="border: 0; display: block;">
24
+ </td>
25
+ </tr>
26
+ </tbody>
27
+ </table>
28
+ <table border="0" cellspacing="0" cellpadding="0" width="600">
29
+ <tbody>
30
+ <tr>
31
+ <td height="25"></td>
32
+ </tr>
33
+ <tr>
34
+ <td align="center">
35
+ <table>
36
+ <tbody>
37
+ <tr>
38
+ <td>
39
+ <img id="insights-text" src="https://access.redhat.com/insightsbeta/images/email_rhi.png" style="min-height: auto; width: 360px;">
40
+ <div id="hbi-subject" style="margin-top: 8px; text-align: right;">
41
+ <span id="hbi-subject-text" style="color: #fff; font-family: 'Arimo',Arial,sans-serif; font-size: 14px;">
42
+ <!-- EMAIL SUBJECT -->
43
+ Weekly Report for <%= Time.now.strftime("%B %e, %Y") %>
44
+ </span>
45
+ </div>
46
+ </td>
47
+ </tr>
48
+ </tbody>
49
+ </table>
50
+ </td>
51
+ </tr>
52
+ <tr>
53
+ <td height="35"></td>
54
+ </tr>
55
+ </tbody>
56
+ </table>
57
+ </td>
58
+ </tr>
59
+ </tbody>
60
+ </table>
61
+ </div>
62
+ </td>
63
+ </tr>
64
+ <tr>
65
+ <td>
66
+ <div id="hbi-content" style="background-color: #ffffff;">
67
+ <!-- CONTENT -->
68
+ <table width="640" border="0" cellspacing="20" cellpadding="10">
69
+ <tbody>
70
+ <tr>
71
+ <td align="center" style="padding:60px 0 0;font-size:36px;color:#585858;font-weight:700">
72
+ <font face="'Arimo', Arial, sans-serif">
73
+ Your <span class="il">weekly</span> Insights report
74
+ </font>
75
+ </td>
76
+ </tr>
77
+ <tr>
78
+ <td style="font-size:16px;color:#585858;padding-bottom:40px">
79
+ <p>
80
+ <font face="'Arimo', Arial, sans-serif">
81
+ <p>
82
+ Hi <%= @user.name %>,
83
+ </p>
84
+
85
+ <p>
86
+ You currently have
87
+ <a href="<%=@server_url%>/inventory?product=all&amp;utm_source=all_systems_first_paragraph&amp;utm_medium=email&amp;utm_campaign=WeeklyEmail">
88
+ <strong><%= @data.total_systems %> systems</strong>
89
+ </a>
90
+ registered with Insights in the <%=@org.name%> organization and
91
+
92
+ <a href="<%=@server_url%>/actions?product=all&amp;initialSeverity=ERROR&amp;utm_source=high_sev_hits_first_paragraph&amp;utm_medium=email&amp;utm_campaign=WeeklyEmail">
93
+ <strong>
94
+ <%= @data.high_severity_hits %>
95
+ </strong>
96
+ </a>
97
+ high severity hits.
98
+ </p>
99
+ <% rules = @data.new_rules %>
100
+ <% if rules.length > 0 %>
101
+ <p>
102
+ <% has = rules.length > 1 ? 'have' : 'has' %>
103
+ <%= "There #{has} been #{rules.length} new rule{s} discovered since your last weekly report:" %>
104
+ </p>
105
+ <%= render partial: "new_rules_section", locals: { new_rules: rules , server_url: @server_url} %>
106
+ <% end %>
107
+ <p>
108
+ We want you to get the most out of Insights and would love to hear your
109
+ questions and comments. Feel free to email us at
110
+ <a href="mailto:insights+weekly@redhat.com">insights+weekly@redhat.com</a>,
111
+ and we'll get
112
+ back to you as soon as we can.
113
+ </p>
114
+ </font>
115
+ </p>
116
+ </td>
117
+ </tr>
118
+ </tbody>
119
+ </table>
120
+
121
+ <table width="640" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff" style="padding-bottom:40px">
122
+ <tbody>
123
+ <tr>
124
+ <td valign="top" align="left">
125
+ <table align="center" width="200">
126
+ <tbody>
127
+ <tr>
128
+ <td align="center">
129
+ <a href="<%=@server_url%>/actions?product=all&amp;utm_source=total_actions&amp;utm_medium=email&amp;utm_campaign=WeeklyEmail" style="color:#ffffff;text-decoration:none" target="_blank">
130
+ <table style="background-color:#535e6a;width:136px;height:136px;color:#fff;font-family:'Arimo',sans-serif;font-weight:700;font-size:52px;border-width:12px;border-color:#cad6e2;border-style:solid;text-align:center;border-radius:50%" align="center">
131
+ <tbody style="width:136px">
132
+ <tr>
133
+ <td style="vertical-align:middle">
134
+ <span><%= @data.total_actions %></span>
135
+ </td>
136
+ </tr>
137
+ </tbody>
138
+ </table>
139
+ </a>
140
+ </td>
141
+ </tr>
142
+ <tr>
143
+ <td align="center" style="font-family:'Arimo',Arial,sans-serif;padding-top:16px">
144
+ <a href="<%=@server_url%>/actions?product=all&amp;utm_source=total_actions&amp;utm_medium=email&amp;utm_campaign=WeeklyEmail" style="color:#535e6a;text-decoration:none" target="_blank">Total Actions</a>
145
+ </td>
146
+ </tr>
147
+ </tbody>
148
+ </table>
149
+ </td>
150
+ <td width="20"></td>
151
+ <td valign="top" align="left">
152
+ <table align="center" width="200">
153
+ <tbody>
154
+ <tr>
155
+ <td align="center">
156
+ <a href="<%=@server_url%>/actions?product=all&amp;initialSeverity=ERROR&amp;utm_source=high_sev_hits&amp;utm_medium=email&amp;utm_campaign=WeeklyEmail" style="color:#ffffff;text-decoration:none" target="_blank">
157
+ <table style="background-color:#535e6a;width:136px;height:136px;color:#fff;font-family:'Arimo',sans-serif;font-weight:700;font-size:52px;border-width:12px;border-color:#cad6e2;border-style:solid;text-align:center;border-radius:50%" align="center">
158
+ <tbody style="width:136px">
159
+ <tr>
160
+ <td style="vertical-align:middle">
161
+ <span><%= @data.high_severity_hits %></span>
162
+ </td>
163
+ </tr>
164
+ </tbody>
165
+ </table>
166
+ </a>
167
+ </td>
168
+ </tr>
169
+ <tr>
170
+ <td align="center" style="font-family:'Arimo',Arial,sans-serif;padding-top:16px">
171
+ <a href="<%=@server_url%>/actions?product=all&amp;initialSeverity=ERROR&amp;utm_source=high_sev_hits&amp;utm_medium=email&amp;utm_campaign=WeeklyEmail" style="color:#535e6a;text-decoration:none" target="_blank">High Severity Hits</a>
172
+ </td>
173
+ </tr>
174
+ </tbody>
175
+ </table>
176
+ </td>
177
+ <td width="20"></td>
178
+ <td valign="top" align="left">
179
+ <table align="center" width="200">
180
+ <tbody>
181
+ <tr>
182
+ <td align="center">
183
+ <a href="<%=@server_url%>/inventory?product=all&amp;utm_source=percent_checkin&amp;utm_medium=email&amp;utm_campaign=WeeklyEmail" style="color:#ffffff;text-decoration:none" target="_blank">
184
+ <table style="background-color:#535e6a;width:136px;height:136px;color:#fff;font-family:'Arimo',sans-serif;font-weight:700;font-size:52px;border-width:12px;border-color:#cad6e2;border-style:solid;text-align:center;border-radius:50%" align="center">
185
+ <tbody style="width:136px">
186
+ <tr>
187
+ <td style="vertical-align:middle">
188
+ <span><%= @data.checking_in_pct %></span><span style="font-size:16px;vertical-align:top">%</span>
189
+ </td>
190
+ </tr>
191
+ </tbody>
192
+ </table>
193
+ </a>
194
+ </td>
195
+ </tr>
196
+ <tr>
197
+ <td align="center" style="color:#535e6a;font-family:'Arimo',Arial,sans-serif;padding-top:16px">
198
+ <a href="<%=@server_url%>/inventory?product=all&amp;utm_source=percent_checkin&amp;utm_medium=email&amp;utm_campaign=WeeklyEmail" style="color:#535e6a;text-decoration:none" target="_blank">Systems Checking In</a>
199
+ </td>
200
+ </tr>
201
+ </tbody>
202
+ </table>
203
+ </td>
204
+ </tr>
205
+ </tbody>
206
+ </table>
207
+
208
+ </div>
209
+ </td>
210
+ </tr>
211
+ <tr>
212
+ <td>
213
+ <div id="goto">
214
+ <!-- GO TO INSIGHTS BUTTON -->
215
+ <table class="footer-table go2insights" style="background-color: #ffffff; border: 0; min-width: 640px !important; padding: 20px 0 60px; width: 640px;">
216
+ <tbody>
217
+ <tr>
218
+ <td align="center">
219
+ <a id="go2insights-button" href="<%=@server_url%>/overview?utm_source=insights_overview&amp;utm_medium=email&amp;utm_campaign=WeeklyEmail" target="_blank" style="background: #03afe8; border-radius: 4px; color: #fff; font-family: 'Arimo',Arial,sans-serif; font-size: 12px; padding: 10px 20px; text-decoration: none;">
220
+ Go To Insights
221
+ </a>
222
+ </td>
223
+ </tr>
224
+ </tbody>
225
+ </table>
226
+ </div>
227
+ </td>
228
+ </tr>
229
+ <tr>
230
+ <td>
231
+ <div id="footer">
232
+ <!-- FOOTER -->
233
+ <table class="footer-table footer" style="background-color: #fafafa; border: 0; min-width: 640px !important; padding: 40px 0 80px; width: 640px;">
234
+ <tbody>
235
+ <tr>
236
+ <td align="center">
237
+ <font face="'Arimo', Arial, sans-serif" style="font-size:12px;color:#333333">
238
+ Copyright © 2016 Red Hat, All rights reserved.<br>
239
+ <a href="<%=@email_settings_url%>" style="color:#333333" target="_blank">Update email preferences</a>
240
+ </font>
241
+ </td>
242
+ </tr>
243
+ </tbody>
244
+ </table>
245
+ </div>
246
+ </td>
247
+ </tr>
248
+ </tbody>
249
+ </table>
250
+ </td>
251
+ </tr>
252
+ </tbody>
253
+ </table>
254
+ </body>
@@ -0,0 +1,22 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # !!! PLEASE KEEP THIS SCRIPT IDEMPOTENT !!!
5
+ #
6
+ ::User.current = ::User.anonymous_admin
7
+
8
+ # Mail Notifications
9
+ notifications = [
10
+ {:name => :insights_notifications,
11
+ :description => N_('Insights reports and messages for registered hosts'),
12
+ :mailer => 'RedhatAccess::InsightsMailer',
13
+ :method => 'create',
14
+ :subscription_type => 'alert'
15
+ }
16
+ ]
17
+
18
+ notifications.each do |notification|
19
+ ::MailNotification.where(name: notification[:name]).first_or_create!(notification)
20
+ end
21
+
22
+ ::User.current = nil
@@ -14,7 +14,7 @@ module RedhatAccess
14
14
  class Engine < ::Rails::Engine
15
15
  isolate_namespace RedhatAccess
16
16
 
17
- initializer 'redhat_access.load_app_instance_data' do |app|
17
+ initializer "redhat_access.load_app_instance_data" do |app|
18
18
  unless app.root.to_s.match root.to_s
19
19
  config.paths["db/migrate"].expanded.each do |expanded_path|
20
20
  app.config.paths["db/migrate"] << expanded_path
@@ -22,11 +22,28 @@ module RedhatAccess
22
22
  end
23
23
  end
24
24
 
25
- initializer 'redhat_access.mount_engine', :after => :build_middleware_stack do |app|
25
+ initializer "redhat_access.mount_engine", :after => :build_middleware_stack do |app|
26
26
  app.routes_reloader.paths << "#{RedhatAccess::Engine.root}/config/mount_engine.rb"
27
27
  app.reload_routes!
28
28
  end
29
29
 
30
+ initializer "redhat_access.register_actions", :before => :finisher_hook do |_app|
31
+ ForemanTasks.dynflow.require!
32
+ action_paths = %W(#{RedhatAccess::Engine.root}/app/lib/actions)
33
+ ForemanTasks.dynflow.config.eager_load_paths.concat(action_paths)
34
+ end
35
+
36
+
37
+ initializer "redhat_access.initialize_insights_poller", :before => :finisher_hook do
38
+ unless ForemanTasks.dynflow.config.remote? || File.basename($PROGRAM_NAME) == 'rake' || Rails.env.test?
39
+ Rails.logger.info("Triggering..")
40
+ ForemanTasks.dynflow.config.on_init do |world|
41
+ Rails.logger.info("Init triggered.......")
42
+ ::Actions::Insights::EmailPoller.ensure_running(world)
43
+ end
44
+ end
45
+ end
46
+
30
47
  # Precompile any JS or CSS files under app/assets/
31
48
  # If requiring files from each other, list them explicitly here to avoid precompiling the same
32
49
  # content twice.
@@ -53,24 +70,6 @@ module RedhatAccess
53
70
  Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
54
71
  end
55
72
 
56
- initializer :config_csp_headers do |_app|
57
- ::SecureHeaders::Configuration.configure do |config|
58
- if config && config.csp
59
- if config.csp[:frame_src]
60
- config.csp[:frame_src] = config.csp[:frame_src] << ' *.redhat.com *.force.com'
61
- end
62
- if config.csp[:connect_src]
63
- config.csp[:connect_src] = config.csp[:connect_src] << ' *.redhat.com'
64
- end
65
- if config.csp[:script_src]
66
- config.csp[:script_src] = config.csp[:script_src] << ' *.redhat.com'
67
- end
68
- if config.csp[:img_src]
69
- config.csp[:img_src] = config.csp[:img_src] << ' *.redhat.com'
70
- end
71
- end
72
- end
73
- end
74
73
 
75
74
  config.after_initialize do
76
75
  Foreman::Plugin.register :redhat_access do
@@ -113,7 +112,7 @@ module RedhatAccess
113
112
  # permission section
114
113
  security_block :redhat_access_security do
115
114
  # Everything except logs should be available to all users
116
- permission :view_search, {:"redhat_access/search" => [:index]}, :public => true
115
+ permission :view_rh_search, {:"redhat_access/search" => [:index]}, :public => true
117
116
  permission :view_cases, {:"redhat_access/cases" => [:index, :create]}, :public => true
118
117
  permission :attachments, {:"redhat_access/attachments" => [:index, :create]}, :public => true
119
118
  permission :configuration, {:"redhat_access/configuration" => [:index]}, :public => true
@@ -1,3 +1,3 @@
1
1
  module RedhatAccess
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redhat_access
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lindani Phiri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-16 00:00:00.000000000 Z
11
+ date: 2017-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redhat_access_lib
@@ -89,17 +89,23 @@ files:
89
89
  - app/helpers/redhat_access/redhat_access_helper.rb
90
90
  - app/helpers/redhat_access/search_helper.rb
91
91
  - app/helpers/redhat_access/telemetry_configuration_helper.rb
92
+ - app/lib/actions/insights/email_poller.rb
93
+ - app/mailers/redhat_access/insights_mailer.rb
92
94
  - app/models/redhat_access/concerns/organization_extensions.rb
93
95
  - app/models/redhat_access/telemetry_configuration.rb
94
96
  - app/models/redhat_access/telemetry_proxy_credentials.rb
95
97
  - app/services/redhat_access/authentication/client_authentication.rb
96
98
  - app/services/redhat_access/telemetry/look_ups.rb
99
+ - app/services/redhat_access/telemetry/messaging_service.rb
97
100
  - app/services/redhat_access/telemetry/portal_client.rb
98
101
  - app/views/redhat_access/analytics_dashboard/configuration.html.erb
99
102
  - app/views/redhat_access/analytics_dashboard/error.html.erb
100
103
  - app/views/redhat_access/analytics_dashboard/help.html.erb
101
104
  - app/views/redhat_access/analytics_dashboard/index.html.erb
102
105
  - app/views/redhat_access/analytics_dashboard/welcome.html.erb
106
+ - app/views/redhat_access/insights_mailer/_new_rule_list.erb
107
+ - app/views/redhat_access/insights_mailer/_new_rules_section.erb
108
+ - app/views/redhat_access/insights_mailer/weekly_email.erb
103
109
  - app/views/redhat_access/redhat_access/index.html.erb
104
110
  - ca/rh_cert-api_chain.pem
105
111
  - config/config.yml.example
@@ -111,6 +117,7 @@ files:
111
117
  - db/migrate/20150319153744_create_redhat_access_telemetry_configurations.rb
112
118
  - db/migrate/20160425175501_add_email_to_telemetry_configurations.rb
113
119
  - db/seeds.d/200-update-insights-roles.rb
120
+ - db/seeds.d/201-add-insights-email-notifications.rb
114
121
  - lib/redhat_access.rb
115
122
  - lib/redhat_access/configuration.rb
116
123
  - lib/redhat_access/engine.rb