Skip to content
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

Connecting physical switch to computer systems #17735

Merged
merged 1 commit into from
Jul 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions app/models/guest_device.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
class GuestDevice < ApplicationRecord
belongs_to :hardware

has_one :vm_or_template, :through => :hardware
has_one :vm, :through => :hardware
has_one :miq_template, :through => :hardware
has_one :host, :through => :hardware
has_one :vm_or_template, :through => :hardware
has_one :vm, :through => :hardware
has_one :miq_template, :through => :hardware
has_one :host, :through => :hardware
has_one :computer_system, :through => :hardware

belongs_to :switch # pNICs link to one switch
belongs_to :lan # vNICs link to one lan
Expand Down
2 changes: 2 additions & 0 deletions app/models/physical_network_port.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ class PhysicalNetworkPort < ApplicationRecord

has_one :connected_port, :foreign_key => "connected_port_uid", :primary_key => "uid_ems", :class_name => "PhysicalNetworkPort", :dependent => :nullify, :inverse_of => :connected_port
has_one :connected_physical_switch, :through => :connected_port, :source => :physical_switch
has_one :computer_system, :through => :guest_device
has_one :connected_computer_system, :through => :connected_port, :source => :computer_system

alias_attribute :name, :port_name
end
9 changes: 9 additions & 0 deletions app/models/physical_switch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ class PhysicalSwitch < Switch
has_many :physical_network_ports, :dependent => :destroy, :foreign_key => :switch_id
has_many :event_streams, :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_attribute :physical_servers, :connected_physical_servers

def my_zone
ems = ext_management_system
ems ? ems.my_zone : MiqServer.my_zone
Expand Down