Class: PowerConnect

Inherits:
Oxidized::Model show all
Defined in:
lib/oxidized/model/powerconnect.rb

Instance Attribute Summary

Attributes inherited from Oxidized::Model

#input, #node

Instance Method Summary collapse

Methods inherited from Oxidized::Model

cfg, #cfg, cfgs, #cmd, cmd, cmds, comment, #comment, expect, #expect, expects, #expects, #get, inherited, #output, post, pre, procs, prompt, #prompt, #send

Methods included from Oxidized::Config::Vars

#vars

Instance Method Details

#clean(cfg) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/oxidized/model/powerconnect.rb', line 53

def clean cfg
  out = []
  skip_blocks = 0
  cfg.each_line do |line|
    # If this is a stackable switch we should skip this block of information
    if (line.match /Up\sTime|Temperature|Power Suppl(ies|y)|Fans/i and @stackable == true)
      skip_blocks = 1
      # Some switches have another empty line. This is identified by this line having a colon
      skip_blocks = 2 if line.match /:/
    end
    # If we have lines to skip do this until we reach and empty line
    if skip_blocks > 0
      skip_blocks -= 1 if /\S/ !~ line
      next
    end
    out << line.strip
  end
  out = comment out.join "\n"
  out << "\n"
end