Class: Rubyipmi::Freeipmi::Lan
- Inherits:
-
Object
- Object
- Rubyipmi::Freeipmi::Lan
- Defined in:
- lib/rubyipmi/freeipmi/commands/lan.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#config ⇒ Object
Returns the value of attribute config.
-
#info ⇒ Object
Returns the value of attribute info.
Instance Method Summary collapse
- #dhcp? ⇒ Boolean
- #gateway ⇒ Object
- #gateway=(address) ⇒ Object
-
#initialize(opts) ⇒ Lan
constructor
A new instance of Lan.
- #ip ⇒ Object
- #ip=(address) ⇒ Object
- #mac ⇒ Object
- #netmask ⇒ Object
- #netmask=(netmask) ⇒ Object
-
#parse(landata) ⇒ Object
def vlanid=(vlan).
- #static? ⇒ Boolean
-
#validaddr?(source) ⇒ Boolean
validates that the address, returns true/false.
-
#vlanid ⇒ Object
def snmp.
Constructor Details
Instance Attribute Details
#channel ⇒ Object
Returns the value of attribute channel.
4 5 6 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 4 def channel @channel end |
#config ⇒ Object
Returns the value of attribute config.
5 6 7 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 5 def config @config end |
#info ⇒ Object
Returns the value of attribute info.
3 4 5 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 3 def info @info end |
Instance Method Details
#dhcp? ⇒ Boolean
22 23 24 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 22 def dhcp? info.fetch("ip_address_source", nil).match(/dhcp/i) != nil end |
#gateway ⇒ Object
42 43 44 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 42 def gateway info.fetch("default_gateway_ip_address", nil) end |
#gateway=(address) ⇒ Object
79 80 81 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 79 def gateway=(address) @config.setsection("Lan_Conf", "Default_Gateway_IP_Address", address) if validaddr?(address) end |
#ip ⇒ Object
30 31 32 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 30 def ip info.fetch("ip_address", nil) end |
#ip=(address) ⇒ Object
71 72 73 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 71 def ip=(address) @config.setsection("Lan_Conf", "IP_Address", address) if validaddr?(address) end |
#mac ⇒ Object
34 35 36 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 34 def mac info.fetch("mac_address", nil) end |
#netmask ⇒ Object
38 39 40 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 38 def netmask info.fetch("subnet_mask", nil) end |
#netmask=(netmask) ⇒ Object
75 76 77 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 75 def netmask=(netmask) @config.setsection("Lan_Conf", "Subnet_Mask", netmask) if validaddr?(netmask) end |
#parse(landata) ⇒ Object
def vlanid=(vlan)
end
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 87 def parse(landata) if !landata.nil? && !landata.empty? landata.lines.each do |line| # clean up the data from spaces next if line.match(/#+/) next if line.match(/Section/i) line.gsub!(/\t/, '') item = line.split(/\s+/) key = item.first.strip.downcase value = item.last.strip @info[key] = value end end @info end |
#static? ⇒ Boolean
26 27 28 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 26 def static? info.fetch("ip_address_source", nil).match(/static/i) != nil end |
#validaddr?(source) ⇒ Boolean
validates that the address, returns true/false
62 63 64 65 66 67 68 69 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 62 def validaddr?(source) valid = /^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/.match("#{source}") if valid.nil? raise "#{source} is not a valid address" else return true end end |
#vlanid ⇒ Object
def snmp
end
50 51 52 53 54 55 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 50 def vlanid info.fetch("vlan_id", nil) # some other vlan configuration that might also be useful # "vlan_id_enable" # "vlan_priority" end |