Skip to content

Commit

Permalink
Connecting physical switch to computer systems
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasgabriel committed Jul 25, 2018
1 parent b64387c commit d7f8b55
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${file}"
}
]
}
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 d7f8b55

Please sign in to comment.