-
Notifications
You must be signed in to change notification settings - Fork 897
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding connection b/w physical servers and switches
- Loading branch information
1 parent
85b25a1
commit 7678a32
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,18 @@ | ||
class PhysicalNetworkPort < ApplicationRecord | ||
belongs_to :guest_device | ||
belongs_to :physical_switch | ||
|
||
# | ||
# Get the peer port connected. | ||
# A connected port has the mac address of the pair in its | ||
# peer_mac_address field. | ||
# | ||
# @return [PhysicalNetworkPort] - the connected port | ||
# | ||
def connected_port | ||
port = PhysicalNetworkPort.find_by('peer_mac_address IS NOT NULL AND peer_mac_address = ?', mac_address) | ||
port = PhysicalNetworkPort.find_by('mac_address IS NOT NULL AND mac_address = ?', peer_mac_address) if port.blank? | ||
|
||
port | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters