class Rubyipmi::Freeipmi::Lan

Attributes

channel[RW]
config[RW]
info[RW]

Public Class Methods

new(opts) click to toggle source
# File lib/rubyipmi/freeipmi/commands/lan.rb, line 9
def initialize(opts)
  @config = Rubyipmi::Freeipmi::BmcConfig.new(opts)
  @info = {}
  @channel = 2
end

Public Instance Methods

dhcp?() click to toggle source
# File lib/rubyipmi/freeipmi/commands/lan.rb, line 24
def dhcp?
  info.fetch("ip_address_source",nil).match(/dhcp/i) != nil
end
gateway() click to toggle source
# File lib/rubyipmi/freeipmi/commands/lan.rb, line 44
def gateway
  info.fetch("default_gateway_ip_address", nil)
end
gateway=(address) click to toggle source
# 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() click to toggle source
# File lib/rubyipmi/freeipmi/commands/lan.rb, line 32
def ip
  info.fetch("ip_address", nil)
end
ip=(address) click to toggle source
# File lib/rubyipmi/freeipmi/commands/lan.rb, line 73
def ip=(address)
  @config.setsection("Lan_Conf", "IP_Address", address) if validaddr?(address)
end
mac() click to toggle source
# File lib/rubyipmi/freeipmi/commands/lan.rb, line 36
def mac
  info.fetch("mac_address", nil)
end
netmask() click to toggle source
# File lib/rubyipmi/freeipmi/commands/lan.rb, line 40
def netmask
  info.fetch("subnet_mask", nil)
end
netmask=(netmask) click to toggle source
# 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) click to toggle source

def vlanid=(vlan)

end

# 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?() click to toggle source
# File lib/rubyipmi/freeipmi/commands/lan.rb, line 28
def static?
  info.fetch("ip_address_source",nil).match(/static/i) != nil
end
validaddr?(source) click to toggle source

validates that the address, returns true/false

# 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() click to toggle source

def snmp

end

# 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