Sha256: 1085ba45ac5095a5f543192a1feb4a35df4d979c75105cefb925f8f7a77f02ff

Contents?: true

Size: 1.49 KB

Versions: 6

Compression:

Stored size: 1.49 KB

Contents

class PowerConnect < Oxidized::Model

  prompt /^([\w\s.@-]+[#>]\s?)$/ # allow spaces in hostname..dell does not limit it.. #

  comment  '! '

  expect /^\s*--More--\s+.*$/ do |data, re|
     send ' '
     data.sub re, ''
  end

  cmd :all do |cfg|
    cfg.each_line.to_a[1..-3].join
  end

  cmd 'show version' do |cfg|
    cfg = cfg.split("\n").select { |line| not line[/Up\sTime/] }
    comment cfg.join("\n") + "\n"
  end

  cmd 'show system' do |cfg|
    @model = $1 if cfg.match /Power[C|c]onnect (\d{4})[P|F]?/
    clean cfg
  end

  cmd 'show running-config'

  cfg :telnet do
    username /^User( Name)?:/
    password /^\r?Password:/
  end

  cfg :telnet, :ssh do
    if vars :enable
      post_login do
        send "enable\n"
        send vars(:enable) + "\n"
      end
    end

    post_login "terminal datadump"
    post_login "terminal length 0"
    pre_logout "logout"
    pre_logout "exit"
    
  end

  def clean cfg
    out = []
    skip_block = false
    cfg.each_line do |line|
      if line.match /Up\sTime|Temperature|Power Supplies/i
        # For 34xx, 35xx, 54xx, 55xx, 62xx and 8024F we should skip this block (terminated by a blank line)
        skip_block = true if @model =~ /^(34|35)(24|48)$|^(54|55)(24|48)$|^(62)(24|48)$|^8024$/
      end
      # If we have lines to skip do this until we reach and empty line
      if skip_block
        skip_block = false if /\S/ !~ line
        next
      end
      out << line.strip
    end
    out = comment out.join "\n"
    out << "\n"
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
oxidized-0.8.1 lib/oxidized/model/powerconnect.rb
oxidized-0.8.0 lib/oxidized/model/powerconnect.rb
oxidized-0.7.2 lib/oxidized/model/powerconnect.rb
oxidized-0.7.1 lib/oxidized/model/powerconnect.rb
oxidized-0.7.0 lib/oxidized/model/powerconnect.rb
oxidized-0.6.0 lib/oxidized/model/powerconnect.rb