Sha256: 43c5b586c2c2050fbb908f27357ffb34f8bfa6151829fdd3ec9e04341f826766

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

class Yamaha < Oxidized::Model
  prompt /^([\w.@()-]+[#>]\s?)$/
  comment '# '

  expect /^---more---$/ do |data, re|
    send ' '
    data.sub re, ''
  end

  # non-preferred way to handle additional PW prompt
  # expect /^[\w.]+>$/ do |data|
  #  send "enable\n"
  #  send vars(:enable) + "\n"
  #  data
  # end

  expect /^Save new configuration/ do |data, re|
    send "N\n"
    data.sub re, ''
  end

  cmd :all do |cfg|
    # cfg.gsub! /\cH+\s{8}/, ''         # example how to handle pager
    # cfg.gsub! /\cH+/, ''              # example how to handle pager
    # get rid of errors for commands that don't work on some devices
    cfg.gsub! /^Error: Invalid command name$|^\s+\^$/, ''
    cfg.cut_both
  end

  cmd 'show config' do |cfg|
    cfg.gsub! /^(# Reporting Date:\s+)(.*)$/, '\1<stripped>'
    cfg
  end

  cfg :telnet do
    password /^Password:/i
  end

  cfg :telnet, :ssh do
    # preferred way to handle additional passwords
    post_login 'console lines infinity'
    post_login 'console columns  200'
    post_login 'console character ascii'
    post_login do
      if vars(:enable) == true
        cmd "administrator"
      elsif vars(:enable)
        cmd "administrator", /^[pP]assword:/
        cmd vars(:enable)
      end
    end
    pre_logout do
      cmd 'exit'
    end
    pre_logout 'exit'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oxidized-0.29.0 lib/oxidized/model/yamaha.rb