Sha256: f6c4cf036b06336713d04885eb2542789b528429f5264df19b21c5f6bd574187

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

class JunOS < Oxidized::Model

  comment  '# '

  def telnet
    @input.class.to_s.match /Telnet/
  end

  cmd :all do |cfg|
    # we don't need screen-scraping in ssh due to exec
    cfg = cfg.lines.to_a[1..-2].join if telnet
    cfg
  end

  cmd :secret do |cfg| 
    cfg.gsub! /encrypted-password (\S+).*/, '<secret removed>'
    cfg.gsub! /community (\S+) {/, 'community <hidden> {'
    cfg
  end

  cmd 'show configuration | display omit'

  cmd 'show version' do |cfg|
    @model = $1 if cfg.match /^Model: (\S+)/
    comment cfg
  end

  post do
    out = ''
    case @model
    when 'mx960'
      out << cmd('show chassis fabric reachability')  { |cfg| comment cfg }
    end
    out
  end

  cmd 'show chassis hardware' do |cfg|
    comment cfg
  end

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

  cfg :ssh do
    exec true  # don't run shell, run each command in exec channel
  end

  cfg :telnet, :ssh do
    post_login 'set cli screen-length 0'
    post_login 'set cli screen-width 0'
    pre_logout 'exit'
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
oxidized-0.4.1 lib/oxidized/model/junos.rb
oxidized-0.4.0 lib/oxidized/model/junos.rb
oxidized-0.3.0 lib/oxidized/model/junos.rb
oxidized-0.2.4 lib/oxidized/model/junos.rb
oxidized-0.2.3 lib/oxidized/model/junos.rb