diff options
Diffstat (limited to 'lib/oxidized')
-rw-r--r-- | lib/oxidized/config/vars.rb | 1 | ||||
-rw-r--r-- | lib/oxidized/model/asa.rb | 48 | ||||
-rw-r--r-- | lib/oxidized/model/fabricos.rb | 21 | ||||
-rw-r--r-- | lib/oxidized/model/vyatta.rb | 27 | ||||
-rw-r--r-- | lib/oxidized/string.rb | 4 |
5 files changed, 99 insertions, 2 deletions
diff --git a/lib/oxidized/config/vars.rb b/lib/oxidized/config/vars.rb index 40e4808..1fd81ef 100644 --- a/lib/oxidized/config/vars.rb +++ b/lib/oxidized/config/vars.rb @@ -5,5 +5,6 @@ module Oxidized::Config::Vars r = @node.vars[name] unless @node.vars.nil? r ||= Oxidized::CFG.groups[@node.group].vars[name.to_s] if Oxidized::CFG.groups.has_key?(@node.group) r ||= Oxidized::CFG.vars[name.to_s] if Oxidized::CFG.vars.has_key?(name) + r end end diff --git a/lib/oxidized/model/asa.rb b/lib/oxidized/model/asa.rb new file mode 100644 index 0000000..3ee4e2d --- /dev/null +++ b/lib/oxidized/model/asa.rb @@ -0,0 +1,48 @@ +class ASA < Oxidized::Model + + # Cisco ASA model # + # Only SSH supported for the sake of security + + prompt /^\r*([\w]+[#>]\s?)$/ + comment '! ' + + cmd :all do |cfg| + cfg.each_line.to_a[1..-2].join + end + + cmd :secret do |cfg| + cfg.gsub! /enable password (\S+) (.*)/, 'enable password <secret hidden> \2' + cfg.gsub! /username (\S+) password (\S+) (.*)/, 'username \1 password <secret hidden> \3' + cfg + end + + cmd 'show clock' do |cfg| + comment cfg + end + + cmd 'show version' do |cfg| + comment cfg + end + + cmd 'show running-config' do |cfg| + cfg = cfg.each_line.to_a[3..-1].join + cfg.gsub! /^: [^\n]*\n/, '' + cfg + end + + cmd 'show inventory' do |cfg| + comment cfg + end + + cfg :ssh do + if vars :enable + post_login do + send "enable\n" + send vars(:enable) + "\n" + end + end + post_login 'terminal pager 0' + pre_logout 'exit' + end + +end diff --git a/lib/oxidized/model/fabricos.rb b/lib/oxidized/model/fabricos.rb new file mode 100644 index 0000000..7ab9fd5 --- /dev/null +++ b/lib/oxidized/model/fabricos.rb @@ -0,0 +1,21 @@ +class FabricOS < Oxidized::Model + + # Brocade Fabric OS model # + ## FIXME: Only ssh exec mode support, no telnet, no ssh screenscraping + + prompt /^([\w]+:+[\w]+[>]\s)$/ + comment '# ' + + cmd 'chassisShow' do |cfg| + comment cfg + end + + cmd 'configShow -all' do |cfg| + cfg + end + + cfg :ssh do + exec true # don't run shell, run each command in exec channel + end + +end diff --git a/lib/oxidized/model/vyatta.rb b/lib/oxidized/model/vyatta.rb new file mode 100644 index 0000000..8d977aa --- /dev/null +++ b/lib/oxidized/model/vyatta.rb @@ -0,0 +1,27 @@ +class Vyatta < Oxidized::Model + + # Brocade Vyatta / VyOS model # + + prompt /\@.*?\:~\$\s/ + + cmd :all do |cfg| + cfg = cfg.lines.to_a[1..-2].join + end + + cmd :secret do |cfg| + cfg.gsub! /community (\S+) {/, 'community <hidden> {' + cfg + end + + cmd 'show configuration | no-more' + + cfg :telnet do + username /login:\s/ + password /^Password:\s/ + end + + cfg :telnet, :ssh do + pre_logout 'exit' + end + +end diff --git a/lib/oxidized/string.rb b/lib/oxidized/string.rb index bcc393a..35dc5af 100644 --- a/lib/oxidized/string.rb +++ b/lib/oxidized/string.rb @@ -3,11 +3,11 @@ module Oxidized class String < String # @return [Oxidized::String] copy of self with last line removed def cut_tail - Oxy::String.new each_line.to_a[0..-2].join + Oxidized::String.new each_line.to_a[0..-2].join end # @return [Oxidized::String] copy of self with first line removed def cut_head - Oxy::String.new each_line.to_a[1..-1].join + Oxidized::String.new each_line.to_a[1..-1].join end end end |