oxidized-script 0.0.1 → 0.0.2

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: ea2afb0bc4bb68667bc29704bde3f1a70cb591f4
4
- data.tar.gz: 0121bfb120faa8af163da27cb0e302324df8811d
3
+ metadata.gz: ea9be3c8d9c8f52605aa70e968d1402b067bd9c5
4
+ data.tar.gz: 92dd4aeba5806eda79f706be7b77813f9a05cf6f
5
5
  SHA512:
6
- metadata.gz: d850980e48c31ba44f5618906219ab8b5618e4002aa6d8bf1e240b02f1c8aee4d6bd41c7247e1fb1659d26133d32acf71e3a6d37e628d0adc7be75a7089701c1
7
- data.tar.gz: ea183301f772e8035bbbe49b38473ccc5a2a4b80994a50273f8c0fa9df0b924cad986b07a289d0b1868069514d2de3bee8660c4361c99817a3aff4db93db8d7c
6
+ metadata.gz: bd23cfcd6376dd20c7676ecf183a635b3e3953ecf9a1dc61f1c3760b2821518bb6e0ee10a4bc86bcb54a3d47581d1184b0f091ff96d44d0d14146f6504fb59bf
7
+ data.tar.gz: 0a8d27f8bec9dbda18078b914088285f65df78dc780d965f19ed9e98492328aebac13012b4370b8679e2e8073502694f1a03dd30a2db35160dccb7f448c8cf0c
@@ -36,6 +36,7 @@ module Oxidized
36
36
  on 'p=', '--password', 'password to use'
37
37
  on 't=', '--timeout', 'timeout value to use'
38
38
  on 'e=', '--enable', 'enable password to use'
39
+ on 'v', '--verbose', 'verbose output, e.g. show commands sent'
39
40
  on 'd', '--debug', 'turn on debugging'
40
41
  end
41
42
  [slop.parse!, slop]
@@ -44,11 +45,9 @@ module Oxidized
44
45
  def connect
45
46
  opts = {}
46
47
  opts[:host] = @host
47
- opts[:model] = @opts[:model] if @opts[:model]
48
- opts[:username] = @opts[:username] if @opts[:username]
49
- opts[:password] = @opts[:password] if @opts[:password]
50
- opts[:timeout] = @opts[:timeout].to_i if @opts[:timeout]
51
- opts[:enable] = @opts[:enable] if @opts[:enable]
48
+ [:model, :username, :passsword, :timeout, :enable, :verbose].each do |key|
49
+ opts[key] = @opts[key] if @opts[key]
50
+ end
52
51
  @oxs = Script.new opts
53
52
  end
54
53
 
@@ -11,7 +11,10 @@ module Oxidized
11
11
  # @param [String] command command to be sent
12
12
  # @return [String] output for command
13
13
  def cmd command
14
- @model.cmd command
14
+ out = ''
15
+ out += "## OXS - #{command}\n" if @verbose
16
+ out += @model.cmd command
17
+ out
15
18
  end
16
19
 
17
20
  # disconnects from ssh/telnet session
@@ -24,12 +27,13 @@ module Oxidized
24
27
  private
25
28
 
26
29
  # @param [Hash] opts options for Oxidized::Script
27
- # @option opts [String] :host hostname or ip address for Oxidized::Node
28
- # @option opts [String] :model node model (ios, junos etc) if defined, nodes are not loaded from source
29
- # @option opts [Fixnum] :timeout oxidized timeout
30
- # @option opts [String :username username for login
31
- # @option opts [String :passsword password for login
32
- # @option opts [String :enable enable password to use
30
+ # @option opts [String] :host hostname or ip address for Oxidized::Node
31
+ # @option opts [String] :model node model (ios, junos etc) if defined, nodes are not loaded from source
32
+ # @option opts [Fixnum] :timeout oxidized timeout
33
+ # @option opts [String] :username username for login
34
+ # @option opts [String] :passsword password for login
35
+ # @option opts [String] :enable enable password to use
36
+ # @option opts [boolean] :verbose extra output, e.g. show command given in output
33
37
  # @yieldreturn [self] if called in block, returns self and disconnnects session after exiting block
34
38
  # @return [void]
35
39
  def initialize opts, &block
@@ -38,7 +42,8 @@ module Oxidized
38
42
  timeout = opts.delete :timeout
39
43
  username = opts.delete :username
40
44
  password = opts.delete :password
41
- enable = opts.delete :enable
45
+ enable = opts.delete :enable
46
+ @verbose = opts.delete :verbose
42
47
  raise InvalidOption, "#{opts} not recognized" unless opts.empty?
43
48
  Oxidized.mgr = Manager.new
44
49
  @node = if model
@@ -49,7 +54,7 @@ module Oxidized
49
54
  raise NoNode, 'node not found' unless @node
50
55
  @node.auth[:username] = username if username
51
56
  @node.auth[:password] = password if password
52
- CFG.vars[:enable] = enable if enable
57
+ CFG.vars.enable = enable if enable
53
58
  CFG.timeout = timeout if timeout
54
59
  @model = @node.model
55
60
  @input = nil
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'oxidized-script'
3
- s.version = '0.0.1'
3
+ s.version = '0.0.2'
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.authors = [ 'Saku Ytti' ]
6
6
  s.email = %w( saku@ytti.fi )
@@ -12,6 +12,6 @@ Gem::Specification.new do |s|
12
12
  s.executables = %w( oxs )
13
13
  s.require_path = 'lib'
14
14
 
15
- #s.add_dependency 'oxidized'
15
+ s.add_dependency 'oxidized'
16
16
  s.add_dependency 'slop'
17
17
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oxidized-script
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-13 00:00:00.000000000 Z
11
+ date: 2014-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: oxidized
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: slop
15
29
  requirement: !ruby/object:Gem::Requirement