oxidized-script 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/oxidized/script/cli.rb +25 -48
- data/oxidized-script.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cb4b95b188a46565abcb9b42201b07bb988fd8672e2b5d55e3f5906378155eb
|
4
|
+
data.tar.gz: fb7d1798857327b428289fdca4307aa745728bf21726140f2617fef81ce5857c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c9c0468da66871a5d82de1f116897191a4ec78b6673ab97afdf8b092115c9d10f88bce3f790ca63318ad08c70edf150a887ec789f47aad08065db44d2684b91
|
7
|
+
data.tar.gz: c631fe4bbc7d70ba5ea450926dacbb7d8d2d88528ffaf29e6af3b9c3f76baa58502bbdd400cc05e86a0ad66b8b6c10c9320c512dacfd1903c647e5c87b5b95b7
|
data/lib/oxidized/script/cli.rb
CHANGED
@@ -13,8 +13,8 @@ module Oxidized
|
|
13
13
|
$stdout.sync = true
|
14
14
|
nodes = get_hosts
|
15
15
|
counter = @threads.to_i
|
16
|
-
Signal.trap("CLD")
|
17
|
-
nodes.each do |node|
|
16
|
+
Signal.trap("CLD") { counter += 1 }
|
17
|
+
nodes.each do |node|
|
18
18
|
Process.wait if counter <= 0
|
19
19
|
puts "Forking " + node if @verbose
|
20
20
|
counter -= 1
|
@@ -76,7 +76,7 @@ module Oxidized
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def opts_parse cmds
|
79
|
-
slop = Slop.new(:
|
79
|
+
slop = Slop.new(help: true)
|
80
80
|
slop.banner 'Usage: oxs [options] hostname [command]'
|
81
81
|
slop.on 'm=', '--model', 'host model (ios, junos, etc), otherwise discovered from Oxidized source'
|
82
82
|
slop.on 'o=', '--ostype', 'OS Type (ios, junos, etc)'
|
@@ -108,7 +108,7 @@ module Oxidized
|
|
108
108
|
@ostype = slop[:ostype]
|
109
109
|
@threads = slop[:threads]
|
110
110
|
@verbose = slop[:verbose]
|
111
|
-
@dryrun= slop[:dryrun]
|
111
|
+
@dryrun = slop[:dryrun]
|
112
112
|
@regex = slop[:regex]
|
113
113
|
[slop.parse!, slop]
|
114
114
|
end
|
@@ -144,61 +144,38 @@ module Oxidized
|
|
144
144
|
cmd = Script::Command.const_get cmd
|
145
145
|
name = cmd.const_get :Name
|
146
146
|
desc = cmd.const_get :Description
|
147
|
-
cmds << {:
|
147
|
+
cmds << { class: cmd, name: name, description: desc }
|
148
148
|
end
|
149
149
|
cmds
|
150
150
|
end
|
151
151
|
|
152
152
|
def get_hosts
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
nodes_regex = run_regex @regex
|
157
|
-
return nodes_group & nodes_regex
|
158
|
-
elsif @group and @ostype
|
159
|
-
puts "running list for hosts in group: #{@group} and matching: #{@ostype}" if @verbose
|
160
|
-
nodes_group = run_group @group
|
161
|
-
nodes_ostype = run_ostype @ostype
|
162
|
-
return nodes_group & nodes_ostype
|
163
|
-
elsif @regex
|
164
|
-
puts 'running list for hosts matching: ' + @regex if @verbose
|
165
|
-
return run_regex @regex
|
166
|
-
elsif @ostype
|
167
|
-
puts 'running list for hosts matching ostype: ' + @ostype if @verbose
|
168
|
-
return run_ostype @ostype
|
169
|
-
else
|
170
|
-
puts 'running list for hosts in group: ' + @group if @verbose
|
171
|
-
return run_group @group
|
153
|
+
puts "running list for hosts" if @verbose
|
154
|
+
if @group
|
155
|
+
puts " - in group: #{@group}" if @verbose
|
172
156
|
end
|
173
|
-
|
174
|
-
|
175
|
-
def run_group group
|
176
|
-
Oxidized.mgr = Manager.new
|
177
|
-
out = []
|
178
|
-
Nodes.new.each do |node|
|
179
|
-
next unless group == node.group
|
180
|
-
out << node.name
|
157
|
+
if @ostype
|
158
|
+
puts " - (and) matching ostype: #{@ostype}" if @verbose
|
181
159
|
end
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
def run_ostype ostype
|
186
|
-
Oxidized.mgr = Manager.new
|
187
|
-
out = []
|
188
|
-
Nodes.new.each do |node|
|
189
|
-
ostype.downcase # need to make sure they are both in lowercase
|
190
|
-
nodemodel = node.model.to_s.downcase # need to make sure they are both in lowercase
|
191
|
-
next unless nodemodel =~ /#{ostype}/
|
192
|
-
out << node.name
|
160
|
+
if @regex
|
161
|
+
puts " - (and) matching: #{@regex}" if @verbose
|
193
162
|
end
|
194
|
-
out
|
195
|
-
end
|
196
|
-
|
197
|
-
def run_regex regex
|
198
163
|
Oxidized.mgr = Manager.new
|
199
164
|
out = []
|
165
|
+
loop_verbose = false # turn on/off verbose output for the following loop
|
200
166
|
Nodes.new.each do |node|
|
201
|
-
|
167
|
+
if @group
|
168
|
+
puts " ... checking if #{node.name} in group: #{@group}, node group is: #{node.group}" if loop_verbose
|
169
|
+
next unless @group == node.group
|
170
|
+
end
|
171
|
+
if @ostype
|
172
|
+
puts " ... checking if #{node.name} matching ostype: #{@ostype}, node ostype is: #{node.model.to_s}" if loop_verbose
|
173
|
+
next unless node.model.to_s.match(/#{@ostype}/i)
|
174
|
+
end
|
175
|
+
if @regex
|
176
|
+
puts " ... checking if if #{node.name} matching: #{@regex}" if loop_verbose
|
177
|
+
next unless node.name.match(/#{@regex}/)
|
178
|
+
end
|
202
179
|
out << node.name
|
203
180
|
end
|
204
181
|
out
|
data/oxidized-script.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'oxidized-script'
|
3
|
-
s.version = '0.
|
3
|
+
s.version = '0.6.0'
|
4
4
|
s.licenses = %w( Apache-2.0 )
|
5
5
|
s.platform = Gem::Platform::RUBY
|
6
6
|
s.authors = [ 'Saku Ytti' ]
|
@@ -13,6 +13,6 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.executables = %w( oxs )
|
14
14
|
s.require_path = 'lib'
|
15
15
|
|
16
|
-
s.add_runtime_dependency 'oxidized', '~> 0.
|
16
|
+
s.add_runtime_dependency 'oxidized', '~> 0.25'
|
17
17
|
s.add_runtime_dependency 'slop', '~> 3.5'
|
18
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oxidized-script
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saku Ytti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oxidized
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.25'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.25'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: slop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|