Class: Node
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Node
- Defined in:
- lib/antfarm/node.rb
Overview
Node class that wraps the nodes table in the ANTFARM database.
-
has many layer 2 interfaces
-
has many layer 3 interfaces through layer 2 interfaces
Class Method Summary collapse
-
.node_named(name) ⇒ Object
Find and return the first node found with the given name.
-
.nodes_of_device_type(device_type) ⇒ Object
Find and return all the nodes found that are the given type.
Instance Method Summary collapse
Class Method Details
.node_named(name) ⇒ Object
Find and return the first node found with the given name.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/antfarm/node.rb', line 37 def self.node_named(name) unless name raise(ArgumentError, "nil argument supplied", caller) end node = self.find_all_by_name(name) case node.length when 0 logger.warn("Node: did not find an existing node with given name.") return nil else logger.info("Node: found existing nodes with given name.") return node[0] end end |
.nodes_of_device_type(device_type) ⇒ Object
Find and return all the nodes found that are the given type.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/antfarm/node.rb', line 55 def self.nodes_of_device_type(device_type) unless device_type raise(ArgumentError, "nil argument supplied", caller) end nodes = self.find_all_by_device_type(device_type) case nodes.length when 0 logger.warn("Node: did not find any existing nodes of given device type.") return nil else logger.info("Node: found existing nodes of given device type.") return nodes end end |
Instance Method Details
#to_label ⇒ Object
72 73 74 |
# File 'lib/antfarm/node.rb', line 72 def to_label return self end |