oxidized 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe68595d80d195deeed1f0642975a4881779798e
4
- data.tar.gz: 3b46e88817bbd6a0a9fa9e1bff7afe64f3a55e98
3
+ metadata.gz: dd1e30df648aee0f0e1a19d7a55bb91879e0456b
4
+ data.tar.gz: 239581a70a3709f67173cb59bf0288bcff6a4b7d
5
5
  SHA512:
6
- metadata.gz: 62dca2064aa9aca2121e509cdd43f93840ae153991d970804598acaa7fdaf4408928ecdd471b47c5878f519b553a2225d8fb04047b1b855a821570ff87e87b9a
7
- data.tar.gz: f8a988620c3d3d8f95f12abbe0a3d1d349570c713e3c8c0e491dc3726e0d1a96099ac637e29fe0365f323d53631d1af1c6cb0122b35543110a46027cd59da11a
6
+ metadata.gz: 98c9644577c24e064c415e985b09f501ef4ce9153a9ab3e7921fcb6093057e037cccc3157c8d2eca71660641501670e9840a57abd45d330ad5b482e8ec640148
7
+ data.tar.gz: 4c9cfe10817d51454ceaca602e10d8dc08d283b8f7a1c850185064369840eb0c80f6479a513ffa2fcbcdbdad36b265eee92fcda278c8b0f10e5b7ad1dda7d2c0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.9.0
2
+ - FEATURE: input log now uses devices name as file, instead of string from config (by @skoef)
3
+ - FEATURE: Dell Networkign OS (dnos) support (by @erefre)
4
+ - BUGFIX: CiscoSMB, powerconnect, comware, xos, ironware, nos fixes
5
+
1
6
  # 0.8.1
2
7
  - BUGFIX: restore ruby 1.9.3 compatibility
3
8
 
data/README.md CHANGED
@@ -63,6 +63,7 @@ Oxidized is a network device configuration backup tool. It's a RANCID replacemen
63
63
  * DELL PowerConnect
64
64
  * Extreme Networks XOS
65
65
  * Force10 FTOS
66
+ * Force10 NDOS
66
67
  * FortiGate FortiOS
67
68
  * HP Comware (HP A-series, H3C, 3Com)
68
69
  * HP ProCurve
@@ -353,6 +354,20 @@ nodiff/$FQDN--show_version
353
354
  nodiff/$FQDN--show_inventory
