Skip to content

Commit

Permalink
Merge pull request #17735 from douglasgabriel/cnt_comp_sys
Browse files Browse the repository at this point in the history
Connecting physical switch to computer systems
  • Loading branch information
agrare committed Jul 26, 2018
2 parents 8347ff3 + 4a7a121 commit 9da1017
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
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

0 comments on commit 9da1017

Please sign in to comment.