Sha256: 78ecb1af4be6b90a25ba4b1d5fa1e1c4466b02d4f54920cace6dd716ec53d72e

Contents?: true

Size: 947 Bytes

Versions: 3

Compression:

Stored size: 947 Bytes

Contents

class ZyNOSGS < Oxidized::Model
  using Refinements

  # Used in Zyxel GS1900 switches, tested with GS1900-8
  prompt /^.*# $/
  comment '! '
  expect /^--More--$/ do |data, re|
    send ' '
    data.sub re, ''
  end

  # replace all used vt100 control sequences
  expect /\e\[\??\d+(;\d+)*[A-Za-z]/ do |data, re|
    data.gsub re, ''
  end
  cmd 'show running-config' do |cfg|
    cfg.gsub! /(System Up Time:) \S+(.*)/, '\\1 <time>'
    # Remove garbage vt100 control sequences
    # Backspace 0x07 char or escape char + control chars
    cfg.gsub! /[\b]|\e\[A|\e\[2K/, ''
    # Remove empty lines
    cfg.gsub! "\n\n", "\n"
    cfg
  end

  cfg :telnet, :ssh do
    username /^(User name|.*Username):/
    password /^\r?Password:/
  end
  cfg :telnet do
    pre_logout do
      send "exit\r"
    end
  end
  cfg :ssh do
    pre_logout do
      # Yes, that GS1900 switch needs two exit !
      send "exit\n"
      send "exit\n"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
oxidized-0.31.0 lib/oxidized/model/zynosgs.rb
oxidized-0.30.1 lib/oxidized/model/zynosgs.rb
oxidized-0.30.0 lib/oxidized/model/zynosgs.rb