354
355
  ```
355
356
 
357
+ ### RESTful API and Web Interface
358
+
359
+ The RESTful API and Web Interface is enabled by configuring the `rest:` parameter in the config file. This parameter can optionally contain a relative URI.
360
+
361
+ ```
362
+ # Listen on http://127.0.0.1:8888/
363
+ rest: 127.0.0.1:8888
364
+ ```
365
+
366
+ ```
367
+ # Listen on http://10.0.0.1:8000/oxidized/
368
+ rest: 10.0.0.1:8000/oxidized
369
+ ```
370
+
356
371
  ### Advanced Configuration
357
372
 
358
373
  Below is an advanced example configuration. You will be able to (optinally) override options per device. The router.db format used is ```hostname:model:username:password:enable_password```. Hostname and model will be the only required options, all others override the global configuration sections.
data/extra/syslog.rb CHANGED
@@ -54,6 +54,8 @@ module Oxidized
54
54
  MSG = {
55
55
  :ios => /%SYS-(SW[0-9]+-)?5-CONFIG_I:/,
56
56
  :junos => 'UI_COMMIT:',
57
+ :eos => /%SYS-5-CONFIG_I:/,
58
+ :nxos => /%VSHD-5-VSHD_SYSLOG_CONFIG_I:/,
57
59
  }
58
60
 
59
61
  class << self
@@ -18,7 +18,7 @@ module Oxidized
18
18
  def connect node
19
19
  @node = node
20
20
  @node.model.cfg['ftp'].each { |cb| instance_exec(&cb) }
21
- @log = File.open(CFG.input.debug?.to_s + '-ftp', 'w') if CFG.input.debug?
21
+ @log = File.open(Oxidized::Config::Crash + "-#{@node.ip}-ftp", 'w') if CFG.input.debug?
22
22
  @ftp = Net::FTP.new @node.ip, @node.auth[:username], @node.auth[:password]
23
23
  connected?
24
24
  end
@@ -20,7 +20,7 @@ module Oxidized
20
20
  @output = ''
21
21
  @node.model.cfg['ssh'].each { |cb| instance_exec(&cb) }
22
22
  secure = CFG.input.ssh.secure
23
- @log = File.open(CFG.input.debug?.to_s + '-ssh', 'w') if CFG.input.debug?
23
+ @log = File.open(Oxidized::Config::Crash + "-#{@node.ip}-ssh", 'w') if CFG.input.debug?
24
24
  port = vars(:ssh_port) || 22
25
25
  @ssh = Net::SSH.start @node.ip, @node.auth[:username], :port => port.to_i,
26
26
  :password => @node.auth[:password], :timeout => CFG.timeout,
@@ -16,11 +16,13 @@ module Oxidized
16
16
  'Port' => port.to_i,
17
17
  'Timeout' => @timeout,
18
18
  'Model' => @node.model }
19
- opt['Output_log'] = CFG.input.debug?.to_s + '-telnet' if CFG.input.debug?
19
+ opt['Output_log'] = Oxidized::Config::Crash + "-#{@node.ip}-telnet" if CFG.input.debug?
20
20
 
21
21
  @telnet = Net::Telnet.new opt
22
- expect username
23
- @telnet.puts @node.auth[:username]
22
+ if @node.auth[:username] and @node.auth[:username].length > 0
23
+ expect username
24
+ @telnet.puts @node.auth[:username]
25
+ end
24
26
  expect password
25
27
  @telnet.puts @node.auth[:password]
26
28
  begin
@@ -23,16 +23,16 @@ class ASA < Oxidized::Model
23
23
  comment cfg
24
24
  end
25
25
 
26
+ cmd 'show inventory' do |cfg|
27
+ comment cfg
28
+ end
29
+
26
30
  cmd 'more system:running-config' do |cfg|
27
31
  cfg = cfg.each_line.to_a[3..-1].join
28
32
  cfg.gsub! /^: [^\n]*\n/, ''
29
33
  cfg
30
34
  end
31
35
 
32
- cmd 'show inventory' do |cfg|
33
- comment cfg
34
- end
35
-
36
36
  cfg :ssh do
37
37
  if vars :enable
38
38
  post_login do
@@ -0,0 +1,52 @@
1
+ class C4CMTS < Oxidized::Model
2
+
3
+ # Arris C4 CMTS
4
+
5
+ prompt /^([\w.@:\/-]+[#>]\s?)$/
6
+ comment '! '
7
+
8
+ cmd :all do |cfg|
9
+ cfg.each_line.to_a[1..-2].map{|line|line.delete("\r").rstrip}.join("\n") + "\n"
10
+ end
11
+
12
+ cmd :secret do |cfg|
13
+ cfg.gsub! /(.+)\s+encrypted-password\s+\w+\s+(.*)/, '\\1 <secret hidden> \\2'
14
+ cfg.gsub! /(snmp-server community)\s+".*"\s+(.*)/, '\\1 <secret hidden> \\2'
15
+ cfg.gsub! /(tacacs.*\s+key)\s+".*"\s+(.*)/, '\\1 <secret hidden> \\2'
16
+ cfg.gsub! /(cable authstring)\s+\w+\s+(.*)/, '\\1 <secret hidden> \\2'
17
+ cfg
18
+ end
19
+
20
+ cmd 'show environment' do |cfg|
21
+ cfg.gsub! /\s+[\-\d]+\s+C\s+[\(\s\d]+\s+\F\)/, '' # remove temperature readings
22
+ cfg.each_line.to_a[1..-2].join
23
+ comment cfg
24
+ end
25
+
26
+ cmd 'show version' do |cfg|
27
+ # remove uptime readings at char 55 and beyond
28
+ cfg = cfg.each_line.map{|line|line.rstrip.slice(0..54)}.join("\n") + "\n"
29
+ comment cfg
30
+ end
31
+
32
+ cmd 'show running-config' do |cfg|
33
+ cfg = cfg.each_line.to_a[1..-2].join
34
+ cfg
35
+ end
36
+
37
+ cfg :telnet do
38
+ username /^Username:/
39
+ password /^Password:/
40
+ end
41
+
42
+ cfg :telnet, :ssh do
43
+ if vars :enable
44
+ post_login do
45
+ send "enable\n"
46
+ send vars(:enable) + "\n"
47
+ end
48
+ end
49
+ pre_logout 'exit'
50
+ end
51
+
52
+ end
@@ -23,10 +23,6 @@ class CiscoSMB < Oxidized::Model
23
23
  comment cfg
24
24
  end
25
25
 
26
- cmd 'show inventory' do |cfg|
27
- comment cfg
28
- end
29
-
30
26
  cmd 'show running-config' do |cfg|
31
27
  cfg = cfg.each_line.to_a[0..-1].join
32
28
  cfg.gsub! /^Current configuration : [^\n]*\n/, ''
@@ -1,7 +1,8 @@
1
1
  class Comware < Oxidized::Model
2
2
  # HP (A-series)/H3C/3Com Comware
3
3
 
4
- prompt /^(<[\w.-]+>)$/
4
+ # sometimes the prompt might have a leading nul
5
+ prompt /^\0*(<[\w.-]+>)$/
5
6
  comment '# '
6
7
 
7
8
  # example how to handle pager
@@ -38,7 +39,7 @@ class Comware < Oxidized::Model
38
39
  end
39
40
 
40
41
  cmd 'display version' do |cfg|
41
- cfg = cfg.each_line.select {|l| not l.match /uptime/ }.join
42
+ cfg = cfg.each_line.select {|l| not l.match /uptime/i }.join
42
43
  comment cfg
43
44
  end
44
45
 
@@ -0,0 +1,47 @@
1
+ class DNOS < Oxidized::Model
2
+
3
+ # Force10 DNOS model #
4
+
5
+ comment '! '
6
+
7
+ cmd :all do |cfg|
8
+ cfg.each_line.to_a[2..-2].join
9
+ end
10
+
11
+ cmd :secret do |cfg|
12
+ cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
13
+ cfg.gsub! /secret (\d+) (\S+).*/, '<secret hidden>'
14
+ cfg
15
+ end
16
+
17
+ cmd 'show inventory' do |cfg|
18
+ comment cfg
19
+ end
20
+
21
+ cmd 'show inventory media' do |cfg|
22
+ comment cfg
23
+ end
24
+
25
+ cmd 'show running-config' do |cfg|
26
+ cfg = cfg.each_line.to_a[3..-1].join
27
+ cfg
28
+ end
29
+
30
+ cfg :telnet do
31
+ username /^Login:/
32
+ password /^Password:/
33
+ end
34
+
35
+ cfg :telnet, :ssh do
36
+ post_login 'terminal length 0'
37
+ post_login 'terminal width 0'
38
+ if vars :enable
39
+ post_login do
40
+ send "enable\n"
41
+ send vars(:enable) + "\n"
42
+ end
43
+ end
44
+ pre_logout 'exit'
45
+ end
46
+
47
+ end
@@ -16,12 +16,9 @@ class IronWare < Oxidized::Model
16
16
  #end
17
17
 
18
18
  cmd :all do |cfg|
19
- cfg.each_line.to_a[1..-2].join
20
- end
21
-
22
- cmd 'show running-config' do |cfg|
23
- cfg = cfg.each_line.to_a[3..-1].join
24
- cfg
19
+ # sometimes ironware inserts arbitrary whitespace after commands are
20
+ # issued on the CLI, from run to run. this normalises the output.
21
+ cfg.each_line.to_a[1..-2].drop_while { |e| e.match /^\s+$/ }.join
25
22
  end
26
23
 
27
24
  cmd 'show version' do |cfg|
@@ -36,7 +33,7 @@ class IronWare < Oxidized::Model
36
33
  cfg.gsub! /(^((.*)Current temp(.*))$)/, '' #remove unwanted lines current temperature
37
34
  cfg.gsub! /Speed = [A-Z]{3} \(\d{2}\%\)/, '' #remove unwanted lines Speed Fans
38
35
  cfg.gsub! /current speed is [A-Z]{3} \(\d{2}\%\)/, ''
39
- cfg.gsub! /Fan controlled temperature: \d{2}\.\d deg-C/, 'Fan controlled temperature: XX.X d deg-C'
36
+ cfg.gsub! /\d{2}\.\d deg-C/, 'XX.X deg-C'
40
37
  if cfg.include? "TEMPERATURE"
41
38
  sc = StringScanner.new cfg
42
39
  out = ''
@@ -55,20 +52,28 @@ class IronWare < Oxidized::Model
55
52
  end
56
53
 
57
54
  cmd 'show module' do |cfg|
55
+ cfg.gsub! /^((Invalid input)|(Type \?)).*$/, '' # some ironware devices are fixed config
58
56
  comment cfg
59
57
  end
60
58
 
59
+ cmd 'show running-config' do |cfg|
60
+ arr = cfg.each_line.to_a
61
+ arr[2..-1].join unless arr.length < 2
62
+ end
63
+
61
64
  cfg :telnet do
62
- username /^Username:/
63
- password /^Password:/
65
+ # match expected prompts on both older and newer
66
+ # versions of IronWare
67
+ username /^(Please Enter Login Name|Username):/
68
+ password /^(Please Enter )Password:/
64
69
  end
65
70
 
66
71
  #handle pager with enable
67
72
  cfg :telnet, :ssh do
68
73
  if vars :enable
69
74
  post_login do
70
- send "enable\n"
71
- send vars(:enable) + "\n"
75
+ send "enable\r\n"
76
+ send vars(:enable) + "\r\n"
72
77
  end
73
78
  end
74
79
  post_login ''
@@ -79,4 +84,4 @@ class IronWare < Oxidized::Model
79
84
  pre_logout 'exit'
80
85
  end
81
86
 
82
- end
87
+ end
@@ -9,7 +9,7 @@ class JunOS < Oxidized::Model
9
9
  cmd :all do |cfg|
10
10
  # we don't need screen-scraping in ssh due to exec
11
11
  cfg = cfg.lines.to_a[1..-2].join if telnet
12
- cfg.lines.map { |line| line.rstrip }.join "\n"
12
+ cfg.lines.map { |line| line.rstrip }.join("\n") + "\n"
13
13
  end
14
14
 
15
15
  cmd :secret do |cfg|
@@ -26,7 +26,7 @@ class NOS < Oxidized::Model
26
26
  end
27
27
 
28
28
  cfg 'show system' do |cfg|
29
- commen cfg.each_line.reject { |line| line.match /Time/ or line.match /speed/ }
29
+ comment cfg.each_line.reject { |line| line.match /Time/ or line.match /speed/ }
30
30
  end
31
31
 
32
32
  cmd 'show running-config'
@@ -25,7 +25,7 @@ class PowerConnect < Oxidized::Model
25
25
 
26
26
  cmd 'show running-config'
27
27
 
28
- cfg :telnet do
28
+ cfg :telnet, :ssh do
29
29
  username /^User( Name)?:/
30
30
  password /^\r?Password:/
31
31
  end
@@ -6,7 +6,9 @@ class XOS < Oxidized::Model
6
6
  comment '# '
7
7
 
8
8
  cmd :all do |cfg|
9
- cfg.each_line.to_a[1..-2].join
9
+ # xos inserts leading \r characters and other trailing white space.
10
+ # this deletes extraneous \r and trailing white space.
11
+ cfg.each_line.to_a[1..-2].map{|line|line.delete("\r").rstrip}.join("\n") + "\n"
10
12
  end
11
13
 
12
14
  cmd 'show version' do |cfg|
@@ -35,6 +37,7 @@ class XOS < Oxidized::Model
35
37
  cfg :telnet, :ssh do
36
38
  post_login 'disable clipaging'
37
39
  pre_logout 'exit'
40
+ pre_logout 'n'
38
41
  end
39
42
 
40
43
  end
data/oxidized.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'oxidized'
3
- s.version = '0.8.1'
3
+ s.version = '0.9.0'
4
4
  s.licenses = %w( Apache-2.0 )
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = [ 'Saku Ytti', 'Samer Abdel-Hafez', 'Anton Aksola' ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oxidized
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saku Ytti
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-09-17 00:00:00.000000000 Z
13
+ date: 2015-11-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: asetus
@@ -136,9 +136,11 @@ files:
136
136
  - lib/oxidized/model/aos7.rb
137
137
  - lib/oxidized/model/aosw.rb
138
138
  - lib/oxidized/model/asa.rb
139
+ - lib/oxidized/model/c4cmts.rb
139
140
  - lib/oxidized/model/ciscosmb.rb
140
141
  - lib/oxidized/model/comware.rb
141
142
  - lib/oxidized/model/cumulus.rb
143
+ - lib/oxidized/model/dnos.rb
142
144
  - lib/oxidized/model/edgeos.rb
143
145
  - lib/oxidized/model/eos.rb
144
146
  - lib/oxidized/model/fabricos.rb