Sha256: d9b2495d3e8f2b9db2eecd3eabdb0c58c1021d7de5bc39257cafc472b5dad2dd

Contents?: true

Size: 1.13 KB

Versions: 8

Compression:

Stored size: 1.13 KB

Contents

class JunOS < Oxidized::Model

  comment  '# '

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

  cmd :all do |cfg|
    cfg = cfg.lines.to_a[1..-2].join if screenscrape
    cfg.lines.map { |line| line.rstrip }.join("\n") + "\n"
  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 }
    when /^(ex22|ex33|ex4|ex8|qfx)/
      out << cmd('show virtual-chassis') { |cfg| comment cfg }
    end
    out
  end

  cmd('show chassis hardware') { |cfg| comment cfg }

  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

8 entries across 8 versions & 1 rubygems

Version Path
oxidized-0.19.0 lib/oxidized/model/junos.rb
oxidized-0.18.0 lib/oxidized/model/junos.rb
oxidized-0.17.0 lib/oxidized/model/junos.rb
oxidized-0.16.3 lib/oxidized/model/junos.rb
oxidized-0.16.2 lib/oxidized/model/junos.rb
oxidized-0.16.1 lib/oxidized/model/junos.rb
oxidized-0.16.0 lib/oxidized/model/junos.rb
oxidized-0.15.0 lib/oxidized/model/junos.rb