Class: Layer2Interface
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Layer2Interface
- Defined in:
- lib/antfarm/layer2_interface.rb
Overview
Layer2Interface class that wraps the layer2_interfaces table in the ANTFARM database.
-
has many layer 3 interfaces
-
has one ethernet interface
-
belongs to a node
The node_name and node_device_type attributes are only applicable when an existing node is not specified.
Instance Attribute Summary collapse
-
#node_device_type ⇒ Object
writeonly
Device type of the node automatically created for this layer 2 interface.
-
#node_name ⇒ Object
writeonly
Name of the node automatically created for this layer 2 interface.
Class Method Summary collapse
-
.interface_addressed(mac_addr_str) ⇒ Object
Find and return the layer 2 interface with the given ethernet address.
Instance Method Summary collapse
-
#to_label ⇒ Object
This is for ActiveScaffold.
Instance Attribute Details
#node_device_type=(value) ⇒ Object (writeonly)
Device type of the node automatically created for this layer 2 interface.
45 46 47 |
# File 'lib/antfarm/layer2_interface.rb', line 45 def node_device_type=(value) @node_device_type = value end |
#node_name=(value) ⇒ Object (writeonly)
Name of the node automatically created for this layer 2 interface.
41 42 43 |
# File 'lib/antfarm/layer2_interface.rb', line 41 def node_name=(value) @node_name = value end |
Class Method Details
.interface_addressed(mac_addr_str) ⇒ Object
Find and return the layer 2 interface with the given ethernet address.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/antfarm/layer2_interface.rb', line 51 def self.interface_addressed(mac_addr_str) unless mac_addr_str raise(ArgumentError, "nil argument supplied", caller) end eth_ifs = EthernetInterface.find(:all) for eth_if in eth_ifs if mac_addr_str == eth_if.address return Layer2Interface.find(eth_if.id) end end return nil end |
Instance Method Details
#to_label ⇒ Object
This is for ActiveScaffold
67 68 69 70 |
# File 'lib/antfarm/layer2_interface.rb', line 67 def to_label #:nodoc: return "#{id} -- #{ethernet_interface.address}" if ethernet_interface return "#{id} -- Generic Layer2 Interface" end |