oxidized-script 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68cefc95e5aa80208cafc27a688c8be059491610
4
- data.tar.gz: b494915c82884731ed23e7e0b840769f131e239d
3
+ metadata.gz: 0c16bc591c5474eb15e40fef64bcdbc48fd7091d
4
+ data.tar.gz: cd0e0ed8d118e8c1f913435b40647b2eb503d33e
5
5
  SHA512:
6
- metadata.gz: b14fb72028484d26c864247868803ab5d559b868adbbebc1f5dff19be3efefea04df5ec7bf6cb493ad111d45b72fe2177ada490a75d1f457148e45a98ae7f4ca
7
- data.tar.gz: 652cfd656ae8f34d6e867f8d7f4790955da500f02d9980a1a02d2b174640a35d2867125fbefc5f58b14191f89bb4771e08a49d3cca2887d72efbb020941fe936
6
+ metadata.gz: a062907057e209090eff6dc322344586138bbe07e5bb9f53b22f6397f9fd0c2102049cea90ca060e06f9dc8be83d3a380cd9f7a2f80ee844f6b66c5f066fbede
7
+ data.tar.gz: 983fd99551877eb0522005e35fad53721cae4f759a9f20023e75d271a691cef6ac1db89257224489819e4045deeca8306b96a17f72b65a36865b89ccbbbe5308
@@ -30,14 +30,15 @@ module Oxidized
30
30
  def opts_parse cmds
31
31
  slop = Slop.new(:help=>true)
32
32
  slop.banner 'Usage: oxs [options] hostname [command]'
33
- slop.on 'm=', '--model', 'host model (ios, junos, etc), otherwise discovered from Oxidized source'
34
- slop.on 'x=', '--commands', 'commands file to be sent'
35
- slop.on 'u=', '--username', 'username to use'
36
- slop.on 'p=', '--password', 'password to use'
37
- slop.on 't=', '--timeout', 'timeout value to use'
38
- slop.on 'e=', '--enable', 'enable password to use'
39
- slop.on 'v', '--verbose', 'verbose output, e.g. show commands sent'
40
- slop.on 'd', '--debug', 'turn on debugging'
33
+ slop.on 'm=', '--model', 'host model (ios, junos, etc), otherwise discovered from Oxidized source'
34
+ slop.on 'x=', '--commands', 'commands file to be sent'
35
+ slop.on 'u=', '--username', 'username to use'
36
+ slop.on 'p=', '--password', 'password to use'
37
+ slop.on 't=', '--timeout', 'timeout value to use'
38
+ slop.on 'e=', '--enable', 'enable password to use'
39
+ slop.on 'c=', '--community', 'snmp community to use for discovery'
40
+ slop.on 'v', '--verbose', 'verbose output, e.g. show commands sent'
41
+ slop.on 'd', '--debug', 'turn on debugging'
41
42
  cmds.each do |cmd|
42
43
  slop.on cmd[:name], cmd[:description] do
43
44
  cmd[:class].run(:args=>@args, :opts=>@opts, :host=>@host, :cmd=>@cmd)
@@ -50,7 +51,7 @@ module Oxidized
50
51
  def connect
51
52
  opts = {}
52
53
  opts[:host] = @host
53
- [:model, :username, :passsword, :timeout, :enable, :verbose].each do |key|
54
+ [:model, :username, :password, :timeout, :enable, :verbose, :community].each do |key|
54
55
  opts[key] = @opts[key] if @opts[key]
55
56
  end
56
57
  @oxs = Script.new opts
@@ -60,6 +61,7 @@ module Oxidized
60
61
  out = ''
61
62
  file = file == '-' ? $stdin : File.read(file)
62
63
  file.each_line do |line|
64
+ line.chomp!
63
65
  line.sub!(/\\n/, "\n") # tread escaped newline as newline
64
66
  out += @oxs.cmd line
65
67
  end
@@ -33,17 +33,19 @@ module Oxidized
33
33
  # @option opts [String] :username username for login
34
34
  # @option opts [String] :passsword password for login
35
35
  # @option opts [String] :enable enable password to use
36
+ # @option opts [String] :community community to use for discovery
36
37
  # @option opts [boolean] :verbose extra output, e.g. show command given in output
37
38
  # @yieldreturn [self] if called in block, returns self and disconnnects session after exiting block
38
39
  # @return [void]
39
40
  def initialize opts, &block
40
- host = opts.delete :host
41
- model = opts.delete :model
42
- timeout = opts.delete :timeout
43
- username = opts.delete :username
44
- password = opts.delete :password
45
- enable = opts.delete :enable
46
- @verbose = opts.delete :verbose
41
+ host = opts.delete :host
42
+ model = opts.delete :model
43
+ timeout = opts.delete :timeout
44
+ username = opts.delete :username
45
+ password = opts.delete :password
46
+ enable = opts.delete :enable
47
+ community = opts.delete :community
48
+ @verbose = opts.delete :verbose
47
49
  raise InvalidOption, "#{opts} not recognized" unless opts.empty?
48
50
  Oxidized.mgr = Manager.new
49
51
  @node = if model
@@ -51,7 +53,17 @@ module Oxidized
51
53
  else
52
54
  Nodes.new(:node=>host).first
53
55
  end
54
- raise NoNode, 'node not found' unless @node
56
+ if not @node
57
+ begin
58
+ require 'corona'
59
+ community ||= Corona::CFG.community
60
+ rescue LoadError
61
+ raise NoNode, 'node not found'
62
+ end
63
+ node = Corona.poll :host=>host, :community=>community
64
+ raise NoNode, 'node not found' unless node
65
+ @node = Node.new :name=>host, :model=>node[:model]
66
+ end
55
67
  @node.auth[:username] = username if username
56
68
  @node.auth[:password] = password if password
57
69
  CFG.vars.enable = enable if enable
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'oxidized-script'
3
- s.version = '0.0.3'
3
+ s.version = '0.0.4'
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.authors = [ 'Saku Ytti' ]
6
6
  s.email = %w( saku@ytti.fi )
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.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saku Ytti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-14 00:00:00.000000000 Z
11
+ date: 2014-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oxidized
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  requirements: []
79
79
  rubyforge_project: oxidized-script
80
- rubygems_version: 2.0.3
80
+ rubygems_version: 2.0.14
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: cli + library for scripting network devices