oxidized 0.7.1 → 0.7.2
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 +4 -4
- data/README.md +1 -1
- data/extra/oxidized.service +12 -0
- data/lib/oxidized/input/ssh.rb +1 -1
- data/lib/oxidized/model/ironware.rb +17 -2
- data/lib/oxidized/nodes.rb +29 -0
- data/lib/oxidized/output/git.rb +78 -1
- data/lib/oxidized/worker.rb +3 -1
- data/oxidized.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c94960c6cdf5ebe4dc6910df211a29a55e3e3ecd
|
4
|
+
data.tar.gz: 9f8a27d266ac4e52519017bce1502df6b87fe802
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e005677f0702e5538645a4489ec4e123dad5ffc88386dc9186053e0db6f08c0321db0df1e945b84d5bb57cecf92c750a25eb3d1b82970496c8fa423f70be083
|
7
|
+
data.tar.gz: 16b8495f91c14040ca26c7f5028250a23ffa54aa7268ea5420ced503ef9fd4027ec46e959801854f44ca03f4cee64fdbd2fa787dca4a6decc69e8e9833a24931
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[](http://badge.fury.io/rb/oxidized)
|
4
4
|
|
5
|
-
Oxidized is a network device configuration backup tool. It's a RANCID
|
5
|
+
Oxidized is a network device configuration backup tool. It's a RANCID replacement!
|
6
6
|
|
7
7
|
* automatically adds/removes threads to meet configured retrieval interval
|
8
8
|
* restful API to move node immediately to head-of-queue (GET/POST /node/next/[NODE])
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#For debian 8 put it in /lib/systemd/system/
|
2
|
+
#and call it with systemctl start oxidized.service
|
3
|
+
|
4
|
+
[Unit]
|
5
|
+
Description=Oxidized - Network Device Configuration Backup Tool
|
6
|
+
|
7
|
+
[Service]
|
8
|
+
ExecStart=/usr/local/bin/oxidized
|
9
|
+
User=root
|
10
|
+
|
11
|
+
[Install]
|
12
|
+
WantedBy=multi-user.target
|
data/lib/oxidized/input/ssh.rb
CHANGED
@@ -24,7 +24,7 @@ module Oxidized
|
|
24
24
|
@ssh = Net::SSH.start @node.ip, @node.auth[:username],
|
25
25
|
:password => @node.auth[:password], :timeout => CFG.timeout,
|
26
26
|
:paranoid => secure,
|
27
|
-
:auth_methods => %w(none publickey password),
|
27
|
+
:auth_methods => %w(none publickey password keyboard-interactive),
|
28
28
|
:number_of_password_prompts => 0
|
29
29
|
unless @exec
|
30
30
|
shell_open @ssh
|
@@ -25,13 +25,28 @@ class IronWare < Oxidized::Model
|
|
25
25
|
end
|
26
26
|
|
27
27
|
cmd 'show version' do |cfg|
|
28
|
-
cfg.gsub! /(^((.*)
|
28
|
+
cfg.gsub! /(^((.*)[Ss]ystem uptime(.*))$)/, '' #remove unwanted line system uptime
|
29
|
+
cfg.gsub! /uptime is .*/,''
|
30
|
+
|
29
31
|
comment cfg
|
30
32
|
end
|
31
33
|
|
32
34
|
cmd 'show chassis' do |cfg|
|
33
|
-
cfg.gsub!
|
35
|
+
cfg.gsub! /\xFF/n, '' # ugly hack - avoids JSON.dump utf-8 breakage on 1.9..
|
34
36
|
cfg.gsub! /(^((.*)Current temp(.*))$)/, '' #remove unwanted lines current temperature
|
37
|
+
cfg.gsub! /Speed = [A-Z]{3} \(\d{2}\%\)/, '' #remove unwanted lines Speed Fans
|
38
|
+
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'
|
40
|
+
if cfg.include? "TEMPERATURE"
|
41
|
+
sc = StringScanner.new cfg
|
42
|
+
out = ''
|
43
|
+
temps = ''
|
44
|
+
out << sc.scan_until(/.*TEMPERATURE/)
|
45
|
+
temps << sc.scan_until(/.*Fans/)
|
46
|
+
out << sc.rest
|
47
|
+
cfg = out
|
48
|
+
end
|
49
|
+
|
35
50
|
comment cfg
|
36
51
|
end
|
37
52
|
|
data/lib/oxidized/nodes.rb
CHANGED
@@ -148,6 +148,35 @@ module Oxidized
|
|
148
148
|
end
|
149
149
|
end
|
150
150
|
end
|
151
|
+
|
152
|
+
public
|
153
|
+
|
154
|
+
def version node, group
|
155
|
+
with_lock do
|
156
|
+
i = find_node_index node
|
157
|
+
output = self[i].output.new
|
158
|
+
raise Oxidized::NotSupported unless output.respond_to? :fetch
|
159
|
+
output.version node, group
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def get_version node, group, oid
|
164
|
+
with_lock do
|
165
|
+
i = find_node_index node
|
166
|
+
output = self[i].output.new
|
167
|
+
raise Oxidized::NotSupported unless output.respond_to? :fetch
|
168
|
+
output.get_version node, group, oid
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def get_diff node, group, oid1, oid2
|
173
|
+
with_lock do
|
174
|
+
i = find_node_index node
|
175
|
+
output = self[i].output.new
|
176
|
+
raise Oxidized::NotSupported unless output.respond_to? :fetch
|
177
|
+
output.get_diff node, group, oid1, oid2
|
178
|
+
end
|
179
|
+
end
|
151
180
|
|
152
181
|
end
|
153
182
|
end
|
data/lib/oxidized/output/git.rb
CHANGED
@@ -61,6 +61,81 @@ class Git < Output
|
|
61
61
|
'node not found'
|
62
62
|
end
|
63
63
|
end
|
64
|
+
|
65
|
+
#give a hash of all oid revision for the givin node, and the date of the commit
|
66
|
+
def version node, group
|
67
|
+
begin
|
68
|
+
repo = @cfg.repo
|
69
|
+
if group
|
70
|
+
repo = File.join File.dirname(repo), group + '.git'
|
71
|
+
end
|
72
|
+
repo = Rugged::Repository.new repo
|
73
|
+
walker = Rugged::Walker.new(repo)
|
74
|
+
walker.sorting(Rugged::SORT_DATE)
|
75
|
+
walker.push(repo.head.target)
|
76
|
+
i = -1
|
77
|
+
tab = []
|
78
|
+
walker.each do |commit|
|
79
|
+
if commit.diff(paths: [node]).size > 0
|
80
|
+
hash = {}
|
81
|
+
hash[:date] = commit.time.to_s
|
82
|
+
hash[:oid] = commit.oid
|
83
|
+
tab[i += 1] = hash
|
84
|
+
end
|
85
|
+
end
|
86
|
+
walker.reset
|
87
|
+
tab
|
88
|
+
rescue
|
89
|
+
'node not found'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
#give the blob of a specific revision
|
94
|
+
def get_version node, group, oid
|
95
|
+
begin
|
96
|
+
repo = @cfg.repo
|
97
|
+
if group && group != ''
|
98
|
+
repo = File.join File.dirname(repo), group + '.git'
|
99
|
+
end
|
100
|
+
repo = Rugged::Repository.new repo
|
101
|
+
repo.blob_at(oid,node).content
|
102
|
+
rescue
|
103
|
+
'version not found'
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
#give a hash with the patch of a diff between 2 revision and the stats (added and deleted lines)
|
108
|
+
def get_diff node, group, oid1, oid2
|
109
|
+
begin
|
110
|
+
repo = @cfg.repo
|
111
|
+
diff_commits = nil
|
112
|
+
if group && group != ''
|
113
|
+
repo = File.join File.dirname(repo), group + '.git'
|
114
|
+
end
|
115
|
+
repo = Rugged::Repository.new repo
|
116
|
+
commit = repo.lookup(oid1)
|
117
|
+
#if the second revision is precised
|
118
|
+
if oid2
|
119
|
+
commit_old = repo.lookup(oid2)
|
120
|
+
diff = repo.diff(commit_old, commit)
|
121
|
+
diff.each do |patch|
|
122
|
+
if /#{node}\s+/.match(patch.to_s.lines.first)
|
123
|
+
diff_commits = {:patch => patch.to_s, :stat => patch.stat}
|
124
|
+
break
|
125
|
+
end
|
126
|
+
end
|
127
|
+
#else gives the diffs between the first oid and his first parrent
|
128
|
+
else
|
129
|
+
stat = commit.parents[0].diff(commit).stat
|
130
|
+
stat = [stat[1],stat[2]]
|
131
|
+
patch = commit.parents[0].diff(commit).patch
|
132
|
+
diff_commits = {:patch => patch, :stat => stat}
|
133
|
+
end
|
134
|
+
diff_commits
|
135
|
+
rescue
|
136
|
+
'no diffs'
|
137
|
+
end
|
138
|
+
end
|
64
139
|
|
65
140
|
private
|
66
141
|
|
@@ -104,8 +179,10 @@ class Git < Output
|
|
104
179
|
:parents => repo.empty? ? [] : [repo.head.target].compact,
|
105
180
|
:update_ref => 'HEAD',
|
106
181
|
)
|
182
|
+
|
107
183
|
index.write
|
184
|
+
true
|
108
185
|
end
|
109
186
|
end
|
110
187
|
end
|
111
|
-
end
|
188
|
+
end
|
data/lib/oxidized/worker.rb
CHANGED
@@ -37,8 +37,10 @@ module Oxidized
|
|
37
37
|
msg = "update #{node.name}"
|
38
38
|
msg += " from #{node.from}" if node.from
|
39
39
|
msg += " with message '#{node.msg}'" if node.msg
|
40
|
-
node.output.new.store node.name, job.config,
|
40
|
+
if node.output.new.store node.name, job.config,
|
41
41
|
:msg => msg, :user => node.user, :group => node.group
|
42
|
+
Log.info "Configuration updated for #{node.group}/#{node.name}"
|
43
|
+
end
|
42
44
|
node.reset
|
43
45
|
else
|
44
46
|
msg = "#{node.name} status #{job.status}"
|
data/oxidized.gemspec
CHANGED
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.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saku Ytti
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-06-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: asetus
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- bin/oxidized
|
91
91
|
- extra/nagios_check_failing_nodes.rb
|
92
92
|
- extra/oxidized.init
|
93
|
+
- extra/oxidized.service
|
93
94
|
- extra/oxidized.supervisord
|
94
95
|
- extra/oxidized.upstart
|
95
96
|
- extra/rest_client.rb
|
@@ -173,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
174
|
version: '0'
|
174
175
|
requirements: []
|
175
176
|
rubyforge_project: oxidized
|
176
|
-
rubygems_version: 2.
|
177
|
+
rubygems_version: 2.4.5
|
177
178
|
signing_key:
|
178
179
|
specification_version: 4
|
179
180
|
summary: feeble attempt at rancid
|