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.
Constructor Details
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
25 26 27 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 25 def dhcp? info.fetch("ip_address_source",nil).match(/dhcp/i) != nil end |
#gateway ⇒ Object
45 46 47 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 45 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
33 34 35 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 33 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
37 38 39 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 37 def mac info.fetch("mac_address", nil) end |
#netmask ⇒ Object
41 42 43 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 41 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 102 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 87 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 return @info end |
#static? ⇒ Boolean
29 30 31 |
# File 'lib/rubyipmi/freeipmi/commands/lan.rb', line 29 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 |