foreman-tasks 8.2.1 → 8.3.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.
- checksums.yaml +4 -4
- data/app/lib/actions/check_long_running_tasks.rb +6 -8
- data/app/lib/actions/deliver_long_running_tasks_notification.rb +0 -4
- data/app/lib/actions/observable_action.rb +11 -2
- data/app/models/foreman_tasks/concerns/user_extensions.rb +0 -19
- data/db/seeds.d/95-mail_notifications.rb +0 -14
- data/lib/foreman_tasks/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ea98197d16aef3c4ca8f16c10b9533f7e89e916c8cefffed1e8523966dc85fa
|
4
|
+
data.tar.gz: fee12ffd69d32683f091f49c1362df778523a29bba97d411931c0608cedd19cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbeafbdf22b249957160385253f62b1f901cd4faca182c47fe5f637a375f55e98b57d7fe28ab814bf3f5fadb11aac50133b7f291e6371e2e1a8896c136410c4e
|
7
|
+
data.tar.gz: 946b98f863337862dfbd3b1cf6bd421b139836cd2920368e5642e50aed3a7ba1118bed49d481ee3e2ef208acd921275bcc3ef4c5b7316b1199b894cecbb715e2
|
@@ -8,10 +8,12 @@ module Actions
|
|
8
8
|
def plan
|
9
9
|
time = Time.now.utc
|
10
10
|
cutoff = time - INTERVAL
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
.where(
|
11
|
+
notification = ::ForemanTasks::TasksMailNotification.find_by(name: "long_running_tasks")
|
12
|
+
org_admin_role = Role.find_by(name: 'Organization admin')
|
13
|
+
users = User.left_joins(:roles)
|
14
|
+
.where(id: UserMailNotification.where(mail_notification_id: notification.id).select(:role_id))
|
15
|
+
.or(User.where(admin: true))
|
16
|
+
.or(User.where(id: UserRole.where(id: [org_admin_role.id] + org_admin_role.cloned_role_ids).select(:owner_id)))
|
15
17
|
|
16
18
|
query = "state ^ (#{STATES.join(', ')}) AND state_updated_at <= \"#{cutoff}\""
|
17
19
|
users.each do |user|
|
@@ -39,9 +41,5 @@ module Actions
|
|
39
41
|
def humanized_name
|
40
42
|
_('Check for long running tasks')
|
41
43
|
end
|
42
|
-
|
43
|
-
def rescue_strategy_for_self
|
44
|
-
Dynflow::Action::Rescue::Skip
|
45
|
-
end
|
46
44
|
end
|
47
45
|
end
|
@@ -36,7 +36,7 @@ module Actions
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def event_names
|
39
|
-
[event_name_base + '_' + event_name_suffix(
|
39
|
+
[:success, :failure].map { |suffix| event_name_base + '_' + event_name_suffix(suffix) }
|
40
40
|
end
|
41
41
|
|
42
42
|
def namespaced_event_names
|
@@ -51,7 +51,16 @@ module Actions
|
|
51
51
|
def self.included(base)
|
52
52
|
base.extend ClassMethods
|
53
53
|
base.include ::Foreman::Observable
|
54
|
-
base.execution_plan_hooks.use :
|
54
|
+
base.execution_plan_hooks.use :emit_event_success, :on => :success
|
55
|
+
base.execution_plan_hooks.use :emit_event_failure, :on => :failure
|
56
|
+
end
|
57
|
+
|
58
|
+
def emit_event_success(execution_plan)
|
59
|
+
emit_event(execution_plan, :success)
|
60
|
+
end
|
61
|
+
|
62
|
+
def emit_event_failure(execution_plan)
|
63
|
+
emit_event(execution_plan, :failure)
|
55
64
|
end
|
56
65
|
|
57
66
|
def emit_event(execution_plan, hook = :success)
|
@@ -8,25 +8,6 @@ module ForemanTasks
|
|
8
8
|
has_many :tasks, :dependent => :nullify,
|
9
9
|
:class_name => ::ForemanTasks::Task.name
|
10
10
|
# rubocop:enable Rails/ReflectionClassName
|
11
|
-
|
12
|
-
before_validation :attach_task_mail_notifications, on: :create
|
13
|
-
end
|
14
|
-
|
15
|
-
def attach_task_mail_notifications
|
16
|
-
return if ::ForemanSeeder.is_seeding
|
17
|
-
|
18
|
-
org_admin_role = Role.find_by(name: 'Organization admin')
|
19
|
-
admin_by_role = org_admin_role &&
|
20
|
-
(roles.map(&:id) & ([org_admin_role.id] + org_admin_role.cloned_role_ids)).any?
|
21
|
-
|
22
|
-
return unless admin || admin_by_role
|
23
|
-
|
24
|
-
notification = MailNotification.find_by(name: 'long_running_tasks')
|
25
|
-
return if notification.nil?
|
26
|
-
|
27
|
-
if user_mail_notifications.none? { |n| n.mail_notification_id == notification.id }
|
28
|
-
user_mail_notifications.build(mail_notification_id: notification.id, interval: 'Subscribe')
|
29
|
-
end
|
30
11
|
end
|
31
12
|
end
|
32
13
|
end
|
@@ -20,19 +20,5 @@ notifications.each do |notification|
|
|
20
20
|
raise ::Foreman::Exception.new(N_("Unable to create mail notification: %s"),
|
21
21
|
SeedHelper.format_errors(created_notification))
|
22
22
|
end
|
23
|
-
|
24
|
-
org_admin_role = Role.find_by(name: 'Organization admin')
|
25
|
-
|
26
|
-
users = User.left_joins(:roles)
|
27
|
-
.joins(:auth_source)
|
28
|
-
.where(admin: true)
|
29
|
-
.or(User.where(id: UserRole.where(id: [org_admin_role.id] + org_admin_role.cloned_role_ids).select(:owner_id)))
|
30
|
-
.where.not(auth_source: { name: 'Hidden' })
|
31
|
-
users.each do |user|
|
32
|
-
mail = UserMailNotification.create(mail_notification_id: created_notification.id, user_id: user.id, interval: 'Subscribe')
|
33
|
-
if mail.nil? || mail.errors.any?
|
34
|
-
raise ::Foreman::Exception.new(N_("Unable to enable mail notification to user '%s': %s"), user.login, SeedHelper.format_errors(mail))
|
35
|
-
end
|
36
|
-
end
|
37
23
|
end
|
38
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman-tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.
|
4
|
+
version: 8.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11
|
11
|
+
date: 2023-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dynflow
|