forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphysical_switch.rb
40 lines (31 loc) · 1.64 KB
/
physical_switch.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class PhysicalSwitch < Switch
include SupportsFeatureMixin
include EventMixin
include EmsRefreshMixin
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
# TODO: Deprecate event_streams if it makes sense, find callers, and change to use ems_events. Even though event_streams
# have only ever been ems_events in this model, we shouldn't rely on that, so callers should use ems_events.
has_many :event_streams, :inverse_of => :physical_switch, :dependent => :nullify
has_many :ems_events, :inverse_of => :physical_switch, :dependent => :nullify
has_many :connected_components, :through => :physical_network_ports, :source => :connected_computer_system
has_many :connected_physical_servers,
:source_type => "PhysicalServer",
:through => :connected_components,
:source => :managed_entity
alias_method :physical_servers, :connected_physical_servers
alias_method :physical_servers=, :connected_physical_servers=
def my_zone
ems = ext_management_system
ems ? ems.my_zone : MiqServer.my_zone
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
end