Sha256: 13571ea1c3f7e1a990c1f87ae642eefa6b6511f339b7339c00574abfa403c562

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

class IronWare < Oxidized::Model

  prompt /^.+[>#]\s?$/
  comment  '! '
  
  #to handle pager without enable
  #expect /^((.*)--More--(.*))$/ do |data, re|
  #  send ' '
  #  data.sub re, ''
  #end

  
  #to remove backspace (if handle pager without enable)
  #expect /^((.*)[\b](.*))$/ do |data, re|
  #  data.sub re, ''
  #end

  cmd :all do |cfg|
    cfg.each_line.to_a[1..-2].join
  end

  cmd 'show running-config' do |cfg|
    cfg = cfg.each_line.to_a[3..-1].join
    cfg
  end

  cmd 'show version' do |cfg|
    cfg.gsub! /(^((.*)system uptime(.*))$)/, '' #remove unwanted line system uptime
    comment cfg
  end

  cmd 'show chassis' do |cfg|
    cfg.gsub! "\xFF", '' # ugly hack - avoids JSON.dump utf-8 breakage on 1.9..
    cfg.gsub! /(^((.*)Current temp(.*))$)/, '' #remove unwanted lines current temperature
    comment cfg
  end
  
  cmd 'show flash' do |cfg|
    comment cfg
  end
  
  cmd 'show module' do |cfg|
    comment cfg
  end

  cfg :telnet do
    username /^Username:/
    password /^Password:/
  end

  #handle pager with enable
  cfg :telnet, :ssh do
    if vars :enable
      post_login do
        send "enable\n"
        send vars(:enable) + "\n"
      end
    end
    post_login 'skip-page-display'
    post_login 'terminal length 0'
    pre_logout 'logout'
    pre_logout 'exit'
    pre_logout 'exit'
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
oxidized-0.7.1 lib/oxidized/model/ironware.rb
oxidized-0.7.0 lib/oxidized/model/ironware.rb
oxidized-0.6.0 lib/oxidized/model/ironware.rb