Sha256: 3263a562605a6e541eda3e71e726a2fc8629c7d2a6f218aac002be71fb164ce3

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

class OpenGear < Oxidized::Model
  using Refinements

  comment '# '

  prompt /^(\$\s)$/

  cmd :secret do |cfg|
    cfg.gsub!(/password (\S+)/, 'password <secret removed>')
    cfg.gsub!(/community (\S+)/, 'community <secret removed>')
    cfg.gsub!(/community=(\S+)/, 'community=<secret removed>')
    cfg.gsub!(/private_key=(\S+)/, 'private_key=<secret removed>')
    cfg.gsub!(/ key=(\S+)/, ' key=<secret removed>')
    cfg.gsub!(/hashed_password=(\S+)/, 'hashed_password=<secret removed>')
    cfg
  end

  cmd('cat /etc/version') { |cfg| comment cfg }

  # newer opengear firmware versions
  cmd 'ogdeviceinfo -r' do |cfg|
    comment cfg unless cfg.include? "ogdeviceinfo: command not found"
  end

  cmd 'config export' do |cfg|
    unless cfg.include? "usage: config"
      out = ''
      cfg.each_line do |line|
        out << line
      end
      out
    end
  end

  # older opengear firmware versions
  cmd 'showserial' do |cfg|
    unless cfg.include? "showserial: command not found"
      cfg.gsub! /^/, 'Serial Number: '
      comment cfg
    end
  end

  cmd 'config -g config' do |cfg|
    unless cfg.include? "config: error: argument"
      out = ''
      cfg.each_line do |line|
        out << line
      end
      out
    end
  end

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

Version data entries

3 entries across 3 versions & 1 rubygems

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