-
Notifications
You must be signed in to change notification settings - Fork 897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move event filters into the database. #3636
Merged
gmcculloug
merged 8 commits into
ManageIQ:master
from
lfu:filtered_provider_events_3273
Aug 14, 2015
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c32d39d
Add migration for BlacklistedEvent.
lfu fa6c283
Add class BlacklistedEvent.
lfu 6a2affe
Move filtered_events section from event_handling.tmp.yml into a class…
lfu a9dbad2
Add has_many relationship from provider to blacklisted_events with de…
lfu de53bf3
Remove existing filter logic from ems_event.rb.
lfu af144d9
Add spec for BlacklistedEvent.
lfu f38e1f9
Changes to sync the blacklisted events.
lfu de7aa4e
Add migration to move existing user added filtered_events in Configur…
lfu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
class BlacklistedEvent < ActiveRecord::Base | ||
belongs_to :ext_management_system, :foreign_key => "ems_id" | ||
|
||
default_value_for :enabled, true | ||
after_save :queue_sync_blacklisted_event_names | ||
after_destroy :queue_sync_blacklisted_event_names, :audit_deletion | ||
after_create :audit_creation | ||
|
||
def audit_deletion | ||
$audit_log.info("Blacklisted event [#{event_name}] for provider [#{provider_model}] with ID [#{ems_id}] has been deleted by user [#{self.class.current_userid}]") | ||
end | ||
|
||
def audit_creation | ||
$audit_log.info("Creating blacklisted event [#{event_name}] for provider [#{provider_model}] with ID [#{ems_id}] by user [#{self.class.current_userid}]") | ||
end | ||
|
||
def enabled=(value) | ||
return if enabled == value | ||
|
||
super | ||
$audit_log.info("Blacklisted event [#{event_name}] for provider [#{provider_model}] with ID [#{ems_id}] had enabled changed to #{value} by user [#{self.class.current_userid}]") | ||
end | ||
|
||
def self.seed | ||
MiqRegion.my_region.lock do | ||
ExtManagementSystem.descendants.each do |ems| | ||
missing_events = ems.default_blacklisted_event_names - where(:provider_model => ems.name, :ems_id => nil).pluck(:event_name) | ||
create(missing_events.collect { |e| {:event_name => e, :provider_model => ems.name, :system => true} }) | ||
end | ||
end | ||
end | ||
|
||
def self.current_userid | ||
User.current_userid || 'system' | ||
end | ||
|
||
def queue_sync_blacklisted_event_names | ||
# notify MiqServer to sync with the blacklisted events | ||
servers = MiqRegion.my_region.active_miq_servers | ||
return if servers.blank? | ||
_log.info("Queueing sync_blacklisted_event_names for [#{servers.length}] active_miq_servers, ids: #{servers.collect(&:id)}") | ||
|
||
servers.each do |s| | ||
MiqQueue.put( | ||
:class_name => "MiqServer", | ||
:instance_id => s.id, | ||
:method_name => "sync_blacklisted_event_names", | ||
:server_guid => s.guid, | ||
:priority => MiqQueue::HIGH_PRIORITY, | ||
:queue_name => 'miq_server' | ||
) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class CreateBlacklistedEvents < ActiveRecord::Migration | ||
def change | ||
create_table :blacklisted_events do |t| | ||
t.string :event_name | ||
t.string :provider_model | ||
t.bigint :ems_id | ||
t.boolean :system | ||
t.boolean :enabled | ||
t.timestamps | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has added a bunch of noise to the migration specs...