summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.rubocop_todo.yml26
-rw-r--r--lib/oxidized/manager.rb4
-rw-r--r--lib/oxidized/model/aosw.rb2
-rw-r--r--lib/oxidized/model/asa.rb2
-rw-r--r--lib/oxidized/model/comware.rb2
-rw-r--r--lib/oxidized/model/firewareos.rb2
-rw-r--r--lib/oxidized/model/fortios.rb2
-rw-r--r--lib/oxidized/model/powerconnect.rb4
-rw-r--r--lib/oxidized/model/procurve.rb2
-rw-r--r--lib/oxidized/model/routeros.rb2
-rw-r--r--lib/oxidized/model/vrp.rb2
-rw-r--r--lib/oxidized/model/zhoneolt.rb2
-rw-r--r--lib/oxidized/source/csv.rb2
-rw-r--r--lib/oxidized/source/http.rb2
-rw-r--r--lib/oxidized/source/sql.rb2
-rw-r--r--spec/cli_spec.rb10
16 files changed, 24 insertions, 44 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 8167e2a..cf359df 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -872,21 +872,6 @@ Style/InfiniteLoop:
- 'extra/syslog.rb'
- 'lib/oxidized/core.rb'
-# Offense count: 10
-# Cop supports --auto-correct.
-# Configuration parameters: InverseMethods, InverseBlocks.
-Style/InverseMethods:
- Exclude:
- - 'lib/oxidized/model/aosw.rb'
- - 'lib/oxidized/model/asa.rb'
- - 'lib/oxidized/model/comware.rb'
- - 'lib/oxidized/model/firewareos.rb'
- - 'lib/oxidized/model/powerconnect.rb'
- - 'lib/oxidized/model/procurve.rb'
- - 'lib/oxidized/model/routeros.rb'
- - 'lib/oxidized/model/vrp.rb'
- - 'lib/oxidized/model/zhoneolt.rb'
-
# Offense count: 1
# Cop supports --auto-correct.
Style/LineEndConcatenation:
@@ -1023,17 +1008,6 @@ Style/PerlBackrefs:
- 'lib/oxidized/model/junos.rb'
- 'lib/oxidized/model/powerconnect.rb'
-# Offense count: 5
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: short, verbose
-Style/PreferredHashMethods:
- Exclude:
- - 'lib/oxidized/manager.rb'
- - 'lib/oxidized/source/csv.rb'
- - 'lib/oxidized/source/http.rb'
- - 'lib/oxidized/source/sql.rb'
-
# Offense count: 1
# Cop supports --auto-correct.
Style/Proc:
diff --git a/lib/oxidized/manager.rb b/lib/oxidized/manager.rb
index bf28ae7..d2ef4d2 100644
--- a/lib/oxidized/manager.rb
+++ b/lib/oxidized/manager.rb
@@ -49,13 +49,13 @@ module Oxidized
@model.merge! _model
end
def add_source _source
- return nil if @source.key? _source
+ return nil if @source.has_key? _source
_source = Manager.load Config::SourceDir, _source
return false if _source.empty?
@source.merge! _source
end
def add_hook _hook
- return nil if @hook.key? _hook
+ return nil if @hook.has_key? _hook
name = _hook
_hook = Manager.load File.join(Config::Root, 'hook'), name
_hook = Manager.load Config::HookDir, name if _hook.empty?
diff --git a/lib/oxidized/model/aosw.rb b/lib/oxidized/model/aosw.rb
index 71fde2e..3397305 100644
--- a/lib/oxidized/model/aosw.rb
+++ b/lib/oxidized/model/aosw.rb
@@ -40,7 +40,7 @@ class AOSW < Oxidized::Model
end
cmd 'show version' do |cfg|
- cfg = cfg.each_line.select { |line| not line.match /(Switch|AP) uptime/i }
+ cfg = cfg.each_line.reject { |line| line.match /(Switch|AP) uptime/i }
rstrip_cfg comment cfg.join
end
diff --git a/lib/oxidized/model/asa.rb b/lib/oxidized/model/asa.rb
index 9df4206..bea0705 100644
--- a/lib/oxidized/model/asa.rb
+++ b/lib/oxidized/model/asa.rb
@@ -27,7 +27,7 @@ class ASA < Oxidized::Model
cmd 'show version' do |cfg|
# avoid commits due to uptime / ixo-router01 up 2 mins 28 secs / ixo-router01 up 1 days 2 hours
- cfg = cfg.each_line.select { |line| not line.match /(\s+up\s+\d+\s+)|(.*days.*)/ }
+ cfg = cfg.each_line.reject { |line| line.match /(\s+up\s+\d+\s+)|(.*days.*)/ }
cfg = cfg.join
comment cfg
end
diff --git a/lib/oxidized/model/comware.rb b/lib/oxidized/model/comware.rb
index a5b7190..0ba26d5 100644
--- a/lib/oxidized/model/comware.rb
+++ b/lib/oxidized/model/comware.rb
@@ -47,7 +47,7 @@ class Comware < Oxidized::Model
end
cmd 'display version' do |cfg|
- cfg = cfg.each_line.select {|l| not l.match /uptime/i }.join
+ cfg = cfg.each_line.reject { |l| l.match /uptime/i }.join
comment cfg
end
diff --git a/lib/oxidized/model/firewareos.rb b/lib/oxidized/model/firewareos.rb
index 1b3d07c..31770dc 100644
--- a/lib/oxidized/model/firewareos.rb
+++ b/lib/oxidized/model/firewareos.rb
@@ -15,7 +15,7 @@ class FirewareOS < Oxidized::Model
cmd 'show sysinfo' do |cfg|
# avoid commits due to uptime
- cfg = cfg.each_line.select { |line| not line.match /(.*time.*)|(.*memory.*)|(.*cpu.*)/ }
+ cfg = cfg.each_line.reject { |line| line.match /(.*time.*)|(.*memory.*)|(.*cpu.*)/ }
cfg = cfg.join
comment cfg
end
diff --git a/lib/oxidized/model/fortios.rb b/lib/oxidized/model/fortios.rb
index 23370c4..9287dce 100644
--- a/lib/oxidized/model/fortios.rb
+++ b/lib/oxidized/model/fortios.rb
@@ -49,7 +49,7 @@ class FortiOS < Oxidized::Model
cfg << cmd('end') if @vdom_enabled
- cfg << cmd('show full-configuration')
+ cfg << cmd('show full-configuration | grep .')
cfg.join "\n"
end
diff --git a/lib/oxidized/model/powerconnect.rb b/lib/oxidized/model/powerconnect.rb
index f602a36..ca91e60 100644
--- a/lib/oxidized/model/powerconnect.rb
+++ b/lib/oxidized/model/powerconnect.rb
@@ -22,7 +22,7 @@ class PowerConnect < Oxidized::Model
if (@stackable.nil?)
@stackable = true if cfg.match /(U|u)nit\s/
end
- cfg = cfg.split("\n").select { |line| not line[/Up\sTime/] }
+ cfg = cfg.split("\n").reject { |line| line[/Up\sTime/] }
comment cfg.join("\n") + "\n"
end
@@ -72,7 +72,7 @@ class PowerConnect < Oxidized::Model
end
out << line.strip
end
- out = out.select { |line| not line[/Up\sTime/] }
+ out = out.reject { |line| line[/Up\sTime/] }
out = comment out.join "\n"
out << "\n"
end
diff --git a/lib/oxidized/model/procurve.rb b/lib/oxidized/model/procurve.rb
index 444fb5b..705a814 100644
--- a/lib/oxidized/model/procurve.rb
+++ b/lib/oxidized/model/procurve.rb
@@ -67,7 +67,7 @@ class Procurve < Oxidized::Model
# not supported on all models
cmd 'show system information' do |cfg|
- cfg = cfg.each_line.select { |line| not line.match /(.*CPU.*)|(.*Up Time.*)|(.*Total.*)|(.*Free.*)|(.*Lowest.*)|(.*Missed.*)/ }
+ cfg = cfg.each_line.reject { |line| line.match /(.*CPU.*)|(.*Up Time.*)|(.*Total.*)|(.*Free.*)|(.*Lowest.*)|(.*Missed.*)/ }
cfg = cfg.join
comment cfg
end
diff --git a/lib/oxidized/model/routeros.rb b/lib/oxidized/model/routeros.rb
index 6717446..b62a3be 100644
--- a/lib/oxidized/model/routeros.rb
+++ b/lib/oxidized/model/routeros.rb
@@ -20,7 +20,7 @@ class RouterOS < Oxidized::Model
cfg.gsub! /\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]/, '' # strip ANSI colours
cfg.gsub! /\\\r\n\s+/, '' # strip new line
cfg.gsub! /# inactive time\r\n/, '' # Remove time based system comment
- cfg = cfg.split("\n").select { |line| not line[/^\#\s\w{3}\/\d{2}\/\d{4}.*$/] }
+ cfg = cfg.split("\n").reject { |line| line[/^\#\s\w{3}\/\d{2}\/\d{4}.*$/] }
cfg.join("\n") + "\n"
end
end
diff --git a/lib/oxidized/model/vrp.rb b/lib/oxidized/model/vrp.rb
index 98229c3..e44f69e 100644
--- a/lib/oxidized/model/vrp.rb
+++ b/lib/oxidized/model/vrp.rb
@@ -25,7 +25,7 @@ class VRP < Oxidized::Model
end
cmd 'display version' do |cfg|
- cfg = cfg.each_line.select {|l| not l.match /uptime/ }.join
+ cfg = cfg.each_line.reject { |l| l.match /uptime/ }.join
comment cfg
end
diff --git a/lib/oxidized/model/zhoneolt.rb b/lib/oxidized/model/zhoneolt.rb
index b60edb2..c50680c 100644
--- a/lib/oxidized/model/zhoneolt.rb
+++ b/lib/oxidized/model/zhoneolt.rb
@@ -39,7 +39,7 @@ class ZhoneOLT < Oxidized::Model
end
cmd 'dump console' do |cfg|
- cfg = cfg.each_line.select { |line| not line.match /To Abort the operation enter Ctrl-C/ }.join
+ cfg = cfg.each_line.reject { |line| line.match /To Abort the operation enter Ctrl-C/ }.join
end
# zhone technically supports ssh, but it locks up a ton. Especially when
diff --git a/lib/oxidized/source/csv.rb b/lib/oxidized/source/csv.rb
index 4814bd7..b61525e 100644
--- a/lib/oxidized/source/csv.rb
+++ b/lib/oxidized/source/csv.rb
@@ -36,7 +36,7 @@ class CSV < Source
@cfg.map.each do |key, position|
keys[key.to_sym] = node_var_interpolate data[position]
end
- keys[:model] = map_model keys[:model] if keys.key? :model
+ keys[:model] = map_model keys[:model] if keys.has_key? :model
# map node specific vars
vars = {}
diff --git a/lib/oxidized/source/http.rb b/lib/oxidized/source/http.rb
index 6c12f29..56a575b 100644
--- a/lib/oxidized/source/http.rb
+++ b/lib/oxidized/source/http.rb
@@ -43,7 +43,7 @@ class HTTP < Source
want_positions = want_position.split('.')
keys[key.to_sym] = node_var_interpolate node.dig(*want_positions)
end
- keys[:model] = map_model keys[:model] if keys.key? :model
+ keys[:model] = map_model keys[:model] if keys.has_key? :model
# map node specific vars
vars = {}
diff --git a/lib/oxidized/source/sql.rb b/lib/oxidized/source/sql.rb
index 13fc39b..ca3bcc3 100644
--- a/lib/oxidized/source/sql.rb
+++ b/lib/oxidized/source/sql.rb
@@ -27,7 +27,7 @@ class SQL < Source
# map node parameters
keys = {}
@cfg.map.each { |key, sql_column| keys[key.to_sym] = node_var_interpolate node[sql_column.to_sym] }
- keys[:model] = map_model keys[:model] if keys.key? :model
+ keys[:model] = map_model keys[:model] if keys.has_key? :model
# map node specific vars
vars = {}
diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb
index eb9872e..bf6058a 100644
--- a/spec/cli_spec.rb
+++ b/spec/cli_spec.rb
@@ -2,8 +2,14 @@ require 'spec_helper'
require 'oxidized/cli'
describe Oxidized::CLI do
- before { @original = ARGV }
- after { ARGV.replace @original }
+ before(:each) do
+ @original = ARGV
+ Oxidized.asetus = Asetus.new
+ end
+
+ after(:each) do
+ ARGV.replace @original
+ end
%w[-v --version].each do |option|
describe option do