oxidized 0.14.3 → 0.15.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: 17df74ebc75870bfaf11cfdc157960c70ad9cc8d
4
- data.tar.gz: 71b84e576ce86002f55493d916e4f80c76ef82ec
3
+ metadata.gz: a5dd4172e3c9577bfb601bc1d88378abf9540179
4
+ data.tar.gz: 57dcd79de9f7303ad54031a33b51579d6f33882a
5
5
  SHA512:
6
- metadata.gz: 6c1b08bb7139195973cc2e98190989aac3469c763dbd53a1ceb92510fa582ccdb6beb261383541ee26e589a68e5e285eb5ab94d305b4d92099f8b22a2b965513
7
- data.tar.gz: 39e7b8e08e86699a1f5ef2ee24511c00b613fac5e056e685244928b463a759e8d8ee6d265557c8db457b0872f51432b44090c8b75139a0be31c6985bc1e7c7ca
6
+ metadata.gz: 41682a4c5ff7978340c21e7255ffdc1b9fe25615db8977b0bd027045fa9849bb4be6edd401b7e6776e54be497714188b3d3ec1d74909a596a1d945945cc1c6c0
7
+ data.tar.gz: e63697ab95faad315a36b6bfb6e0be416aaae3a4c7d2433f371f85914b0ec658ab13bf7ecd58723774902984c1204885dfaa2e82fea6e829c93bd5a46e038360
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ # 0.15.0
2
+ - FEATURE: disable periodic collection, only on demand (by Adam Winberg)
3
+ - FEATURE: allow disabling ssh exec mode always (mainly for oxidized-script) (by @nickhilliard)
4
+ - FEATURE: support mellanox devices (by @ham5ter)
5
+ - FEATURE: support firewireos devices (by @alexandre-io)
6
+ - FEATURE: support quanta devices (by @f0o)
7
+ - FEATURE: support tellabs coriant8800, coriant8600 (by @udhos)
8
+ - FEATURE: support brocade6910 (by @cardboardpig)
9
+ - BUGFIX: debugging, tests (by @ElvinEfendi)
10
+ - BUGFIX: nos, panos, acos, procurve, eos, edgeswitch, aosw, fortios updates
11
+
1
12
  # 0.14.3
2
13
  - BUGFIX: fix git when using multiple groups without single_repo
3
14
 
data/Dockerfile CHANGED
@@ -13,3 +13,6 @@ RUN apt-get -y autoremove
13
13
 
14
14
  ADD extra/oxidized.runit /etc/service/oxidized/run
15
15
  ADD extra/auto-reload-config.runit /etc/service/auto-reload-config/run
16
+
17
+ VOLUME ["/root/.config/oxidized"]
18
+ EXPOSE 8888/tcp
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oxidized (0.12.2)
4
+ oxidized (0.14.3)
5
5
  asetus (~> 0.1)
6
- net-ssh (~> 3.0, >= 3.0.2)
6
+ net-ssh (>= 3.0.0, < 3.1)
7
7
  rugged (~> 0.21, >= 0.21.4)
8
8
  slop (~> 3.5)
9
9
 
@@ -23,7 +23,7 @@ GEM
23
23
  method_source (~> 0.8.1)
24
24
  slop (~> 3.4)
25
25
  rake (10.4.2)
26
- rugged (0.23.3)
26
+ rugged (0.24.0)
27
27
  slop (3.6.0)
28
28
 
29
29
  PLATFORMS
@@ -38,4 +38,4 @@ DEPENDENCIES
38
38
  rake (~> 10.0)
39
39
 
40
40
  BUNDLED WITH
