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
#initialize(opts) ⇒ Lan
Returns a new instance of Lan.
9 10 11 12 13 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 9 def initialize(opts) @config = Rubyipmi::Freeipmi::BmcConfig.new(opts) @info = {} @channel = 2 end |
Instance Attribute Details
#channel ⇒ Object
Returns the value of attribute channel.
6 7 8 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 6 def channel @channel end |
#config ⇒ Object
Returns the value of attribute config.
7 8 9 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 7 def config @config end |
#info ⇒ Object
Returns the value of attribute info.
5 6 7 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 5 def info @info end |
Instance Method Details
#dhcp? ⇒ Boolean
24 25 26 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 24 def dhcp? info.fetch("ip_address_source",nil).match(/dhcp/i) != nil end |
#gateway ⇒ Object
44 45 46 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 44 def gateway info.fetch("default_gateway_ip_address", nil) end |
#gateway=(address) ⇒ Object
81 82 83 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 81 def gateway=(address) @config.setsection("Lan_Conf", "Default_Gateway_IP_Address", address) if validaddr?(address) end |
#ip ⇒ Object
32 33 34 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 32 def ip info.fetch("ip_address", nil) end |
#ip=(address) ⇒ Object
73 74 75 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 73 def ip=(address) @config.setsection("Lan_Conf", "IP_Address", address) if validaddr?(address) end |
#mac ⇒ Object
36 37 38 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 36 def mac info.fetch("mac_address", nil) end |
#netmask ⇒ Object
40 41 42 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 40 def netmask info.fetch("subnet_mask", nil) end |
#netmask=(netmask) ⇒ Object
77 78 79 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 77 def netmask=(netmask) @config.setsection("Lan_Conf", "Subnet_Mask", netmask) if validaddr?(netmask) end |
#parse(landata) ⇒ Object
def vlanid=(vlan)
end
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 89 def parse(landata) if ! landata.nil? and ! 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
28 29 30 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 28 def static? info.fetch("ip_address_source",nil).match(/static/i) != nil end |
#validaddr?(source) ⇒ Boolean
validates that the address, returns true/false
64 65 66 67 68 69 70 71 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 64 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
52 53 54 55 56 57 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 52 def vlanid info.fetch("vlan_id", nil) # some other vlan configuration that might also be useful # "vlan_id_enable" # "vlan_priority" end |