Sha256: 773d4db7804b51b2f0cc45207fa7532e26a54a058a721fc1269547247b36c1ae

Contents?: true

Size: 1.98 KB

Versions: 4

Compression:

Stored size: 1.98 KB

Contents

module Rubyipmi::Freeipmi

  class Lan

    attr_accessor :info
    attr_accessor :channel
    attr_accessor :config

    def initialize(opts)
      @config = Rubyipmi::Freeipmi::BmcConfig.new(opts)

      @info = {}
      @channel = 2
    end

    def info
      if @info.length < 1
        parse(@config.section("Lan_Conf"))
      else
        @info
      end
    end

    def dhcp?
      if @info.length < 1
        parse(@config.section("Lan_Conf"))
      end
      @info["ip_address_source"].match(/dhcp/i) != nil
    end

    def static?
      if @info.length < 1
        parse(@config.section("Lan_Conf"))
      end
      @info["ip_address_source"].match(/static/i) != nil
    end

    def ip
      if @info.length < 1
        parse(@config.section("Lan_Conf"))
      end
      @info["ip_address"]
    end

    def mac
      if @info.length < 1
        parse(@config.section("Lan_Conf"))
      end
      @info["mac_address"]
    end

    def netmask
      if @info.length < 1
        parse(@config.section("Lan_Conf"))
      end
      @info["subnet_mask"]
    end

    def gateway
      if @info.length < 1
        parse(@config.section("Lan_Conf"))
      end
      @info["default_gateway_ip_address"]
    end

  #  def snmp
  #
  #  end

  #  def vlanid
  #
  #  end

  #  def snmp=(community)
  #
  #  end

    def ip=(address)
      @config.setsection("Lan_Conf", "IP_Address", address)
    end

    def netmask=(netmask)
      @config.setsection("Lan_Conf", "Subnet_Mask", netmask)
    end

    def gateway=(address)
      @config.setsection("Lan_Conf", "Default_Gateway_IP_Address", address)
    end

  #  def vlanid=(vlan)
  #
  #  end

    def parse(landata)
      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
      return @info
    end
  end
end


Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubyipmi-0.6.0 lib/rubyipmi/freeipmi/commands/lan.rb
rubyipmi-0.5.1 lib/rubyipmi/freeipmi/commands/lan.rb
rubyipmi-0.5.0 lib/rubyipmi/freeipmi/commands/lan.rb
rubyipmi-0.4.0 lib/rubyipmi/freeipmi/commands/lan.rb