oxidized-script 0.3.1 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f33b06421d3e4c2ab37dd2532a68215b98991d34
4
- data.tar.gz: e9349537593bfbc2b4194827381ce8f3f400ab8c
3
+ metadata.gz: e78a905befb0130e399d70d444d00433dd1d023e
4
+ data.tar.gz: 61e31fef4d16f550b35afb45dabc2b8200560540
5
5
  SHA512:
6
- metadata.gz: 09dbc25da8a981abcadd591ffe630a037c4068c248ef7d5117c60d4272d40be424c5b4efc5e86df5a180541233ac1142237c57a8751ed95561a54b01e4a555b1
7
- data.tar.gz: 39895ff7b8f342f1e7ff3470ee010b1ea0e9ada7200bee3ce2556ada7d743cc978672b894a652faeb762b3a8b383f929768689208fb814e1568c8eb9a9d8f7a1
6
+ metadata.gz: fe0c5a45af71afe30b680ac7e145333d4eddbe7bcd58e232ad0165fcae2711470df794f391d9dc56b05f195ed76add855f91cfacb34fb2117004366da85e1ab6
7
+ data.tar.gz: 52101b291edad1ec64c78e6a92926de01a949f58fcf8a63ded5fbc40950be2047320d1c1a4b1e08f9f0bb845d69f77092941c22c14d9084a4c2de5a6187cc1f3
@@ -1,3 +1,6 @@
1
+ # 0.3.2
2
+ - FEATURE on --ostype to get a list of nodes that match a particular OS Type (junos, routeros, ios) (by InsaneSplash)
3
+
1
4
  # 0.3.1
2
5
  - FEATURE on --dryrun to get a list of nodes without running a command (by @nertwork)
3
6
  - BUGFIX: errors with large config files running in ruby threads - forking instead (by @nertwork)
data/README.md CHANGED
@@ -38,6 +38,7 @@ Name Default RD Protocols Interfaces
38
38
  [fisakytt@lan-login1 ~]% oxs --help
39
39
  Usage: oxs [options] hostname [command]
40
40
  -m, --model host model (ios, junos, etc), otherwise discovered from Oxidized source
41
+ -o, --ostype OS Type (ios, junos, etc)
41
42
  -x, --commands commands file to be sent
42
43
  -u, --username username to use
43
44
  -p, --password password to use
@@ -9,7 +9,7 @@ module Oxidized
9
9
  class NothingToDo < ScriptError; end
10
10
 
11
11
  def run
12
- if @group or @regex
12
+ if @group or @regex or @ostype
13
13
  nodes = get_hosts
14
14
  counter = @threads.to_i
15
15
  Signal.trap("CLD") { counter += 1 }
@@ -57,14 +57,14 @@ module Oxidized
57
57
  @cmd_class.run :args=>@args, :opts=>@opts, :host=>@host, :cmd=>@cmd
58
58
  exit 0
59
59
  else
60
- if @group or @regex
60
+ if @group or @regex or @ostype
61
61
  @cmd = @args.shift
62
62
  else
63
63
  @host = @args.shift
64
64
  @cmd = @args.shift if @args
65
65
  end
66
66
  @oxs = nil
67
- raise NothingToDo, 'no host given' if not @host and not @group and not @regex
67
+ raise NothingToDo, 'no host given' if not @host and not @group and not @ostype and not @regex
68
68
  if @dryrun
69
69
  puts get_hosts
70
70
  exit
@@ -77,6 +77,7 @@ module Oxidized
77
77
  slop = Slop.new(:help=>true)
78
78
  slop.banner 'Usage: oxs [options] hostname [command]'
79
79
  slop.on 'm=', '--model', 'host model (ios, junos, etc), otherwise discovered from Oxidized source'
80
+ slop.on 'o=', '--ostype', 'OS Type (ios, junos, etc)'
80
81
  slop.on 'x=', '--commands', 'commands file to be sent'
81
82
  slop.on 'u=', '--username', 'username to use'
82
83
  slop.on 'p=', '--password', 'password to use'
@@ -102,6 +103,7 @@ module Oxidized
102
103
  end
103
104
  slop.parse
104
105
  @group = slop[:group]
106
+ @ostype = slop[:ostype]
105
107
  @threads = slop[:threads]
106
108
  @verbose = slop[:verbose]
107
109
  @dryrun= slop[:dryrun]
@@ -151,9 +153,17 @@ module Oxidized
151
153
  nodes_group = run_group @group
152
154
  nodes_regex = run_regex @regex
153
155
  return nodes_group & nodes_regex
156
+ elsif @group and @ostype
157
+ puts "running list for hosts in group: #{@group} and matching: #{@ostype}" if @verbose
158
+ nodes_group = run_group @group
159
+ nodes_ostype = run_ostype @ostype
160
+ return nodes_group & nodes_ostype
154
161
  elsif @regex
155
162
  puts 'running list for hosts matching: ' + @regex if @verbose
156
163
  return run_regex @regex
164
+ elsif @ostype
165
+ puts 'running list for hosts matching ostype: ' + @ostype if @verbose
166
+ return run_ostype @ostype
157
167
  else
158
168
  puts 'running list for hosts in group: ' + @group if @verbose
159
169
  return run_group @group
@@ -170,6 +180,18 @@ module Oxidized
170
180
  out
171
181
  end
172
182
 
183
+ def run_ostype ostype
184
+ Oxidized.mgr = Manager.new
185
+ out = []
186
+ Nodes.new.each do |node|
187
+ ostype.downcase # need to make sure they are both in lowercase
188
+ nodemodel = node.model.to_s.downcase # need to make sure they are both in lowercase
189
+ next unless nodemodel =~ /#{ostype}/
190
+ out << node.name
191
+ end
192
+ out
193
+ end
194
+
173
195
  def run_regex regex
174
196
  Oxidized.mgr = Manager.new
175
197
  out = []
@@ -37,6 +37,7 @@ module Oxidized
37
37
  # @param [Hash] opts options for Oxidized::Script
38
38
  # @option opts [String] :host @hostname or ip address for Oxidized::Node
39
39
  # @option opts [String] :model node model (ios, junos etc) if defined, nodes are not loaded from source
40
+ # @option opts [String] :ostype OS Type (ios, junos, etc)
40
41
  # @option opts [Fixnum] :timeout oxidized timeout
41
42
  # @option opts [String] :username username for login
42
43
  # @option opts [String] :passsword password for login
@@ -49,6 +50,7 @@ module Oxidized
49
50
  def initialize opts, &block
50
51
  @host = opts.delete :host
51
52
  model = opts.delete :model
53
+ ostype = opts.delete :ostype
52
54
  timeout = opts.delete :timeout
53
55
  username = opts.delete :username
54
56
  password = opts.delete :password
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'oxidized-script'
3
- s.version = '0.3.1'
3
+ s.version = '0.4.0'
4
4
  s.licenses = %w( Apache-2.0 )
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = [ 'Saku Ytti' ]
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.3.1
4
+ version: 0.4.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: 2016-08-24 00:00:00.000000000 Z
11
+ date: 2017-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oxidized
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  requirements: []
82
82
  rubyforge_project: oxidized-script
83
- rubygems_version: 2.5.1
83
+ rubygems_version: 2.5.2
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: cli + library for scripting network devices