-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Openstack CinderManager EventCatcher
Showing
8 changed files
with
109 additions
and
17 deletions.
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
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
5 changes: 5 additions & 0 deletions
5
app/models/manageiq/providers/openstack/storage_manager/cinder_manager.rb
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 |
---|---|---|
@@ -1,4 +1,9 @@ | ||
class ManageIQ::Providers::Openstack::StorageManager::CinderManager < ManageIQ::Providers::StorageManager::CinderManager | ||
require_nested :EventCatcher | ||
require_nested :Refresher | ||
include ManageIQ::Providers::Openstack::ManagerMixin | ||
|
||
def self.event_monitor_class | ||
ManageIQ::Providers::Openstack::StorageManager::CinderManager::EventCatcher | ||
end | ||
end |
20 changes: 20 additions & 0 deletions
20
app/models/manageiq/providers/openstack/storage_manager/cinder_manager/event_catcher.rb
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,20 @@ | ||
class ManageIQ::Providers::Openstack::StorageManager::CinderManager::EventCatcher < ::MiqEventCatcher | ||
require_nested :Runner | ||
|
||
def self.ems_class | ||
ManageIQ::Providers::Openstack::StorageManager::CinderManager | ||
end | ||
|
||
def self.settings_name | ||
:event_catcher_openstack_cinder | ||
end | ||
|
||
def self.all_valid_ems_in_zone | ||
require 'manageiq/providers/openstack/legacy/openstack_event_monitor' | ||
super.select do |ems| | ||
ems.sync_event_monitor_available?.tap do |available| | ||
_log.info("Event Monitor unavailable for #{ems.name}. Check log history for more details.") unless available | ||
end | ||
end | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
...odels/manageiq/providers/openstack/storage_manager/cinder_manager/event_catcher/runner.rb
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,8 @@ | ||
class ManageIQ::Providers::Openstack::StorageManager::CinderManager::EventCatcher::Runner < ManageIQ::Providers::BaseManager::EventCatcher::Runner | ||
include ManageIQ::Providers::Openstack::EventCatcherMixin | ||
|
||
def add_openstack_queue(event) | ||
event_hash = ManageIQ::Providers::Openstack::StorageManager::CinderManager::EventParser.event_to_hash(event, @cfg[:ems_id]) | ||
EmsEvent.add_queue('add', @cfg[:ems_id], event_hash) | ||
end | ||
end |
39 changes: 39 additions & 0 deletions
39
app/models/manageiq/providers/openstack/storage_manager/cinder_manager/event_parser.rb
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,39 @@ | ||
module ManageIQ::Providers::Openstack::StorageManager::CinderManager::EventParser | ||
def self.event_to_hash(event, ems_id) | ||
content = message_content(event, ems_id) | ||
event_type = content["event_type"] | ||
payload = content["payload"] || {} | ||
|
||
log_header = "ems_id: [#{ems_id}] " unless ems_id.nil? | ||
_log.debug("#{log_header}event: [#{event_type}]") if $log && $log.debug? | ||
|
||
# attributes that are common to all notifications | ||
event_hash = { | ||
:event_type => event_type, | ||
:source => "OPENSTACK", | ||
:message => payload, | ||
:timestamp => content["timestamp"], | ||
:username => content["_context_user_name"], | ||
:full_data => event, | ||
:ems_id => ems_id | ||
} | ||
|
||
event_hash[:vm_ems_ref] = payload["instance_id"] if payload.key? "instance_id" | ||
event_hash[:host_ems_ref] = payload["host"] if payload.key? "host" | ||
event_hash[:availability_zone_ems_ref] = payload["availability_zone"] if payload.key? "availability_zone" | ||
event_hash[:chain_id] = payload["reservation_id"] if payload.key? "reservation_id" | ||
event_hash | ||
end | ||
|
||
def self.message_content(event, ems_id) | ||
unless ems_id.nil? | ||
ems = ExtManagementSystem.find_by_id(ems_id) | ||
if ems.connection_configuration_by_role("amqp") | ||
if event[:content].key?("oslo.message") | ||
return JSON.parse(event[:content]["oslo.message"]) | ||
end | ||
end | ||
end | ||
event[:content] | ||
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