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 +4 -4
- data/lib/oxidized/script/cli.rb +11 -9
- data/lib/oxidized/script/script.rb +20 -8
- data/oxidized-script.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c16bc591c5474eb15e40fef64bcdbc48fd7091d
|
4
|
+
data.tar.gz: cd0e0ed8d118e8c1f913435b40647b2eb503d33e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a062907057e209090eff6dc322344586138bbe07e5bb9f53b22f6397f9fd0c2102049cea90ca060e06f9dc8be83d3a380cd9f7a2f80ee844f6b66c5f066fbede
|
7
|
+
data.tar.gz: 983fd99551877eb0522005e35fad53721cae4f759a9f20023e75d271a691cef6ac1db89257224489819e4045deeca8306b96a17f72b65a36865b89ccbbbe5308
|
data/lib/oxidized/script/cli.rb
CHANGED
@@ -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',
|
34
|
-
slop.on 'x=', '--commands',
|
35
|
-
slop.on 'u=', '--username',
|
36
|
-
slop.on 'p=', '--password',
|
37
|
-
slop.on 't=', '--timeout',
|
38
|
-
slop.on 'e=', '--enable',
|
39
|
-
slop.on '
|
40
|
-
slop.on '
|
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, :
|
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
|
41
|
-
model
|
42
|
-
timeout
|
43
|
-
username
|
44
|
-
password
|
45
|
-
enable
|
46
|
-
|
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
|
-
|
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
|
data/oxidized-script.gemspec
CHANGED
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.
|
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-
|
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.
|
80
|
+
rubygems_version: 2.0.14
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: cli + library for scripting network devices
|