oxidized 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile +3 -0
- data/README.md +133 -0
- data/Rakefile +46 -0
- data/TODO.md +20 -0
- data/bin/oxidized +13 -0
- data/extra/rest_client.rb +25 -0
- data/extra/syslog.rb +110 -0
- data/lib/oxidized.rb +6 -0
- data/lib/oxidized/cli.rb +42 -0
- data/lib/oxidized/config.rb +55 -0
- data/lib/oxidized/config/vars.rb +10 -0
- data/lib/oxidized/core.rb +41 -0
- data/lib/oxidized/input/cli.rb +48 -0
- data/lib/oxidized/input/input.rb +19 -0
- data/lib/oxidized/input/ssh.rb +111 -0
- data/lib/oxidized/input/telnet.rb +145 -0
- data/lib/oxidized/job.rb +14 -0
- data/lib/oxidized/jobs.rb +24 -0
- data/lib/oxidized/log.rb +21 -0
- data/lib/oxidized/manager.rb +57 -0
- data/lib/oxidized/model/acos.rb +69 -0
- data/lib/oxidized/model/aireos.rb +55 -0
- data/lib/oxidized/model/aos.rb +38 -0
- data/lib/oxidized/model/aos7.rb +58 -0
- data/lib/oxidized/model/aosw.rb +43 -0
- data/lib/oxidized/model/eos.rb +32 -0
- data/lib/oxidized/model/fortios.rb +44 -0
- data/lib/oxidized/model/ios.rb +63 -0
- data/lib/oxidized/model/iosxr.rb +47 -0
- data/lib/oxidized/model/ironware.rb +33 -0
- data/lib/oxidized/model/junos.rb +56 -0
- data/lib/oxidized/model/model.rb +152 -0
- data/lib/oxidized/model/powerconnect.rb +38 -0
- data/lib/oxidized/model/procurve.rb +45 -0
- data/lib/oxidized/model/timos.rb +45 -0
- data/lib/oxidized/node.rb +169 -0
- data/lib/oxidized/node/stats.rb +33 -0
- data/lib/oxidized/nodes.rb +143 -0
- data/lib/oxidized/output/file.rb +42 -0
- data/lib/oxidized/output/git.rb +78 -0
- data/lib/oxidized/output/output.rb +5 -0
- data/lib/oxidized/source/csv.rb +42 -0
- data/lib/oxidized/source/source.rb +11 -0
- data/lib/oxidized/source/sql.rb +61 -0
- data/lib/oxidized/string.rb +13 -0
- data/lib/oxidized/worker.rb +54 -0
- data/oxidized.gemspec +20 -0
- data/spec/nodes_spec.rb +46 -0
- metadata +136 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
module Oxidized
|
2
|
+
require 'oxidized/model/model'
|
3
|
+
require 'oxidized/input/input'
|
4
|
+
require 'oxidized/output/output'
|
5
|
+
require 'oxidized/source/source'
|
6
|
+
class Manager
|
7
|
+
class << self
|
8
|
+
def load dir, file
|
9
|
+
begin
|
10
|
+
require File.join dir, file+'.rb'
|
11
|
+
klass = nil
|
12
|
+
[Oxidized, Object].each do |mod|
|
13
|
+
klass = mod.constants.find { |const| const.to_s.downcase == file.downcase }
|
14
|
+
klass = mod.constants.find { |const| const.to_s.downcase == 'oxidized'+ file.downcase } unless klass
|
15
|
+
klass = mod.const_get klass if klass
|
16
|
+
break if klass
|
17
|
+
end
|
18
|
+
i = klass.new
|
19
|
+
i.setup if i.respond_to? :setup
|
20
|
+
{ file => klass }
|
21
|
+
rescue LoadError
|
22
|
+
{}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
attr_reader :input, :output, :model, :source
|
27
|
+
def initialize
|
28
|
+
@input = {}
|
29
|
+
@output = {}
|
30
|
+
@model = {}
|
31
|
+
@source = {}
|
32
|
+
end
|
33
|
+
def add_input method
|
34
|
+
method = Manager.load Config::InputDir, method
|
35
|
+
return false if method.empty?
|
36
|
+
@input.merge! method
|
37
|
+
end
|
38
|
+
def add_output method
|
39
|
+
method = Manager.load Config::OutputDir, method
|
40
|
+
return false if method.empty?
|
41
|
+
@output.merge! method
|
42
|
+
end
|
43
|
+
def add_model _model
|
44
|
+
name = _model
|
45
|
+
_model = Manager.load File.join(Config::Root, 'model'), name
|
46
|
+
_model = Manager.load Config::ModelDir, name if _model.empty?
|
47
|
+
return false if _model.empty?
|
48
|
+
@model.merge! _model
|
49
|
+
end
|
50
|
+
def add_source _source
|
51
|
+
return nil if @source.key? _source
|
52
|
+
_source = Manager.load Config::SourceDir, _source
|
53
|
+
return false if _source.empty?
|
54
|
+
@source.merge! _source
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
class ACOS < Oxidized::Model
|
2
|
+
# A10 ACOS model for AX and Thunder series
|
3
|
+
|
4
|
+
comment '! '
|
5
|
+
|
6
|
+
##ACOS prompt changes depending on the state of the device
|
7
|
+
prompt /^([-\w.\/:?\[\]\(\)]+[#>]\s?)$/
|
8
|
+
|
9
|
+
cmd 'show version' do |cfg|
|
10
|
+
comment cfg
|
11
|
+
end
|
12
|
+
|
13
|
+
cmd 'show license' do |cfg|
|
14
|
+
comment cfg
|
15
|
+
end
|
16
|
+
|
17
|
+
cmd 'show running-config all-partitions'
|
18
|
+
|
19
|
+
cmd 'show aflex all-partitions' do |cfg|
|
20
|
+
@partitions_aflex = cfg.lines.each_with_object({}) do |l,h|
|
21
|
+
h[$1] = [] if l.match /partition: (.+)/
|
22
|
+
# only consider scripts that have passed syntax check
|
23
|
+
h[h.keys.last] << $1 if l.match /^([\w-]+) +Check/
|
24
|
+
end
|
25
|
+
''
|
26
|
+
end
|
27
|
+
|
28
|
+
cmd :all do |cfg, cmdstring|
|
29
|
+
new_cfg = comment "COMMAND: #{cmdstring}\n"
|
30
|
+
new_cfg << cfg.each_line.to_a[1..-2].join
|
31
|
+
end
|
32
|
+
|
33
|
+
pre do
|
34
|
+
unless @partitions_aflex.empty?
|
35
|
+
out = []
|
36
|
+
@partitions_aflex.each do |partition,arules|
|
37
|
+
out << "! partition: #{partition}"
|
38
|
+
arules.each do |name|
|
39
|
+
cmd("show aflex #{name} partition #{partition}") do |cfg|
|
40
|
+
content = cfg.split(/Content:/).last.strip
|
41
|
+
out << "aflex create #{name}"
|
42
|
+
out << content
|
43
|
+
out << ".\n"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
out.join "\n"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
cfg :telnet do
|
52
|
+
username /login:/
|
53
|
+
password /^Password:/
|
54
|
+
end
|
55
|
+
|
56
|
+
cfg :telnet, :ssh do
|
57
|
+
# preferred way to handle additional passwords
|
58
|
+
if vars :enable
|
59
|
+
post_login do
|
60
|
+
send "enable\n"
|
61
|
+
send vars(:enable) + "\n"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
post_login 'terminal length 0'
|
65
|
+
post_login 'terminal width 0'
|
66
|
+
pre_logout "exit\nexit\ny"
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class Aireos < Oxidized::Model
|
2
|
+
|
3
|
+
# AireOS (at least I think that is what it's called, hard to find data)
|
4
|
+
# Used in Cisco WLC 5500
|
5
|
+
|
6
|
+
comment '# ' ## this complains too, can't find real comment char
|
7
|
+
prompt /^\([^\)]+\)\s>/
|
8
|
+
|
9
|
+
cmd :all do |cfg|
|
10
|
+
cfg.each_line.to_a[1..-2].join
|
11
|
+
end
|
12
|
+
|
13
|
+
##show sysinfo?
|
14
|
+
##show switchconfig?
|
15
|
+
|
16
|
+
cmd 'show udi' do |cfg|
|
17
|
+
cfg = comment clean cfg
|
18
|
+
cfg << "\n"
|
19
|
+
end
|
20
|
+
|
21
|
+
cmd 'show boot' do |cfg|
|
22
|
+
cfg = comment clean cfg
|
23
|
+
cfg << "\n"
|
24
|
+
end
|
25
|
+
|
26
|
+
cmd 'show run-config commands' do |cfg|
|
27
|
+
clean cfg
|
28
|
+
end
|
29
|
+
|
30
|
+
cfg :telnet, :ssh do
|
31
|
+
username /^User:\s*/
|
32
|
+
password /^Password:\s*/
|
33
|
+
post_login 'config paging disable'
|
34
|
+
end
|
35
|
+
|
36
|
+
cfg :telnet, :ssh do
|
37
|
+
pre_logout do
|
38
|
+
send "logout\n"
|
39
|
+
send "n"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def clean cfg
|
44
|
+
out = []
|
45
|
+
cfg.each_line do |line|
|
46
|
+
next if line.match /^\s*$/
|
47
|
+
next if line.match /rogue adhoc alert [\da-f]{2}:/
|
48
|
+
line = line[1..-1] if line[0] == "\r"
|
49
|
+
out << line.strip
|
50
|
+
end
|
51
|
+
out = out.join "\n"
|
52
|
+
out << "\n"
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class AOS < Oxidized::Model
|
2
|
+
|
3
|
+
# Alcatel-Lucent Operating System
|
4
|
+
# used in OmniSwitch
|
5
|
+
|
6
|
+
comment '! '
|
7
|
+
|
8
|
+
cmd :all do |cfg|
|
9
|
+
cfg.each_line.to_a[1..-2].join
|
10
|
+
end
|
11
|
+
|
12
|
+
cmd 'show system' do |cfg|
|
13
|
+
cfg = cfg.each_line.find{|line|line.match 'Description'}
|
14
|
+
comment cfg.to_s.strip
|
15
|
+
end
|
16
|
+
|
17
|
+
cmd 'show chassis' do |cfg|
|
18
|
+
comment cfg
|
19
|
+
end
|
20
|
+
|
21
|
+
cmd 'show hardware info' do |cfg|
|
22
|
+
comment cfg
|
23
|
+
end
|
24
|
+
|
25
|
+
cmd 'show configuration snapshot' do |cfg|
|
26
|
+
cfg
|
27
|
+
end
|
28
|
+
|
29
|
+
cfg :telnet do
|
30
|
+
username /^login : /
|
31
|
+
password /^password : /
|
32
|
+
end
|
33
|
+
|
34
|
+
cfg :telnet, :ssh do
|
35
|
+
pre_logout 'exit'
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
class AOS7 < Oxidized::Model
|
2
|
+
|
3
|
+
# Alcatel-Lucent Operating System Version 7 (Linux based)
|
4
|
+
# used in OmniSwitch 6900/10k
|
5
|
+
|
6
|
+
comment '! '
|
7
|
+
|
8
|
+
cmd :all do |cfg, cmdstring|
|
9
|
+
new_cfg = comment "COMMAND: #{cmdstring}\n"
|
10
|
+
new_cfg << cfg.each_line.to_a[1..-2].join
|
11
|
+
end
|
12
|
+
|
13
|
+
cmd 'show system' do |cfg|
|
14
|
+
cfg = cfg.each_line.find{|line|line.match 'Description'}
|
15
|
+
comment cfg.to_s.strip + "\n"
|
16
|
+
end
|
17
|
+
|
18
|
+
cmd 'show chassis' do |cfg|
|
19
|
+
# check for virtual chassis existence
|
20
|
+
@slave_vcids = cfg.scan(/Chassis ID (\d+) \(Slave\)/).flatten
|
21
|
+
@master_vcid = $1 if cfg.match /Chassis ID (\d+) \(Master\)/
|
22
|
+
comment cfg
|
23
|
+
end
|
24
|
+
|
25
|
+
cmd 'show hardware-info' do |cfg|
|
26
|
+
comment cfg
|
27
|
+
end
|
28
|
+
|
29
|
+
cmd 'show running-directory' do |cfg|
|
30
|
+
comment cfg
|
31
|
+
end
|
32
|
+
|
33
|
+
cmd 'show configuration snapshot' do |cfg|
|
34
|
+
cfg
|
35
|
+
end
|
36
|
+
|
37
|
+
pre do
|
38
|
+
cfg = []
|
39
|
+
if @master_vcid
|
40
|
+
# add slave VC boot config as comment
|
41
|
+
@slave_vcids.each do |id|
|
42
|
+
cfg << comment("vc_boot.cfg for slave chassis #{id}")
|
43
|
+
cfg << comment(cmd("show configuration vcm-snapshot chassis-id #{id}"))
|
44
|
+
end
|
45
|
+
cfg << cmd("show configuration vcm-snapshot chassis-id #{@master_vcid}")
|
46
|
+
end
|
47
|
+
cfg.join "\n"
|
48
|
+
end
|
49
|
+
|
50
|
+
cfg :telnet do
|
51
|
+
username /^login : /
|
52
|
+
password /^Password : /
|
53
|
+
end
|
54
|
+
|
55
|
+
cfg :telnet, :ssh do
|
56
|
+
pre_logout 'exit'
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class AOSW < Oxidized::Model
|
2
|
+
|
3
|
+
# AOSW - Alcatel-Lucent OS - Wireless
|
4
|
+
# Used in Alcatel OAW-4750 WLAN controller (Aruba)
|
5
|
+
|
6
|
+
comment '# '
|
7
|
+
prompt /^\([^)]+\) #/
|
8
|
+
|
9
|
+
cmd :all do |cfg|
|
10
|
+
cfg.each_line.to_a[1..-2].join
|
11
|
+
end
|
12
|
+
|
13
|
+
cmd 'show version' do |cfg|
|
14
|
+
cfg = cfg.each_line.select { |line| not line.match /Switch uptime/i }
|
15
|
+
comment cfg.join
|
16
|
+
end
|
17
|
+
|
18
|
+
cmd 'show inventory' do |cfg|
|
19
|
+
cfg = cfg.each_line.take_while { |line| not line.match /Output \d Config/i }
|
20
|
+
comment cfg.join
|
21
|
+
end
|
22
|
+
|
23
|
+
cmd 'show slots' do |cfg|
|
24
|
+
comment cfg
|
25
|
+
end
|
26
|
+
cmd 'show license' do |cfg|
|
27
|
+
comment cfg
|
28
|
+
end
|
29
|
+
cmd 'show configuration' do |cfg|
|
30
|
+
cfg
|
31
|
+
end
|
32
|
+
|
33
|
+
cfg :telnet do
|
34
|
+
username /^User:\s*/
|
35
|
+
password /^Password:\s*/
|
36
|
+
end
|
37
|
+
|
38
|
+
cfg :telnet, :ssh do
|
39
|
+
post_login 'no paging'
|
40
|
+
pre_logout 'exit'
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class EOS < Oxidized::Model
|
2
|
+
|
3
|
+
# Arista EOS model #
|
4
|
+
# need to add telnet support here .. #
|
5
|
+
|
6
|
+
prompt /^[^\(]+\([^\)]+\)#/
|
7
|
+
|
8
|
+
comment '! '
|
9
|
+
|
10
|
+
cmd :all do |cfg|
|
11
|
+
cfg.each_line.to_a[2..-2].join
|
12
|
+
end
|
13
|
+
|
14
|
+
cmd :secret do |cfg|
|
15
|
+
cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
|
16
|
+
cfg.gsub! /username (\S+) privilege (\d+) (\S+).*/, '<secret hidden>'
|
17
|
+
cfg
|
18
|
+
end
|
19
|
+
|
20
|
+
cmd 'show inventory | no-more' do |cfg|
|
21
|
+
comment cfg
|
22
|
+
end
|
23
|
+
|
24
|
+
cmd 'show running-config | no-more' do |cfg|
|
25
|
+
cfg
|
26
|
+
end
|
27
|
+
|
28
|
+
cfg :telnet, :ssh do
|
29
|
+
pre_logout 'exit'
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class FortiOS < Oxidized::Model
|
2
|
+
|
3
|
+
comment '# '
|
4
|
+
|
5
|
+
prompt /^([-\w\.]+(\s[\(\w\-\.\)]+)?\s?[#>]\s?)$/
|
6
|
+
|
7
|
+
cmd :all do |cfg, cmdstring|
|
8
|
+
new_cfg = comment "COMMAND: #{cmdstring}\n"
|
9
|
+
new_cfg << cfg.each_line.to_a[1..-2].join
|
10
|
+
end
|
11
|
+
|
12
|
+
cmd 'get system status' do |cfg|
|
13
|
+
@vdom_enabled = cfg.include? 'Virtual domain configuration: enable'
|
14
|
+
comment cfg
|
15
|
+
end
|
16
|
+
|
17
|
+
post do
|
18
|
+
cfg = []
|
19
|
+
cfg << cmd('config global') if @vdom_enabled
|
20
|
+
|
21
|
+
cfg << cmd('get hardware status') do |cfg|
|
22
|
+
comment cfg
|
23
|
+
end
|
24
|
+
|
25
|
+
cfg << cmd('diagnose autoupdate version') do |cfg|
|
26
|
+
comment cfg
|
27
|
+
end
|
28
|
+
|
29
|
+
cfg << cmd('end') if @vdom_enabled
|
30
|
+
|
31
|
+
cfg << cmd('show')
|
32
|
+
cfg.join "\n"
|
33
|
+
end
|
34
|
+
|
35
|
+
cfg :telnet do
|
36
|
+
username /login:/
|
37
|
+
password /^Password:/
|
38
|
+
end
|
39
|
+
|
40
|
+
cfg :telnet, :ssh do
|
41
|
+
pre_logout "exit\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
class IOS < Oxidized::Model
|
2
|
+
|
3
|
+
prompt /^([\w.@()-]+[#>]\s?)$/
|
4
|
+
comment '! '
|
5
|
+
|
6
|
+
# example how to handle pager
|
7
|
+
#expect /^\s--More--\s+.*$/ do |data, re|
|
8
|
+
# send ' '
|
9
|
+
# data.sub re, ''
|
10
|
+
#end
|
11
|
+
|
12
|
+
# non-preferred way to handle additional PW prompt
|
13
|
+
#expect /^[\w.]+>$/ do |data|
|
14
|
+
# send "enable\n"
|
15
|
+
# send vars(:enable) + "\n"
|
16
|
+
# data
|
17
|
+
#end
|
18
|
+
|
19
|
+
cmd :all do |cfg|
|
20
|
+
#cfg.gsub! /\cH+\s{8}/, '' # example how to handle pager
|
21
|
+
#cfg.gsub! /\cH+/, '' # example how to handle pager
|
22
|
+
cfg.each_line.to_a[1..-2].join
|
23
|
+
end
|
24
|
+
|
25
|
+
cmd :secret do |cfg|
|
26
|
+
cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
|
27
|
+
cfg.gsub! /username (\S+) privilege (\d+) (\S+).*/, '<secret hidden>'
|
28
|
+
cfg
|
29
|
+
end
|
30
|
+
|
31
|
+
cmd 'show inventory' do |cfg|
|
32
|
+
comment cfg
|
33
|
+
end
|
34
|
+
|
35
|
+
cmd 'show running-config' do |cfg|
|
36
|
+
cfg = cfg.each_line.to_a[3..-1].join
|
37
|
+
cfg.gsub! /^Current configuration : [^\n]*\n/, ''
|
38
|
+
cfg.sub! /^(ntp clock-period).*/, '! \1'
|
39
|
+
cfg.gsub! /^\ tunnel\ mpls\ traffic-eng\ bandwidth[^\n]*\n*(
|
40
|
+
(?:\ [^\n]*\n*)*
|
41
|
+
tunnel\ mpls\ traffic-eng\ auto-bw)/mx, '\1'
|
42
|
+
cfg
|
43
|
+
end
|
44
|
+
|
45
|
+
cfg :telnet do
|
46
|
+
username /^Username:/
|
47
|
+
password /^Password:/
|
48
|
+
end
|
49
|
+
|
50
|
+
cfg :telnet, :ssh do
|
51
|
+
post_login 'terminal length 0'
|
52
|
+
post_login 'terminal width 0'
|
53
|
+
# preferred way to handle additional passwords
|
54
|
+
if vars :enable
|
55
|
+
post_login do
|
56
|
+
send "enable\n"
|
57
|
+
send vars(:enable) + "\n"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
pre_logout 'exit'
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|