summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2014-03-05 13:54:36 +0200
committerSaku Ytti <saku@ytti.fi>2014-03-05 13:54:36 +0200
commitf8be9c5a3597768128d70209daf4d40e527a7880 (patch)
tree656a61bee97b11e022fa0d27be38f059c146e18f
parent91abe312526e3bd0cd4927209dbff53976393dde (diff)
Add AireOS support
Crappy Cisco WLC 5k, much quality, very implementation, such secure * stop pre_logout from expecting prompt by default
-rw-r--r--lib/oxidized/config/bootstrap.rb2
-rw-r--r--lib/oxidized/input/cli.rb12
-rw-r--r--lib/oxidized/input/ssh.rb17
-rw-r--r--lib/oxidized/input/telnet.rb8
-rw-r--r--lib/oxidized/model/aireos.rb54
-rw-r--r--lib/oxidized/model/ios.rb8
-rw-r--r--oxidized.gemspec2
7 files changed, 85 insertions, 18 deletions
diff --git a/lib/oxidized/config/bootstrap.rb b/lib/oxidized/config/bootstrap.rb
index 4f9e2ab..9a0135e 100644
--- a/lib/oxidized/config/bootstrap.rb
+++ b/lib/oxidized/config/bootstrap.rb
@@ -8,7 +8,7 @@ module Oxidized
CFG.log = File.join Config::Root, 'log'
CFG.debug = false
CFG.threads = 30
- CFG.timeout = 5
+ CFG.timeout = 30
CFG.prompt = /^([\w.@-]+[#>]\s?)$/
CFG.rest = '0.0.0.0:8888'
CFG.vars = {
diff --git a/lib/oxidized/input/cli.rb b/lib/oxidized/input/cli.rb
index ab93b06..2e6ac35 100644
--- a/lib/oxidized/input/cli.rb
+++ b/lib/oxidized/input/cli.rb
@@ -5,6 +5,7 @@ module Oxidized
def initialize
@post_login = []
@pre_logout = []
+ @username, @password, @exec = nil
end
def get
@@ -15,7 +16,7 @@ module Oxidized
end
def disconnect_cli
- @pre_logout.each { |command, block| block ? block.call : (cmd command) }
+ @pre_logout.each { |command, block| block ? block.call : (cmd command, nil) }
end
def post_login _post_login=nil, &block
@@ -29,6 +30,15 @@ module Oxidized
@pre_logout << [_pre_logout, block]
end
end
+
+ def username re=/^(Username|login)/
+ @username or @username = re
+ end
+
+ def password re=/^Password/
+ @password or @password = re
+ end
+
end
end
end
diff --git a/lib/oxidized/input/ssh.rb b/lib/oxidized/input/ssh.rb
index a0a5916..ef15292 100644
--- a/lib/oxidized/input/ssh.rb
+++ b/lib/oxidized/input/ssh.rb
@@ -23,7 +23,10 @@ module Oxidized
@ssh = Net::SSH.start @node.ip, @node.auth[:username],
:password => @node.auth[:password], :timeout => CFG.timeout,
:paranoid => secure
- open_shell @ssh unless @exec
+ unless @exec
+ shell_open @ssh
+ @username ? shell_login : expect(@node.prompt)
+ end
@ssh and not @ssh.closed?
end
@@ -55,7 +58,7 @@ module Oxidized
end
end
- def open_shell ssh
+ def shell_open ssh
@ses = ssh.open_channel do |ch|
ch.on_data do |ch, data|
@output << data
@@ -68,7 +71,15 @@ module Oxidized
end
end
end
- expect @node.prompt
+ end
+
+ # Cisco WCS has extremely dubious SSH implementation, SSH auth is always
+ # success, it always opens shell and then run auth in shell. I guess
+ # they'll never support exec() :)
+ def shell_login
+ expect username
+ cmd @node.auth[:username], password
+ cmd @node.auth[:password]
end
def exec state=nil
diff --git a/lib/oxidized/input/telnet.rb b/lib/oxidized/input/telnet.rb
index 26df113..84d9877 100644
--- a/lib/oxidized/input/telnet.rb
+++ b/lib/oxidized/input/telnet.rb
@@ -48,14 +48,6 @@ module Oxidized
end
end
- def username re=/^(Username|login)/
- @username or @username = re
- end
-
- def password re=/^Password/
- @password or @password = re
- end
-
end
end
diff --git a/lib/oxidized/model/aireos.rb b/lib/oxidized/model/aireos.rb
new file mode 100644
index 0000000..8f5f646
--- /dev/null
+++ b/lib/oxidized/model/aireos.rb
@@ -0,0 +1,54 @@
+class Aireos < Oxidized::Model
+
+ # AireOS (at least I think that is what it's called, hard to find data)
+ # Used in Cisco WLC 5500
+
+ comment '# ' ## this complains too, can't find real comment char
+ prompt /^\([^\)]+\)\s>/
+
+ cmd :all do |cfg|
+ cfg.each_line.to_a[1..-2].join
+ end
+
+ ##show sysinfo?
+ ##show switchconfig?
+
+ cmd 'show udi' do |cfg|
+ cfg = comment clean cfg
+ cfg << "\n"
+ end
+
+ cmd 'show boot' do |cfg|
+ cfg = comment clean cfg
+ cfg << "\n"
+ end
+
+ cmd 'show run-config commands' do |cfg|
+ clean cfg
+ end
+
+ cfg :telnet, :ssh do
+ username /^User:\s*/
+ password /^Password:\s*/
+ post_login 'config paging disable'
+ end
+
+ cfg :telnet, :ssh do
+ pre_logout do
+ send "logout\n"
+ send "n"
+ end
+ end
+
+ def clean cfg
+ out = []
+ cfg.each_line do |line|
+ next if line.match /^\s*$/
+ line = line[1..-1] if line[0] == "\r"
+ out << line.strip
+ end
+ out = out.join "\n"
+ out << "\n"
+ end
+
+end
diff --git a/lib/oxidized/model/ios.rb b/lib/oxidized/model/ios.rb
index a216126..275625e 100644
--- a/lib/oxidized/model/ios.rb
+++ b/lib/oxidized/model/ios.rb
@@ -21,6 +21,10 @@ class IOS < Oxidized::Model
cfg.each_line.to_a[1..-3].join
end
+ cmd 'show inventory' do |cfg|
+ comment cfg
+ end
+
cmd 'show running-config' do |cfg|
cfg = cfg.each_line.to_a[3..-1].join
cfg.gsub! /^Current configuration : [^\n]*\n/, ''
@@ -31,10 +35,6 @@ class IOS < Oxidized::Model
cfg
end
- cmd 'show inventory' do |cfg|
- comment cfg
- end
-
cfg :telnet do
username /^Username:/
password /^Password:/
diff --git a/oxidized.gemspec b/oxidized.gemspec
index 12058ed..31e4640 100644
--- a/oxidized.gemspec
+++ b/oxidized.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'oxidized'
- s.version = '0.0.36'
+ s.version = '0.0.37'
s.platform = Gem::Platform::RUBY
s.authors = [ 'Saku Ytti' ]
s.email = %w( saku@ytti.fi )