41
- 1.11.2
41
+ 1.12.4
data/README.md CHANGED
@@ -20,13 +20,14 @@ Oxidized is a network device configuration backup tool. It's a RANCID replacemen
20
20
  1. [Supported OS Types](#supported-os-types)
21
21
  2. [Installation](#installation)
22
22
  * [Debian](#debian)
23
- * [CentOS, Oracle Linux, Red Hat Linux version 6](#centos-oracle-linux-red-hat-linux-version 6)
23
+ * [CentOS, Oracle Linux, Red Hat Linux](#centos-oracle-linux-red-hat-linux)
24
24
  3. [Initial Configuration](#configuration)
25
25
  4. [Installing Ruby 2.1.2 using RVM](#installing-ruby-2.1.2-using-rvm)
26
26
  5. [Running with Docker](#running-with-docker)
27
27
  6. [Cookbook](#cookbook)
28
28
  * [Debugging](#debugging)
29
29
  * [Privileged mode](#privileged-mode)
30
+ * [Disabling SSH exec channels](#disabling-ssh-exec-channels)
30
31
  * [Source: CSV](#source-csv)
31
32
  * [Source: SQLite](#source-sqlite)
32
33
  * [Source: HTTP](#source-http)
@@ -62,6 +63,7 @@ Oxidized is a network device configuration backup tool. It's a RANCID replacemen
62
63
  * Ironware
63
64
  * NOS (Network Operating System)
64
65
  * Vyatta
66
+ * 6910
65
67
  * Ciena
66
68
  * SOAS
67
69
  * Cisco
@@ -74,6 +76,9 @@ Oxidized is a network device configuration backup tool. It's a RANCID replacemen
74
76
  * SMB (Nikola series)
75
77
  * Citrix
76
78
  * NetScaler (Virtual Applicance)
79
+ * Coriant (former Tellabs)
80
+ * TMOS (8800)
81
+ * 8600
77
82
  * Cumulus
78
83
  * Linux
79
84
  * DataCom
@@ -101,6 +106,8 @@ Oxidized is a network device configuration backup tool. It's a RANCID replacemen
101
106
  * Juniper
102
107
  * JunOS
103
108
  * ScreenOS (Netscreen)
109
+ * Mellanox
110
+ * MLNX-OS
104
111
  * Mikrotik
105
112
  * RouterOS
106
113
  * Motorola
@@ -113,12 +120,16 @@ Oxidized is a network device configuration backup tool. It's a RANCID replacemen
113
120
  * Opengear
114
121
  * Palo Alto
115
122
  * PANOS
123
+ * Quanta
124
+ * Quanta / VxWorks 6.6 (1.1.0.8)
116
125
  * Supermicro
117
126
  * Supermicro
118
127
  * Ubiquiti
119
128
  * AirOS
120
129
  * Edgeos
121
130
  * EdgeSwitch
131
+ * Watchguard
132
+ * Fireware OS
122
133
  * Zyxel
123
134
  * ZyNOS
124
135
 
@@ -133,13 +144,19 @@ gem install oxidized
133
144
  gem install oxidized-script oxidized-web # if you don't install oxidized-web, make sure you remove "rest" from your config
134
145
  ```
135
146
 
136
- ## CentOS, Oracle Linux, Red Hat Linux version 6
137
- Install Ruby 1.9.3 or greater (for Ruby 2.1.2 installation instructions see "Installing Ruby 2.1.2 using RVM"), then install Oxidized dependencies
147
+ ## CentOS, Oracle Linux, Red Hat Linux
148
+ On CentOS 6 / RHEL 6, install Ruby 1.9.3 or greater (for Ruby 2.1.2 installation instructions see "Installing Ruby 2.1.2 using RVM"), then install Oxidized dependencies
138
149
  ```shell
139
150
  yum install cmake sqlite-devel openssl-devel libssh2-devel
140
151
  ```
141
152
 
142
- Now lets install oxidized via Rubygems:
153
+ RHEL 7 / CentOS 7 will work out of the box with the following package list:
154
+
155
+ ```shell
156
+ yum install cmake sqlite-devel openssl-devel libssh2-devel ruby gcc ruby-devel
157
+ ```
158
+
159
+ Now let's install oxidized via Rubygems:
143
160
  ```shell
144
161
  gem install oxidized
145
162
  gem install oxidized-script oxidized-web
@@ -149,6 +166,14 @@ gem install oxidized-script oxidized-web
149
166
 
150
167
  Oxidized configuration is in YAML format. Configuration files are subsequently sourced from ```/etc/oxidized/config``` then ```~/.config/oxidized/config```. The hashes will be merged, this might be useful for storing source information in a system wide file and user specific configuration in the home directory (to only include a staff specific username and password). Eg. if many users are using ```oxs```, see [Oxidized::Script](https://github.com/ytti/oxidized-script).
151
168
 
169
+ It is recommended practice to run Oxidized using its own username. This username can be added using standard command-line tools:
170
+
171
+ ```
172
+ useradd oxidized
173
+ ```
174
+
175
+ It is recommended not to run Oxidized as root.
176
+
152
177
  To initialize a default configuration in your home directory ```~/.config/oxidized/config```, simply run ```oxidized``` once. If you don't further configure anything from the output and source sections, it'll extend the examples on a subsequent ```oxidized``` execution. This is useful to see what options for a specific source or output backend are available.
153
178
 
154
179
  You can set the env variable `OXIDIZED_HOME` to change its home directory.
@@ -316,6 +341,16 @@ The above strips out snmp community strings from your saved configs.
316
341
 
317
342
  **NOTE:** Removing secrets reduces the usefulness as a full configuration backup, but it may make sharing configs easier.
318
343
 
344
+ ### Disabling SSH exec channels
345
+
346
+ Oxidized uses exec channels to make information extraction simpler, but there are some situations where this doesn't work well, e.g. configuring devices. This feature can be turned off by setting the ```ssh_no_exec```
347
+ variable.
348
+
349
+ ```
350
+ vars:
351
+ ssh_no_exec: true
352
+ ```
353
+
319
354
  ### Source: CSV
320
355
 
321
356
  One line per device, colon seperated.
@@ -551,6 +586,7 @@ vars:
551
586
  enable: S3cr3tx
552
587
  groups: {}
553
588
  rest: 127.0.0.1:8888
589
+ pid: ~/.config/oxidized/oxidized.pid
554
590
  input:
555
591
  default: ssh, telnet
556
592
  debug: false
@@ -6,7 +6,7 @@ Description=Oxidized - Network Device Configuration Backup Tool
6
6
 
7
7
  [Service]
8
8
  ExecStart=/usr/local/bin/oxidized
9
- User=root
9
+ User=oxidized
10
10
 
11
11
  [Install]
12
12
  WantedBy=multi-user.target
data/lib/oxidized/cli.rb CHANGED
@@ -24,7 +24,7 @@ module Oxidized
24
24
  Config.load(@opts)
25
25
  Oxidized.setup_logger
26
26
 
27
- @pidfile = File.join(Oxidized::Config::Root, 'pid')
27
+ @pidfile = File.expand_path(Oxidized.config.pid)
28
28
  end
29
29
 
30
30
  def crash error
@@ -30,6 +30,7 @@ module Oxidized
30
30
  asetus.default.rest = '127.0.0.1:8888' # or false to disable
31
31
  asetus.default.vars = {} # could be 'enable'=>'enablePW'
32
32
  asetus.default.groups = {} # group level configuration
33
+ asetus.default.pid = File.join(Oxidized::Config::Root, 'pid')
33
34
 
34
35
  asetus.default.input.default = 'ssh, telnet'
35
36
  asetus.default.input.debug = false # or String for session log file
data/lib/oxidized/core.rb CHANGED
@@ -31,6 +31,7 @@ module Oxidized
31
31
  private
32
32
 
33
33
  def run
34
+ Oxidized.logger.debug "lib/oxidized/core.rb: Starting the worker..."
34
35
  while true
35
36
  @worker.work
36
37
  sleep Config::Sleep
@@ -17,10 +17,15 @@ module Oxidized
17
17
  end
18
18
 
19
19
  def connect_cli
20
- @post_login.each { |command, block| block ? block.call : (cmd command) }
20
+ Oxidized.logger.debug "lib/oxidized/input/cli.rb: Running post_login commands at #{node.name}"
21
+ @post_login.each do |command, block|
22
+ Oxidized.logger.debug "lib/oxidized/input/cli.rb: Running post_login command: #{command.inspect}, block: #{block.inspect} at #{node.name}"
23
+ block ? block.call : (cmd command)
24
+ end
21
25
  end
22
26
 
23
27
  def disconnect_cli
28
+ Oxidized.logger.debug "lib/oxidized/input/cli.rb Running pre_logout commands at #{node.name}"
24
29
  @pre_logout.each { |command, block| block ? block.call : (cmd command, nil) }
25
30
  end
26
31
 
@@ -37,6 +37,7 @@ module Oxidized
37
37
  ssh_opts[:kex] = vars(:ssh_kex).split(/,\s*/) if vars(:ssh_kex)
38
38
  ssh_opts[:encryption] = vars(:ssh_encryption).split(/,\s*/) if vars(:ssh_encryption)
39
39
 
40
+ Oxidized.logger.debug "lib/oxidized/input/ssh.rb: Connecting to #{@node.name}"
40
41
  @ssh = Net::SSH.start(@node.ip, @node.auth[:username], ssh_opts)
41
42
  unless @exec
42
43
  shell_open @ssh
@@ -54,7 +55,7 @@ module Oxidized
54
55
  end
55
56
 
56
57
  def cmd cmd, expect=node.prompt
57
- Oxidized.logger.debug "SSH: #{cmd} @ #{node.name}"
58
+ Oxidized.logger.debug "lib/oxidized/input/ssh.rb #{cmd} @ #{node.name} with expect: #{expect.inspect}"
58
59
  if @exec
59
60
  @ssh.exec! cmd
60
61
  else
@@ -111,7 +112,7 @@ module Oxidized
111
112
  end
112
113
 
113
114
  def exec state=nil
114
- state == nil ? @exec : (@exec=state)
115
+ state == nil ? @exec : (@exec=state) unless vars :ssh_no_exec
115
116
  end
116
117
 
117
118
  def cmd_shell(cmd, expect_re)
@@ -123,6 +124,7 @@ module Oxidized
123
124
  end
124
125
 
125
126
  def expect regexp
127
+ Oxidized.logger.debug "lib/oxidized/input/ssh.rb: expecting #{regexp.inspect} at #{node.name}"
126
128
  Timeout::timeout(Oxidized.config.timeout) do
127
129
  @ssh.loop(0.1) do
128
130
  sleep 0.1
@@ -130,6 +132,5 @@ module Oxidized
130
132
  end
131
133
  end
132
134
  end
133
-
134
135
  end
135
136
  end
data/lib/oxidized/job.rb CHANGED
@@ -5,9 +5,11 @@ module Oxidized
5
5
  @node = node
6
6
  @start = Time.now.utc
7
7
  super do
8
+ Oxidized.logger.debug "lib/oxidized/job.rb: Starting fetching process for #{@node.name} at #{Time.now.utc}"
8
9
  @status, @config = @node.run
9
10
  @end = Time.now.utc
10
11
  @time = @end - @start
12
+ Oxidized.logger.debug "lib/oxidized/job.rb: Config fetched for #{@node.name} at #{@end}"
11
13
  end
12
14
  end
13
15
  end
data/lib/oxidized/jobs.rb CHANGED
@@ -6,7 +6,9 @@ module Oxidized
6
6
 
7
7
  def initialize max, interval, nodes
8
8
  @max = max
9
- @interval = interval
9
+ # Set interval to 1 if interval is 0 (=disabled) so we don't break
10
+ # the 'ceil' function
11
+ @interval = interval == 0 ? 1 : interval
10
12
  @nodes = nodes
11
13
  @last = Time.now.utc
12
14
  @durations = Array.new @nodes.size, AVERAGE_DURATION
@@ -7,6 +7,14 @@ class ACOS < Oxidized::Model
7
7
  prompt /^([-\w.\/:?\[\]\(\)]+[#>]\s?)$/
8
8
 
9
9
  cmd 'show version' do |cfg|
10
+ cfg.gsub! /\s(Last configuration saved at).*/, ' \\1 <removed>'
11
+ cfg.gsub! /\s(Memory).*/, ' \\1 <removed>'
12
+ cfg.gsub! /\s(Current time is).*/, ' \\1 <removed>'
13
+ cfg.gsub! /\s(The system has been up).*/, ' \\1 <removed>'
14
+ comment cfg
15
+ end
16
+
17
+ cmd 'show bootimage' do |cfg|
10
18
  comment cfg
11
19
  end
12
20
 
@@ -14,7 +22,12 @@ class ACOS < Oxidized::Model
14
22
  comment cfg
15
23
  end
16
24
 
17
- cmd 'show running-config all-partitions'
25
+ cmd 'show running-config all-partitions' do |cfg|
26
+ cfg.gsub! /(Current configuration).*/, '\\1 <removed>'
27
+ cfg.gsub! /(Configuration last updated at).*/, '\\1 <removed>'
28
+ cfg.gsub! /(Configuration last saved at).*/, '\\1 <removed>'
29
+ cfg.gsub! /(Configuration last synchronized at).*/, '\\1 <removed>'
30
+ end
18
31
 
19
32
  cmd 'show aflex all-partitions' do |cfg|
20
33
  comment cfg
@@ -22,6 +22,7 @@ class AOSW < Oxidized::Model
22
22
  cfg.gsub!(/key (\S+)$/, 'key <secret removed>')
23
23
  cfg.gsub!(/secret (\S+)$/, 'secret <secret removed>')
24
24
  cfg.gsub!(/wpa-passphrase (\S+)$/, 'wpa-passphrase <secret removed>')
25
+ cfg.gsub!(/bkup-passwords (\S+)$/, 'bkup-passwords <secret removed>')
25
26
  cfg
26
27
  end
27
28
 
@@ -33,18 +33,17 @@ class ASA < Oxidized::Model
33
33
  # backup any xml referenced in the configuration.
34
34
  anyconnect_profiles = cfg.scan(Regexp.new('(\sdisk0:/.+\.xml)')).flatten
35
35
  anyconnect_profiles.each do |profile|
36
- cfg << (comment profile + "\n" )
37
- cmd ("more" + profile) do |xml|
38
- cfg << (comment xml)
39
- end
36
+ cfg << (comment profile + "\n" )
37
+ cmd ("more" + profile) do |xml|
38
+ cfg << (comment xml)
39
+ end
40
40
  end
41
41
  # if DAP is enabled, also backup dap.xml
42
42
  if cfg.rindex(/dynamic-access-policy-record\s(?!DfltAccessPolicy)/)
43
- cfg << (comment "disk0:/dap.xml\n")
44
- cmd "more disk0:/dap.xml" do |xml|
45
- cfg << (comment xml)
46
- puts xml
47
- end
43
+ cfg << (comment "disk0:/dap.xml\n")
44
+ cmd "more disk0:/dap.xml" do |xml|
45
+ cfg << (comment xml)
46
+ end
48
47
  end
49
48
  cfg
50
49
  end
@@ -53,7 +52,7 @@ class ASA < Oxidized::Model
53
52
  if vars :enable
54
53
  post_login do
55
54
  send "enable\n"
56
- send vars(:enable) + "\n"
55
+ cmd vars(:enable)
57
56
  end
58
57
  end
59
58
  post_login 'terminal pager 0'
@@ -0,0 +1,45 @@
1
+
2
+ class BR6910 < Oxidized::Model
3
+
4
+ prompt /^Vty-[0-9]\#$/
5
+ comment '! '
6
+
7
+ # not possible to disable paging prior to show running-config
8
+ expect /^((.*)Others to exit ---(.*))$/ do |data, re|
9
+ send 'a'
10
+ data.sub re, ''
11
+ end
12
+
13
+ cmd :all do |cfg|
14
+ # sometimes br6910s inserts arbitrary whitespace after commands are
15
+ # issued on the CLI, from run to run. this normalises the output.
16
+ cfg.each_line.to_a[1..-2].drop_while { |e| e.match /^\s+$/ }.join
17
+ end
18
+
19
+ cmd 'show version' do |cfg|
20
+ comment cfg
21
+ end
22
+
23
+ # show flash is not possible on a brocade 6910, do dir instead
24
+ # to see flash contents (includes config file names)
25
+ cmd 'dir' do |cfg|
26
+ comment cfg
27
+ end
28
+
29
+ cmd 'show running-config' do |cfg|
30
+ arr = cfg.each_line.to_a
31
+ arr[2..-1].join unless arr.length < 2
32
+ end
33
+
34
+ cfg :telnet do
35
+ username /^Username:/
36
+ password /^Password:/
37
+ end
38
+
39
+ # post login and post logout
40
+ cfg :telnet, :ssh do
41
+ post_login ''
42
+ pre_logout 'exit'
43
+ end
44
+
45
+ end
@@ -0,0 +1,30 @@
1
+ class Coriant8600 < Oxidized::Model
2
+
3
+ comment '# '
4
+
5
+ prompt /^[^\s#>]+[#>]$/
6
+
7
+ cmd 'show hw-inventory' do |cfg|
8
+ comment cfg
9
+ end
10
+
11
+ cmd 'show flash' do |cfg|
12
+ comment cfg
13
+ end
14
+
15
+ cmd 'show run' do |cfg|
16
+ cfg
17
+ end
18
+
19
+ cfg :telnet do
20
+ username /^user name:$/
21
+ password /^password:$/
22
+ end
23
+
24
+ cfg :telnet, :ssh do
25
+ pre_logout 'exit'
26
+ post_login 'enable'
27
+ post_login 'terminal more off'
28
+ end
29
+
30
+ end
@@ -0,0 +1,25 @@
1
+ class CoriantTmos < Oxidized::Model
2
+
3
+ comment '# '
4
+
5
+ prompt /^[^\s#]+#\s$/
6
+
7
+ cmd 'show node extensive' do |cfg|
8
+ comment cfg
9
+ end
10
+
11
+ cmd 'show run' do |cfg|
12
+ cfg
13
+ end
14
+
15
+ cfg :telnet do
16
+ username /^Login:\s$/
17
+ password /^Password:\s$/
18
+ end
19
+
20
+ cfg :telnet, :ssh do
21
+ pre_logout 'exit'
22
+ post_login 'enable config terminal length 0'
23
+ end
24
+
25
+ end
@@ -11,8 +11,8 @@ class EdgeSwitch < Oxidized::Model
11
11
  end
12
12
 
13
13
  cfg :telnet do
14
- username /Username:\s/
15
- password /^Password:\s/
14
+ username /User(name)?:\s?/
15
+ password /^Password:\s?/
16
16
  end
17
17
 
18
18
  cfg :telnet, :ssh do
@@ -14,6 +14,7 @@ class EOS < Oxidized::Model
14
14
  cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
15
15
  cfg.gsub! /username (\S+) privilege (\d+) (\S+).*/, '<secret hidden>'
16
16
  cfg.gsub! /^(enable secret).*/, '\\1 <configuration removed>'
17
+ cfg.gsub! /^(tacacs-server key \d+).*/, '\\1 <configuration removed>'
17
18
  cfg
18
19
  end
19
20
 
@@ -0,0 +1,24 @@
1
+ class FirewareOS < Oxidized::Model
2
+
3
+ prompt /^\[?\w*\]?\w*<?\w*>?#\s*$/
4
+ comment '-- '
5
+
6
+ cmd :all do |cfg|
7
+ cfg.each_line.to_a[1..-2].join
8
+ end
9
+
10
+ cmd 'show sysinfo' do |cfg|
11
+ # avoid commits due to uptime
12
+ cfg = cfg.each_line.select { |line| not line.match /(.*time.*)|(.*memory.*)|(.*cpu.*)/ }
13
+ cfg = cfg.join
14
+ comment cfg
15
+ end
16
+
17
+ cmd 'export config to console'
18
+
19
+ cfg :ssh do
20
+ pre_logout 'exit'
21
+ end
22
+
23
+ end
24
+
@@ -2,7 +2,7 @@ class FortiOS < Oxidized::Model
2
2
 
3
3
  comment '# '
4
4
 
5
- prompt /^([-\w\.]+(\s[\(\w\-\.\)]+)?\~?\s?[#>$]\s?)$/
5
+ prompt /^([-\w\.\~]+(\s[\(\w\-\.\)]+)?\~?\s?[#>$]\s?)$/
6
6
 
7
7
  expect /^--More--\s$/ do |data, re|
8
8
  send ' '
@@ -7,8 +7,7 @@ class JunOS < Oxidized::Model
7
7
  end
8
8
 
9
9
  cmd :all do |cfg|
10
- # we don't need screen-scraping in ssh due to exec
11
- cfg = cfg.lines.to_a[1..-2].join if telnet
10
+ cfg = cfg.lines.to_a[1..-2].join if screenscrape
12
11
  cfg.lines.map { |line| line.rstrip }.join("\n") + "\n"
13
12
  end
14
13
 
@@ -0,0 +1,43 @@
1
+ class MLNXOS < Oxidized::Model
2
+
3
+ prompt /([\w.@()-\[:\s\]]+[#>]\s)$/
4
+ comment '## '
5
+
6
+ # Pager Handling
7
+ expect /.+lines\s\d+\-\d+([\s]|\/\d+\s\(END\)\s).+$/ do |data, re|
8
+ send ' '
9
+ data.sub re, ''
10
+ end
11
+
12
+ cmd :all do |cfg|
13
+ cfg.gsub! /\[\?1h=\r/, '' # Pager Handling
14
+ cfg.gsub! /\r\[K/,'' # Pager Handling
15
+ cfg.gsub! /\s/, '' # Linebreak Handling
16
+ cfg = cfg.lines.to_a[2..-3].join
17
+ end
18
+
19
+ cmd :secret do |cfg|
20
+ cfg.gsub! /(snmp-server community).*/, ' <snmp-server community configuration removed>'
21
+ cfg.gsub! /username (\S+) password (\d+) (\S+).*/, '<secret hidden>'
22
+ cfg
23
+ end
24
+
25
+ cmd 'show version' do |cfg|
26
+ comment cfg
27
+ end
28
+
29
+ cmd 'show inventory' do |cfg|
30
+ comment cfg
31
+ end
32
+
33
+ cmd 'enable'
34
+
35
+ cmd 'show running-config' do |cfg|
36
+ cfg
37
+ end
38
+
39
+ cfg :ssh do
40
+ password /^Password:\s*/
41
+ pre_logout 'exit'
42
+ end
43
+ end
@@ -35,6 +35,7 @@ module Oxidized
35
35
  else
36
36
  @cmd[:cmd] << [_cmd, block]
37
37
  end
38
+ Oxidized.logger.debug "lib/oxidized/model/model.rb Added #{_cmd} to the commands list"
38
39
  end
39
40
  def cmds
40
41
  @cmd
@@ -79,6 +80,7 @@ module Oxidized
79
80
  attr_accessor :input, :node
80
81
 
81
82
  def cmd string, &block
83
+ Oxidized.logger.debug "lib/oxidized/model/model.rb Executing #{string}"
82
84
  out = @input.cmd(string)
83
85
  return false unless out
84
86
  self.class.cmds[:all].each do |all_block|
@@ -127,6 +129,7 @@ module Oxidized
127
129
  end
128
130
 
129
131
  def get
132
+ Oxidized.logger.debug 'lib/oxidized/model/model.rb Collecting commands\' outputs'
130
133
  outputs = Outputs.new
131
134
  procs = self.class.procs
132
135
  self.class.cmds[:cmd].each do |command, block|
@@ -151,6 +154,10 @@ module Oxidized
151
154
  data
152
155
  end
153
156
 
157
+ def screenscrape
158
+ @input.class.to_s.match(/Telnet/) || vars(:ssh_no_exec)
159
+ end
160
+
154
161
  private
155
162
 
156
163
  def process_cmd_output output, name
@@ -22,14 +22,14 @@ class NOS < Oxidized::Model
22
22
  end
23
23
 
24
24
  cmd 'show chassis' do |cfg|
25
- comment cfg.each_line.reject { |line| line.match /Time/ }.join
25
+ comment cfg.each_line.reject { |line| line.match /Time/ or line.match /Update/ }.join
26
26
  end
27
27
 
28
28
  cfg 'show system' do |cfg|
29
29
  comment cfg.each_line.reject { |line| line.match /Time/ or line.match /speed/ }
30
30
  end
31
31
 
32
- cmd 'show running-config'
32
+ cmd 'show running-config | nomore'
33
33
 
34
34
  cfg :telnet do
35
35
  username /^.* login: /
@@ -11,7 +11,14 @@ class PanOS < Oxidized::Model
11
11
  end
12
12
 
13
13
  cmd 'show system info' do |cfg|
14
- cfg.gsub! /^(up)?time:\ .*\n/, ''
14
+ cfg.gsub! /^(up)?time:\ .*$/, ''
15
+ cfg.gsub! /^app-.*?:\ .*$/, ''
16
+ cfg.gsub! /^av-.*?:\ .*$/, ''
17
+ cfg.gsub! /^threat-.*?:\ .*$/, ''
18
+ cfg.gsub! /^wildfire-.*?:\ .*$/, ''
19
+ cfg.gsub! /^wf-private.*?:\ .*$/, ''
20
+ cfg.gsub! /^url-filtering.*?:\ .*$/, ''
21
+ cfg.gsub! /^global-.*?:\ .*$/, ''
15
22
  comment cfg
16
23
  end
17
24
 
@@ -40,7 +40,8 @@ class Procurve < Oxidized::Model
40
40
 
41
41
  # not supported on all models
42
42
  cmd 'show system information' do |cfg|
43
- cfg = cfg.split("\n")[0..-8].join("\n")
43
+ cfg = cfg.each_line.select { |line| not line.match /(.*CPU.*)|(.*Up Time.*)|(.*Total.*)|(.*Free.*)|(.*Lowest.*)|(.*Missed.*)/ }
44
+ cfg = cfg.join
44
45
  comment cfg
45
46
  end
46
47
 
@@ -0,0 +1,35 @@
1
+ class QuantaOS < Oxidized::Model
2
+
3
+ prompt /^\((\w|\S)+\) (>|#)$/
4
+ comment '! '
5
+
6
+ cmd 'show run' do |cfg|
7
+ cfg.each_line.select do |line|
8
+ not line.match /^!.*$/ and
9
+ not line.match /^\((\w|\S)+\) (>|#)$/ and
10
+ not line.match /^show run$/
11
+ end.join
12
+ end
13
+
14
+ cfg :telnet do
15
+ username /^Username:/
16
+ password /^Password:/
17
+ end
18
+
19
+ cfg :telnet, :ssh do
20
+ post_login do
21
+ send "enable\n"
22
+ if vars :enable
23
+ cmd vars(:enable)
24
+ else
25
+ cmd ""
26
+ end
27
+ end
28
+ post_login 'terminal length 0'
29
+ pre_logout do
30
+ send "quit\n"
31
+ send "n\n"
32
+ end
33
+ end
34
+
35
+ end
data/lib/oxidized/node.rb CHANGED
@@ -9,9 +9,7 @@ module Oxidized
9
9
  attr_accessor :running, :user, :msg, :from, :stats, :retry
10
10
  alias :running? :running
11
11
  def initialize opt
12
- if Oxidized.config.debug == true or opt[:debug] == true
13
- puts 'resolving DNS for %s...' % opt[:name]
14
- end
12
+ Oxidized.logger.debug 'resolving DNS for %s...' % opt[:name]
15
13
  @name = opt[:name]
16
14
  @ip = IPAddr.new(opt[:ip]).to_s rescue nil
17
15
  @ip ||= Resolv.new.getaddress @name
@@ -38,9 +36,11 @@ module Oxidized
38
36
  next unless @model.cfg[cfg_name] and not @model.cfg[cfg_name].empty?
39
37
  @model.input = input = input.new
40
38
  if config=run_input(input)
39
+ Oxidized.logger.debug "lib/oxidized/node.rb: #{input.class.name} ran for #{name} successfully"
41
40
  status = :success
42
41
  break
43
42
  else
43
+ Oxidized.logger.debug "lib/oxidized/node.rb: #{input.class.name} failed for #{name}"
44
44
  status = :no_connection
45
45
  end
46
46
  end
@@ -165,6 +165,7 @@ module Oxidized
165
165
  def resolve_model opt
166
166
  model = (opt[:model] or Oxidized.config.model)
167
167
  if not Oxidized.mgr.model[model]
168
+ Oxidized.logger.debug "lib/oxidized/node.rb: Loading model #{model.inspect}"
168
169
  Oxidized.mgr.add_model model or raise ModelNotFound, "#{model} not found for node #{ip}"
169
170
  end
170
171
  Oxidized.mgr.model[model].new
@@ -11,6 +11,7 @@ module Oxidized
11
11
  new = []
12
12
  @source = Oxidized.config.source.default
13
13
  Oxidized.mgr.add_source @source
14
+ Oxidized.logger.info "lib/oxidized/nodes.rb: Loading nodes"
14
15
  Oxidized.mgr.source[@source].new.load.each do |node|
15
16
  # we want to load specific node(s), not all of them
16
17
  next unless node_want? node_want, node
@@ -24,7 +25,7 @@ module Oxidized
24
25
  end
25
26
  end
26
27
  size == 0 ? replace(new) : update_nodes(new)
27
- Oxidized.logger.info "Loaded #{size} nodes"
28
+ Oxidized.logger.info "lib/oxidized/nodes.rb: Loaded #{size} nodes"
28
29
  end
29
30
  end
30
31
 
@@ -1,3 +1,3 @@
1
1
  module Oxidized
2
- VERSION = '0.14.3'
2
+ VERSION = '0.15.0'
3
3
  end
@@ -14,17 +14,21 @@ module Oxidized
14
14
  ended.each { |job| process job }
15
15
  @jobs.work
16
16
  while @jobs.size < @jobs.want
17
- Oxidized.logger.debug "Jobs #{@jobs.size}, Want: #{@jobs.want}"
17
+ Oxidized.logger.debug "lib/oxidized/worker.rb: Jobs #{@jobs.size}, Want: #{@jobs.want}"
18
18
  # ask for next node in queue non destructive way
19
19
  nextnode = @nodes.first
20
20
  unless nextnode.last.nil?
21
- break if nextnode.last.end + Oxidized.config.interval > Time.now.utc
21
+ # Set unobtainable value for 'last' if interval checking is disabled
22
+ last = Oxidized.config.interval == 0 ? Time.now.utc + 10 : nextnode.last.end
23
+ break if last + Oxidized.config.interval > Time.now.utc
22
24
  end
23
25
  # shift nodes and get the next node
24
26
  node = @nodes.get
25
27
  node.running? ? next : node.running = true
26
28
  @jobs.push Job.new node
29
+ Oxidized.logger.debug "lib/oxidized/worker.rb: Added #{node.name} to the job queue"
27
30
  end
31
+ Oxidized.logger.debug("lib/oxidized/worker.rb: #{@jobs.size} jobs running in parallel") unless @jobs.empty?
28
32
  end
29
33
 
30
34
  def process job
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.14.3
4
+ version: 0.15.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: 2016-05-25 00:00:00.000000000 Z
13
+ date: 2016-07-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: asetus
@@ -160,6 +160,7 @@ executables:
160
160
  extensions: []
161
161
  extra_rdoc_files: []
162
162
  files:
163
+ - ".ruby-version"
163
164
  - ".travis.yml"
164
165
  - CHANGELOG.md
165
166
  - Dockerfile
@@ -206,10 +207,13 @@ files:
206
207
  - lib/oxidized/model/aos7.rb
207
208
  - lib/oxidized/model/aosw.rb
208
209
  - lib/oxidized/model/asa.rb
210
+ - lib/oxidized/model/br6910.rb
209
211
  - lib/oxidized/model/c4cmts.rb
210
212
  - lib/oxidized/model/catos.rb
211
213
  - lib/oxidized/model/ciscosmb.rb
212
214
  - lib/oxidized/model/comware.rb
215
+ - lib/oxidized/model/coriant8600.rb
216
+ - lib/oxidized/model/corianttmos.rb
213
217
  - lib/oxidized/model/cumulus.rb
214
218
  - lib/oxidized/model/datacom.rb
215
219
  - lib/oxidized/model/dnos.rb
@@ -217,6 +221,7 @@ files:
217
221
  - lib/oxidized/model/edgeswitch.rb
218
222
  - lib/oxidized/model/eos.rb
219
223
  - lib/oxidized/model/fabricos.rb
224
+ - lib/oxidized/model/firewareos.rb
220
225
  - lib/oxidized/model/fortios.rb
221
226
  - lib/oxidized/model/ftos.rb
222
227
  - lib/oxidized/model/ios.rb
@@ -226,6 +231,7 @@ files:
226
231
  - lib/oxidized/model/isam.rb
227
232
  - lib/oxidized/model/junos.rb
228
233
  - lib/oxidized/model/masteros.rb
234
+ - lib/oxidized/model/mlnxos.rb
229
235
  - lib/oxidized/model/model.rb
230
236
  - lib/oxidized/model/mtrlrfs.rb
231
237
  - lib/oxidized/model/netonix.rb
@@ -237,6 +243,7 @@ files:
237
243
  - lib/oxidized/model/panos.rb
238
244
  - lib/oxidized/model/powerconnect.rb
239
245
  - lib/oxidized/model/procurve.rb
246
+ - lib/oxidized/model/quantaos.rb
240
247
  - lib/oxidized/model/routeros.rb
241
248
  - lib/oxidized/model/saos.rb
242
249
  - lib/oxidized/model/screenos.rb