diff --git a/app/models/event_stream.rb b/app/models/event_stream.rb index fc5e8a6cbaad..d429fbe5aa70 100644 --- a/app/models/event_stream.rb +++ b/app/models/event_stream.rb @@ -27,6 +27,8 @@ class EventStream < ApplicationRecord belongs_to :middleware_server, :foreign_key => :middleware_server_id belongs_to :physical_server + belongs_to :physical_chassis, :inverse_of => :event_streams + belongs_to :physical_switch, :inverse_of => :event_streams virtual_column :group, :type => :string virtual_column :group_level, :type => :string diff --git a/app/models/physical_chassis.rb b/app/models/physical_chassis.rb index c71b150c6179..2e5823d8450c 100644 --- a/app/models/physical_chassis.rb +++ b/app/models/physical_chassis.rb @@ -1,10 +1,13 @@ class PhysicalChassis < ApplicationRecord + include EventMixin + acts_as_miq_taggable belongs_to :ext_management_system, :foreign_key => :ems_id, :inverse_of => :physical_chassis, :class_name => "ManageIQ::Providers::PhysicalInfraManager" belongs_to :physical_rack, :foreign_key => :physical_rack_id, :inverse_of => :physical_chassis + has_many :event_streams, :inverse_of => :physical_chassis, :dependent => :nullify has_many :physical_servers, :dependent => :destroy, :inverse_of => :physical_chassis has_one :computer_system, :as => :managed_entity, :dependent => :destroy, :inverse_of => false @@ -17,6 +20,10 @@ def my_zone ems ? ems.my_zone : MiqServer.my_zone end + def event_where_clause(assoc = :ems_events) + ["#{events_table_name(assoc)}.physical_chassis_id = ?", id] + end + def refresh_ems unless ext_management_system raise _("No Provider defined") diff --git a/app/models/physical_switch.rb b/app/models/physical_switch.rb index c1e12b3e33d9..a1068e32a4b7 100644 --- a/app/models/physical_switch.rb +++ b/app/models/physical_switch.rb @@ -1,10 +1,13 @@ class PhysicalSwitch < Switch + include EventMixin + belongs_to :ext_management_system, :foreign_key => :ems_id, :inverse_of => :physical_switches, :class_name => "ManageIQ::Providers::PhysicalInfraManager" has_one :asset_detail, :as => :resource, :dependent => :destroy, :inverse_of => :resource has_one :hardware, :dependent => :destroy, :foreign_key => :switch_id, :inverse_of => :physical_switch has_many :physical_network_ports, :dependent => :destroy, :foreign_key => :switch_id + has_many :event_streams, :inverse_of => :physical_switch, :dependent => :nullify def my_zone ems = ext_management_system @@ -25,6 +28,10 @@ def refresh_ems EmsRefresh.queue_refresh(ext_management_system) end + def event_where_clause(assoc = :ems_events) + ["#{events_table_name(assoc)}.physical_switch_id = ?", id] + end + def self.display_name(number = 1) n_('Physical Switch', 'Physical Switches', number) end