cow 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +11 -10
- data/bin/console +4 -4
- data/cow.gemspec +8 -16
- data/lib/cow.rb +7 -7
- data/lib/cow/application.rb +14 -14
- data/lib/cow/plugins/acs.rb +13 -11
- data/lib/cow/plugins/acs5000.rb +12 -11
- data/lib/cow/plugins/acs6000.rb +12 -10
- data/lib/cow/plugins/cisco.rb +14 -12
- data/lib/cow/plugins/digi_ts.rb +20 -13
- data/lib/cow/plugins/tmpl.rb +7 -13
- data/lib/cow/version.rb +1 -1
- metadata +3 -9
data/README.md
CHANGED
@@ -20,18 +20,19 @@ Type `cow`. Then you can see usage.
|
|
20
20
|
|
21
21
|
```
|
22
22
|
$ cow list
|
23
|
-
|
24
|
-
console.local/
|
25
|
-
console.local/
|
26
|
-
console.local/
|
27
|
-
console.local/
|
28
|
-
console.local/
|
29
|
-
console.local/
|
30
|
-
console.local/
|
23
|
+
SERVER/PORT PORTNAME COMMAND
|
24
|
+
console.local/1 tokyo-core01 ssh -l kazubu:7001 console.local
|
25
|
+
console.local/2 tokyo-core02 ssh -l kazubu:7002 console.local
|
26
|
+
console.local/3 tokyo-sw01 ssh -l kazubu:7003 console.local
|
27
|
+
console.local/4 tokyo-sw02 ssh -l kazubu:7004 console.local
|
28
|
+
console.local/5 tokyo-serv01 ssh -l kazubu:7005 console.local
|
29
|
+
console.local/6 tokyo-serv02 ssh -l kazubu:7006 console.local
|
30
|
+
console.local/7 tokyo-serv03 ssh -l kazubu:7007 console.local
|
31
31
|
|
32
32
|
$ cow find core
|
33
|
-
|
34
|
-
console.local/
|
33
|
+
SERVER/PORT PORTNAME COMMAND
|
34
|
+
console.local/1 tokyo-core01 ssh -l kazubu:7001 console.local
|
35
|
+
console.local/2 tokyo-core02 ssh -l kazubu:7002 console.local
|
35
36
|
|
36
37
|
$ cow connect tokyo-core01
|
37
38
|
Found on console.local/1. Connecting...
|
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'cow'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require
|
10
|
+
# require 'pry'
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start
|
data/cow.gemspec
CHANGED
@@ -4,29 +4,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'cow/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'cow'
|
8
8
|
spec.version = Cow::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Kazuki Shimizu']
|
10
|
+
spec.email = ['kazubu@kazubu.jp']
|
11
11
|
|
12
12
|
spec.summary = %q{Console server Wrapper}
|
13
13
|
spec.description = %q{Ease to connect console server ports}
|
14
|
-
spec.homepage =
|
15
|
-
|
16
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
-
#if spec.respond_to?(:metadata)
|
19
|
-
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
-
#else
|
21
|
-
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
-
#end
|
14
|
+
spec.homepage = 'https://github.com/kazubu/cow/'
|
23
15
|
|
24
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
-
spec.bindir =
|
17
|
+
spec.bindir = 'exe'
|
26
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
28
20
|
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
31
23
|
spec.add_dependency 'snmp'
|
32
24
|
end
|
data/lib/cow.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
1
|
+
require 'cow/version'
|
2
|
+
require 'cow/plugins/acs'
|
3
|
+
require 'cow/plugins/acs5000'
|
4
|
+
require 'cow/plugins/acs6000'
|
5
|
+
require 'cow/plugins/digi_ts'
|
6
|
+
require 'cow/plugins/cisco'
|
7
7
|
|
8
8
|
module Cow
|
9
9
|
SERVER_TYPES = {
|
@@ -13,5 +13,5 @@ module Cow
|
|
13
13
|
digi_ts_telnet: Cow::DIGI_TS::Telnet::Server,
|
14
14
|
cisco_telnet: Cow::Cisco::Telnet::Server,
|
15
15
|
cisco_ssh: Cow::Cisco::SSH::Server
|
16
|
-
}
|
16
|
+
}.freeze
|
17
17
|
end
|
data/lib/cow/application.rb
CHANGED
@@ -11,19 +11,19 @@ module Cow
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def add_server(_server)
|
14
|
-
@servers.each_with_index
|
14
|
+
@servers.each_with_index do |server, idx|
|
15
15
|
if server.hostname == _server.hostname
|
16
16
|
@servers[idx] = _server
|
17
17
|
return _server
|
18
18
|
end
|
19
|
-
|
19
|
+
end
|
20
20
|
|
21
21
|
@servers << _server
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
25
25
|
|
26
|
-
CACHE_FILE = '/var/cache/cow/cow.cache'
|
26
|
+
CACHE_FILE = '/var/cache/cow/cow.cache'.freeze
|
27
27
|
|
28
28
|
@cache = nil
|
29
29
|
|
@@ -64,7 +64,7 @@ module Cow
|
|
64
64
|
|
65
65
|
File.open(_cache, 'w') do |file|
|
66
66
|
puts 'Updating cache file.'
|
67
|
-
if file.flock(File::LOCK_EX|File::LOCK_NB)
|
67
|
+
if file.flock(File::LOCK_EX | File::LOCK_NB)
|
68
68
|
|
69
69
|
begin
|
70
70
|
yield cache
|
@@ -117,7 +117,7 @@ module Cow
|
|
117
117
|
server = Cow::SERVER_TYPES[_type.to_sym].new(_hostname, _snmp_community)
|
118
118
|
|
119
119
|
server.ports.each do |port|
|
120
|
-
puts
|
120
|
+
puts '%s %s' % ["#{server.hostname}/#{port.port}".ljust(30), port.name.to_s.ljust(20)]
|
121
121
|
end
|
122
122
|
|
123
123
|
load_cache
|
@@ -137,8 +137,8 @@ module Cow
|
|
137
137
|
if port.name == _portname
|
138
138
|
puts "Found on #{server.hostname}/#{port.port}. Connecting..."
|
139
139
|
server.connect(port)
|
140
|
+
break
|
140
141
|
end
|
141
|
-
return
|
142
142
|
end
|
143
143
|
end
|
144
144
|
end
|
@@ -147,23 +147,23 @@ module Cow
|
|
147
147
|
raise ArgumentError unless _keyword.class == String
|
148
148
|
|
149
149
|
load_cache
|
150
|
-
puts
|
150
|
+
puts '%s %s %s' % ['SERVER/PORT'.ljust(30), 'PORTNAME'.ljust(20), 'COMMAND']
|
151
151
|
|
152
152
|
@cache.servers.each do |server|
|
153
153
|
server.find(_keyword).each do |port|
|
154
|
-
puts
|
154
|
+
puts '%s %s %s' % ["#{server.hostname}/#{port.port}".ljust(30), port.name.to_s.ljust(20), server.connect_command(port)]
|
155
155
|
end
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
159
|
def cmd_list(_hostname)
|
160
160
|
load_cache
|
161
|
-
puts
|
161
|
+
puts '%s %s %s' % ['SERVER/PORT'.ljust(30), 'PORTNAME'.ljust(20), 'COMMAND']
|
162
162
|
|
163
163
|
@cache.servers.each do |server|
|
164
164
|
if _hostname.nil? || server.hostname == _hostname
|
165
165
|
server.ports.each do |port|
|
166
|
-
puts
|
166
|
+
puts '%s %s %s' % ["#{server.hostname}/#{port.port}".ljust(30), port.name.to_s.ljust(20), server.connect_command(port)]
|
167
167
|
end
|
168
168
|
end
|
169
169
|
end
|
@@ -171,7 +171,7 @@ module Cow
|
|
171
171
|
|
172
172
|
def cmd_server_list
|
173
173
|
load_cache
|
174
|
-
puts
|
174
|
+
puts 'SERVER(TYPE)'
|
175
175
|
|
176
176
|
@cache.servers.each do |server|
|
177
177
|
type = nil
|
@@ -184,8 +184,7 @@ module Cow
|
|
184
184
|
def cmd_update(_hostname)
|
185
185
|
load_cache
|
186
186
|
|
187
|
-
puts
|
188
|
-
puts "%s %s" % ["SERVER/PORT".ljust(30), "PORTNAME".ljust(20)]
|
187
|
+
puts 'Updating local cache...'
|
189
188
|
|
190
189
|
edit_cache do |cache|
|
191
190
|
cache.servers.each do |server|
|
@@ -193,8 +192,9 @@ module Cow
|
|
193
192
|
puts "Updating server #{server.hostname}"
|
194
193
|
server.update_ports
|
195
194
|
|
195
|
+
puts '%s %s' % ['SERVER/PORT'.ljust(30), 'PORTNAME'.ljust(20)]
|
196
196
|
server.ports.each do |port|
|
197
|
-
puts
|
197
|
+
puts '%s %s' % ["#{server.hostname}/#{port.port}".ljust(30), port.name.to_s.ljust(20)]
|
198
198
|
end
|
199
199
|
|
200
200
|
cache.add_server server
|
data/lib/cow/plugins/acs.rb
CHANGED
@@ -3,8 +3,8 @@ require 'snmp'
|
|
3
3
|
|
4
4
|
module Cow
|
5
5
|
module ACS
|
6
|
-
OID_DESCRIPTION_LIST = '1.3.6.1.4.1.2925.4.2.6.2.1.1.3'
|
7
|
-
OID_TCPPORT_LIST = '1.3.6.1.4.1.2925.4.2.6.2.1.1.26'
|
6
|
+
OID_DESCRIPTION_LIST = '1.3.6.1.4.1.2925.4.2.6.2.1.1.3'.freeze
|
7
|
+
OID_TCPPORT_LIST = '1.3.6.1.4.1.2925.4.2.6.2.1.1.26'.freeze
|
8
8
|
|
9
9
|
class Port < Cow::Tmpl::Port
|
10
10
|
end
|
@@ -16,24 +16,26 @@ module Cow
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def connect_command(_port, _user = ENV['USER'])
|
19
|
-
|
19
|
+
"ssh -l #{_user}:#{port(_port).tcp_port} #{@hostname}"
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
23
23
|
|
24
24
|
def get_ports
|
25
25
|
ret = []
|
26
|
-
snmp
|
27
|
-
s.walk(OID_DESCRIPTION_LIST)
|
28
|
-
next if x.name.last
|
26
|
+
snmp do |s|
|
27
|
+
s.walk(OID_DESCRIPTION_LIST) do |x|
|
28
|
+
next if x.name.last.zero?
|
29
|
+
next unless (/^[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}P[0-9]{2}$/ =~ x.value.to_s).nil?
|
29
30
|
port = x.name.last
|
30
31
|
name = x.value.to_s
|
31
|
-
tcp_port = snmp{|s| break s.get_value(OID_TCPPORT_LIST + ".#{
|
32
|
+
tcp_port = snmp { |s| break s.get_value(OID_TCPPORT_LIST + ".#{port}") }
|
32
33
|
|
33
|
-
ret <<
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
ret << Cow::ACS::Port.new(port, name, tcp_port)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
ret
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
data/lib/cow/plugins/acs5000.rb
CHANGED
@@ -3,8 +3,8 @@ require 'snmp'
|
|
3
3
|
|
4
4
|
module Cow
|
5
5
|
module ACS5000
|
6
|
-
OID_DESCRIPTION_LIST = '1.3.6.1.4.1.10418.15.2.2.6.2.1.1.3'
|
7
|
-
OID_TCPPORT_LIST = '1.3.6.1.4.1.10418.15.2.2.6.2.1.1.26'
|
6
|
+
OID_DESCRIPTION_LIST = '1.3.6.1.4.1.10418.15.2.2.6.2.1.1.3'.freeze
|
7
|
+
OID_TCPPORT_LIST = '1.3.6.1.4.1.10418.15.2.2.6.2.1.1.26'.freeze
|
8
8
|
|
9
9
|
class Port < Cow::Tmpl::Port
|
10
10
|
end
|
@@ -16,24 +16,25 @@ module Cow
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def connect_command(_port, _user = ENV['USER'])
|
19
|
-
|
19
|
+
"ssh -l #{_user}:#{port(_port).tcp_port} #{@hostname}"
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
23
23
|
|
24
24
|
def get_ports
|
25
25
|
ret = []
|
26
|
-
snmp
|
27
|
-
s.walk(OID_DESCRIPTION_LIST)
|
28
|
-
next if x.name.last
|
26
|
+
snmp do |s|
|
27
|
+
s.walk(OID_DESCRIPTION_LIST) do |x|
|
28
|
+
next if x.name.last.zero?
|
29
29
|
port = x.name.last
|
30
30
|
name = x.value.to_s
|
31
|
-
tcp_port = snmp{|s| break s.get_value(OID_TCPPORT_LIST + ".#{
|
31
|
+
tcp_port = snmp { |s| break s.get_value(OID_TCPPORT_LIST + ".#{port}") }
|
32
32
|
|
33
|
-
ret <<
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
ret << Cow::ACS5000::Port.new(port, name, tcp_port)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
ret
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
data/lib/cow/plugins/acs6000.rb
CHANGED
@@ -3,7 +3,8 @@ require 'snmp'
|
|
3
3
|
|
4
4
|
module Cow
|
5
5
|
module ACS6000
|
6
|
-
OID_DESCRIPTION_LIST = '1.3.6.1.4.1.10418.16.2.3.2.1.4'
|
6
|
+
OID_DESCRIPTION_LIST = '1.3.6.1.4.1.10418.16.2.3.2.1.4'.freeze
|
7
|
+
TCP_PORT_OFFSET = 7000
|
7
8
|
|
8
9
|
class Port < Cow::Tmpl::Port
|
9
10
|
end
|
@@ -15,24 +16,25 @@ module Cow
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def connect_command(_port, _user = ENV['USER'])
|
18
|
-
|
19
|
+
"ssh -l #{_user}:#{port(_port).tcp_port} #{@hostname}"
|
19
20
|
end
|
20
21
|
|
21
22
|
private
|
22
23
|
|
23
24
|
def get_ports
|
24
25
|
ret = []
|
25
|
-
snmp
|
26
|
-
s.walk(OID_DESCRIPTION_LIST)
|
27
|
-
next if x.name.last
|
26
|
+
snmp do |s|
|
27
|
+
s.walk(OID_DESCRIPTION_LIST) do |x|
|
28
|
+
next if x.name.last.zero?
|
28
29
|
port = x.name.last
|
29
30
|
name = x.value.to_s
|
30
|
-
tcp_port = port.to_i
|
31
|
+
tcp_port = TCP_PORT_OFFSET + port.to_i
|
31
32
|
|
32
|
-
ret <<
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
ret << Cow::ACS6000::Port.new(port, name, tcp_port)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
ret
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
data/lib/cow/plugins/cisco.rb
CHANGED
@@ -3,7 +3,8 @@ require 'snmp'
|
|
3
3
|
|
4
4
|
module Cow
|
5
5
|
module Cisco
|
6
|
-
OID_DESCRIPTION_LIST = '1.3.6.1.4.1.9.2.9.2.1.8'
|
6
|
+
OID_DESCRIPTION_LIST = '1.3.6.1.4.1.9.2.9.2.1.8'.freeze
|
7
|
+
TCP_PORT_OFFSET = 2000
|
7
8
|
|
8
9
|
class Port < Cow::Tmpl::Port
|
9
10
|
end
|
@@ -16,18 +17,19 @@ module Cow
|
|
16
17
|
|
17
18
|
def get_ports
|
18
19
|
ret = []
|
19
|
-
snmp
|
20
|
-
s.walk(OID_DESCRIPTION_LIST)
|
21
|
-
next if x.name.last
|
22
|
-
next if x.value.to_s.
|
20
|
+
snmp do |s|
|
21
|
+
s.walk(OID_DESCRIPTION_LIST) do |x|
|
22
|
+
next if x.name.last.zero?
|
23
|
+
next if x.value.to_s.empty?
|
23
24
|
port = x.name.last
|
24
25
|
name = x.value.to_s
|
25
|
-
tcp_port =
|
26
|
+
tcp_port = TCP_PORT_OFFSET + port.to_i
|
26
27
|
|
27
|
-
ret <<
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
ret << Cow::Cisco::Port.new(port, name, tcp_port)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
ret
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
@@ -36,7 +38,7 @@ module Cow
|
|
36
38
|
include Cow::Cisco::Server
|
37
39
|
|
38
40
|
def connect_command(_port, _user = ENV['USER'])
|
39
|
-
|
41
|
+
"telnet #{@hostname} #{port(_port).tcp_port}"
|
40
42
|
end
|
41
43
|
end
|
42
44
|
end
|
@@ -46,7 +48,7 @@ module Cow
|
|
46
48
|
include Cow::Cisco::Server
|
47
49
|
|
48
50
|
def connect_command(_port, _user = ENV['USER'])
|
49
|
-
|
51
|
+
"ssh -l #{_user}:#{port(_port).port} #{@hostname}"
|
50
52
|
end
|
51
53
|
end
|
52
54
|
end
|
data/lib/cow/plugins/digi_ts.rb
CHANGED
@@ -3,8 +3,8 @@ require 'snmp'
|
|
3
3
|
|
4
4
|
module Cow
|
5
5
|
module DIGI_TS
|
6
|
-
OID_DESCRIPTION_LIST = '1.3.6.1.4.1.332.11.5.3.3.25.13.1.29'
|
7
|
-
OID_TCPPORT_BASE = '1.3.6.1.4.1.332.11.5.3.3.20.22.0'
|
6
|
+
OID_DESCRIPTION_LIST = '1.3.6.1.4.1.332.11.5.3.3.25.13.1.29'.freeze
|
7
|
+
OID_TCPPORT_BASE = '1.3.6.1.4.1.332.11.5.3.3.20.22.0'.freeze
|
8
8
|
|
9
9
|
class Port < Cow::Tmpl::Port
|
10
10
|
end
|
@@ -17,8 +17,8 @@ module Cow
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def connect_command(_port, _user = ENV['USER'])
|
20
|
-
#
|
21
|
-
|
20
|
+
# "ssh -l #{_user}:#{port(_port).tcp_port+500} #{@hostname}"
|
21
|
+
"telnet #{@hostname} #{port(_port).tcp_port}"
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
@@ -26,19 +26,26 @@ module Cow
|
|
26
26
|
def get_ports
|
27
27
|
ret = []
|
28
28
|
|
29
|
-
base_port = snmp{|s| break s.get_value(OID_TCPPORT_BASE)}
|
29
|
+
base_port = snmp{|s| break s.get_value(OID_TCPPORT_BASE) }
|
30
30
|
|
31
|
-
snmp
|
32
|
-
s.walk(OID_DESCRIPTION_LIST)
|
33
|
-
next if x.value.to_s.chomp.
|
31
|
+
snmp do |s|
|
32
|
+
s.walk(OID_DESCRIPTION_LIST) do |x|
|
33
|
+
next if x.value.to_s.chomp.empty?
|
34
34
|
port = x.name.last
|
35
35
|
name = x.value.to_s
|
36
|
-
tcp_port = base_port + port.to_i
|
36
|
+
tcp_port = base_port.to_i + port.to_i
|
37
37
|
|
38
|
-
ret <<
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
ret << Cow::DIGI_TS::Port.new(port, name, tcp_port)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
ret
|
43
|
+
end
|
44
|
+
|
45
|
+
def snmp
|
46
|
+
SNMP::Manager.open(host: @hostname, community: @snmp_community, version: :SNMPv1) do|snmp|
|
47
|
+
yield(snmp)
|
48
|
+
end
|
42
49
|
end
|
43
50
|
end
|
44
51
|
end
|
data/lib/cow/plugins/tmpl.rb
CHANGED
@@ -13,7 +13,7 @@ module Cow
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def initialize(_port, _name, _tcp_port)
|
16
|
-
raise ArgumentError if _port.nil?
|
16
|
+
raise ArgumentError if _port.nil? || _name.nil? || _tcp_port.nil?
|
17
17
|
|
18
18
|
@port = _port.to_s
|
19
19
|
@name = _name.to_s
|
@@ -40,7 +40,8 @@ module Cow
|
|
40
40
|
|
41
41
|
def ports
|
42
42
|
update_ports unless @ports
|
43
|
-
|
43
|
+
|
44
|
+
@ports
|
44
45
|
end
|
45
46
|
|
46
47
|
def update_ports
|
@@ -50,14 +51,9 @@ module Cow
|
|
50
51
|
def port(_port)
|
51
52
|
case _port
|
52
53
|
when Fixnum
|
53
|
-
ports.each{|p|
|
54
|
-
return p if p.port == _port
|
55
|
-
}
|
54
|
+
ports.each{|p| return p if p.port == _port}
|
56
55
|
when String
|
57
|
-
ports.each{|p|
|
58
|
-
return p if p.name == _port
|
59
|
-
}
|
60
|
-
else
|
56
|
+
ports.each{|p| return p if p.name == _port}
|
61
57
|
end
|
62
58
|
|
63
59
|
nil
|
@@ -65,9 +61,7 @@ module Cow
|
|
65
61
|
|
66
62
|
def find(_portname)
|
67
63
|
_ports = []
|
68
|
-
ports.each{|p|
|
69
|
-
_ports << p if p.name.include?(_portname)
|
70
|
-
}
|
64
|
+
ports.each{|p| _ports << p if p.name.include?(_portname) }
|
71
65
|
return _ports
|
72
66
|
end
|
73
67
|
|
@@ -90,7 +84,7 @@ module Cow
|
|
90
84
|
end
|
91
85
|
|
92
86
|
def snmp
|
93
|
-
SNMP::Manager.open(:
|
87
|
+
SNMP::Manager.open(host: @hostname, community: @snmp_community) do|snmp|
|
94
88
|
yield(snmp)
|
95
89
|
end
|
96
90
|
end
|
data/lib/cow/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-09-
|
12
|
+
date: 2016-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -84,7 +84,7 @@ files:
|
|
84
84
|
- lib/cow/plugins/digi_ts.rb
|
85
85
|
- lib/cow/plugins/tmpl.rb
|
86
86
|
- lib/cow/version.rb
|
87
|
-
homepage: https://
|
87
|
+
homepage: https://github.com/kazubu/cow/
|
88
88
|
licenses: []
|
89
89
|
post_install_message:
|
90
90
|
rdoc_options: []
|
@@ -96,18 +96,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
96
|
- - ! '>='
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
|
-
segments:
|
100
|
-
- 0
|
101
|
-
hash: -2846258190445444436
|
102
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
100
|
none: false
|
104
101
|
requirements:
|
105
102
|
- - ! '>='
|
106
103
|
- !ruby/object:Gem::Version
|
107
104
|
version: '0'
|
108
|
-
segments:
|
109
|
-
- 0
|
110
|
-
hash: -2846258190445444436
|
111
105
|
requirements: []
|
112
106
|
rubyforge_project:
|
113
107
|
rubygems_version: 1.8.23
|