summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--.rubocop_todo.yml28
-rw-r--r--.ruby-version1
-rw-r--r--.travis.yml8
-rw-r--r--README.md2
-rw-r--r--docs/Supported-OS-Types.md1
-rw-r--r--lib/oxidized/model/ndms.rb25
-rw-r--r--spec/githubrepo_spec.rb31
-rw-r--r--spec/input/ssh_spec.rb15
-rw-r--r--spec/node_spec.rb7
-rw-r--r--spec/nodes_spec.rb4
11 files changed, 63 insertions, 61 deletions
diff --git a/.gitignore b/.gitignore
index f6a2251..3fd09d4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,8 @@
/tmp/
.idea/
Gemfile.lock
+.ruby-version
+.sass-cache/
# Used by dotenv library to load environment variables.
# .env
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index e71f1ba..a56def7 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -29,16 +29,6 @@ Layout/AccessModifierIndentation:
Exclude:
- 'lib/oxidized/output/gitcrypt.rb'
-# Offense count: 2
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
-# SupportedHashRocketStyles: key, separator, table
-# SupportedColonStyles: key, separator, table
-# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
-Layout/AlignHash:
- Exclude:
- - 'spec/input/ssh_spec.rb'
-
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
@@ -150,8 +140,6 @@ Layout/EmptyLinesAroundBlockBody:
- 'lib/oxidized/model/audiocodes.rb'
- 'lib/oxidized/model/ciscosma.rb'
- 'lib/oxidized/model/tplink.rb'
- - 'spec/input/ssh_spec.rb'
- - 'spec/node_spec.rb'
# Offense count: 158
# Cop supports --auto-correct.
@@ -219,8 +207,6 @@ Layout/IndentHash:
- 'lib/oxidized/hook/githubrepo.rb'
- 'lib/oxidized/input/ssh.rb'
- 'lib/oxidized/output/http.rb'
- - 'spec/githubrepo_spec.rb'
- - 'spec/node_spec.rb'
# Offense count: 21
# Cop supports --auto-correct.
@@ -380,8 +366,6 @@ Layout/SpaceInsideHashLiteralBraces:
- 'lib/oxidized/output/git.rb'
- 'lib/oxidized/output/gitcrypt.rb'
- 'lib/oxidized/output/http.rb'
- - 'spec/githubrepo_spec.rb'
- - 'spec/input/ssh_spec.rb'
# Offense count: 9
# Cop supports --auto-correct.
@@ -695,9 +679,6 @@ Style/BracesAroundHashParameters:
- 'lib/oxidized/input/telnet.rb'
- 'lib/oxidized/model/procurve.rb'
- 'lib/oxidized/output/http.rb'
- - 'spec/githubrepo_spec.rb'
- - 'spec/input/ssh_spec.rb'
- - 'spec/node_spec.rb'
# Offense count: 3
Style/CaseEquality:
@@ -848,13 +829,6 @@ Style/LineEndConcatenation:
Exclude:
- 'lib/oxidized/hook.rb'
-# Offense count: 9
-# Cop supports --auto-correct.
-Style/MethodCallWithoutArgsParentheses:
- Exclude:
- - 'spec/githubrepo_spec.rb'
- - 'spec/input/ssh_spec.rb'
-
# Offense count: 131
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
@@ -966,7 +940,6 @@ Style/PercentLiteralDelimiters:
- 'lib/oxidized/config.rb'
- 'lib/oxidized/input/ssh.rb'
- 'oxidized.gemspec'
- - 'spec/nodes_spec.rb'
# Offense count: 22
# Cop supports --auto-correct.
@@ -1132,7 +1105,6 @@ Style/TrailingUnderscoreVariable:
Exclude:
- 'lib/oxidized/node.rb'
- 'lib/oxidized/output/git.rb'
- - 'spec/node_spec.rb'
# Offense count: 3
# Cop supports --auto-correct.
diff --git a/.ruby-version b/.ruby-version
deleted file mode 100644
index ebf14b4..0000000
--- a/.ruby-version
+++ /dev/null
@@ -1 +0,0 @@
-2.1.8
diff --git a/.travis.yml b/.travis.yml
index 8f97b30..db2925a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,11 @@
language: ruby
sudo: false
cache: bundler
+before_install:
+ - gem install bundler
rvm:
- - 2.1.6
+ - 2.1
+ - 2.2
+ - 2.3
+ - 2.4
+ - 2.5
diff --git a/README.md b/README.md
index ebe3d43..9e52792 100644
--- a/README.md
+++ b/README.md
@@ -79,7 +79,7 @@ gem install oxidized-script oxidized-web # if you don't install oxidized-web, ma
### CentOS, Oracle Linux, Red Hat Linux
-On CentOS 6 / RHEL 6, install Ruby greater than 1.9.3 (for Ruby 2.1.2 installation instructions see [Installing Ruby 2.1.2 using RVM](#installing-ruby-212-using-rvm)), then install Oxidized dependencies
+On CentOS 6 / RHEL 6, install Ruby 2.0 or greater (for Ruby 2.1.2 installation instructions see [Installing Ruby 2.1.2 using RVM](#installing-ruby-212-using-rvm)), then install Oxidized dependencies
```shell
yum install cmake sqlite-devel openssl-devel libssh2-devel
diff --git a/docs/Supported-OS-Types.md b/docs/Supported-OS-Types.md
index 7a765f8..4556946 100644
--- a/docs/Supported-OS-Types.md
+++ b/docs/Supported-OS-Types.md
@@ -163,3 +163,4 @@
* [Zhone (OLT and MX)](/lib/oxidized/model/zhoneolt.rb)
* Zyxel
* [ZyNOS](/lib/oxidized/model/zynos.rb)
+ * [NDMS](/lib/oxidized/model/ndms.rb)
diff --git a/lib/oxidized/model/ndms.rb b/lib/oxidized/model/ndms.rb
new file mode 100644
index 0000000..c632bb9
--- /dev/null
+++ b/lib/oxidized/model/ndms.rb
@@ -0,0 +1,25 @@
+class NDMS < Oxidized::Model
+
+ # Pull config from Zyxel Keenetic devices from version NDMS >= 2.0
+
+ comment '! '
+
+ prompt /^([\w.@()-]+[#>]\s?)/m
+
+ cmd 'show version' do |cfg|
+ cfg = cfg.each_line.to_a[1..-3].join
+ comment cfg
+ end
+
+ cmd 'show running-config' do |cfg|
+ cfg = cfg.each_line.to_a[1..-2]
+ cfg = cfg.reject { |line| line.match /(clock date|checksum)/ }.join
+ cfg
+ end
+
+ cfg :telnet do
+ username /^Login:/
+ password /^Password:/
+ pre_logout 'exit'
+ end
+end
diff --git a/spec/githubrepo_spec.rb b/spec/githubrepo_spec.rb
index e676534..baa9a14 100644
--- a/spec/githubrepo_spec.rb
+++ b/spec/githubrepo_spec.rb
@@ -3,11 +3,11 @@ require 'rugged'
require 'oxidized/hook/githubrepo'
describe GithubRepo do
- let(:credentials) { mock() }
- let(:remote) { mock() }
- let(:remotes) { mock() }
- let(:repo_head) { mock() }
- let(:repo) { mock() }
+ let(:credentials) { mock }
+ let(:remote) { mock }
+ let(:remotes) { mock }
+ let(:repo_head) { mock }
+ let(:repo) { mock }
let(:gr) { GithubRepo.new }
before do
@@ -44,15 +44,15 @@ describe GithubRepo do
gr.fetch_and_merge_remote(repo).must_equal nil
end
describe "when there is update considering conflicts" do
- let(:merge_index) { mock() }
- let(:their_branch) { mock() }
+ let(:merge_index) { mock }
+ let(:their_branch) { mock }
before(:each) do
- repo.expects(:fetch).with('origin', ['refs/heads/master'], credentials: credentials).returns({total_deltas: 1})
+ repo.expects(:fetch).with('origin', ['refs/heads/master'], credentials: credentials).returns(total_deltas: 1)
their_branch.expects(:target_id).returns(1)
repo_head.expects(:target_id).returns(2)
repo.expects(:merge_commits).with(2, 1).returns(merge_index)
- repo.expects(:branches).returns({"origin/master" => their_branch})
+ repo.expects(:branches).returns("origin/master" => their_branch)
end
it "should not try merging when there's conflict" do
@@ -70,12 +70,11 @@ describe GithubRepo do
repo_head.expects(:target).returns("our_target")
merge_index.expects(:write_tree).with(repo).returns("tree")
merge_index.expects(:conflicts?).returns(false)
- Rugged::Commit.expects(:create).with(repo, {
- parents: ["our_target", "their_target"],
- tree: "tree",
- message: "Merge remote-tracking branch 'origin/master'",
- update_ref: "HEAD"
- }).returns(1)
+ Rugged::Commit.expects(:create).with(repo,
+ parents: ["our_target", "their_target"],
+ tree: "tree",
+ message: "Merge remote-tracking branch 'origin/master'",
+ update_ref: "HEAD").returns(1)
gr.fetch_and_merge_remote(repo).must_equal 1
end
end
@@ -101,7 +100,7 @@ describe GithubRepo do
Oxidized.config.output.git.repo = '/foo.git'
remote.expects(:url).returns('https://github.com/username/foo.git')
remote.expects(:push).with(['refs/heads/master'], credentials: credentials).returns(true)
- repo.expects(:remotes).returns({'origin' => remote})
+ repo.expects(:remotes).returns('origin' => remote)
Rugged::Repository.expects(:new).with('/foo.git').returns(repo)
end
diff --git a/spec/input/ssh_spec.rb b/spec/input/ssh_spec.rb
index 7be9139..2d1f5ce 100644
--- a/spec/input/ssh_spec.rb
+++ b/spec/input/ssh_spec.rb
@@ -14,23 +14,22 @@ describe Oxidized::SSH do
model: 'junos',
username: 'alma',
password: 'armud',
- vars: {ssh_proxy: 'test.com'})
-
+ vars: { ssh_proxy: 'test.com' })
end
describe "#connect" do
it "should use proxy command when proxy host given" do
ssh = Oxidized::SSH.new
- model = mock()
- model.expects(:cfg).returns({'ssh' => []})
+ model = mock
+ model.expects(:cfg).returns('ssh' => [])
@node.expects(:model).returns(model).at_least_once
- proxy = mock()
+ proxy = mock
Net::SSH::Proxy::Command.expects(:new).with("ssh test.com -W %h:%p").returns(proxy)
- Net::SSH.expects(:start).with('93.184.216.34', 'alma', {:port => 22, :password => 'armud', :timeout => Oxidized.config.timeout,
- :paranoid => Oxidized.config.input.ssh.secure, :auth_methods => ['none', 'publickey', 'password', 'keyboard-interactive'],
- :number_of_password_prompts => 0, :proxy => proxy})
+ Net::SSH.expects(:start).with('93.184.216.34', 'alma', :port => 22, :password => 'armud', :timeout => Oxidized.config.timeout,
+ :paranoid => Oxidized.config.input.ssh.secure, :auth_methods => ['none', 'publickey', 'password', 'keyboard-interactive'],
+ :number_of_password_prompts => 0, :proxy => proxy)
ssh.instance_variable_set("@exec", true)
ssh.connect(@node)
diff --git a/spec/node_spec.rb b/spec/node_spec.rb
index 829e05a..f769751 100644
--- a/spec/node_spec.rb
+++ b/spec/node_spec.rb
@@ -14,7 +14,6 @@ describe Oxidized::Node do
username: 'alma',
password: 'armud',
prompt: 'test_prompt')
-
end
describe '#new' do
@@ -39,7 +38,7 @@ describe Oxidized::Node do
it 'should fetch the configuration' do
stub_oxidized_ssh
- status, _ = @node.run
+ status, = @node.run
status.must_equal :success
end
end
@@ -52,9 +51,9 @@ describe Oxidized::Node do
let(:group) { nil }
let(:node) do
- Oxidized::Node.new({
+ Oxidized::Node.new(
ip: '127.0.0.1', group: group, model: 'junos'
- })
+ )
end
it 'when there are no groups' do
diff --git a/spec/nodes_spec.rb b/spec/nodes_spec.rb
index 6fa4b41..a801107 100644
--- a/spec/nodes_spec.rb
+++ b/spec/nodes_spec.rb
@@ -17,8 +17,8 @@ describe Oxidized::Nodes do
Oxidized::Node.any_instance.stubs(:resolve_repo)
Oxidized::Node.any_instance.stubs(:resolve_output)
- @nodes_org = %w(ltt-pe1.hel kes2-rr1.tku tor-peer1.oul
- hal-p2.tre sav-gr1-sw1.kuo psl-sec-pe1.hel).map { |e| Oxidized::Node.new(opts.merge(name: e)) }
+ @nodes_org = %w[ltt-pe1.hel kes2-rr1.tku tor-peer1.oul
+ hal-p2.tre sav-gr1-sw1.kuo psl-sec-pe1.hel].map { |e| Oxidized::Node.new(opts.merge(name: e)) }
@node = @nodes_org.delete_at(0)
@nodes = Oxidized::Nodes.new(nodes: @nodes_org.dup)
end