network-utility 1.1.23 → 1.1.25
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 +4 -4
- data/document/config.md +48 -20
- data/document/config.rb +1294 -0
- data/network.rb +5 -1
- data/support/snmp.rb +36 -0
- metadata +3 -1
data/network.rb
CHANGED
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
'whitelist'
|
|
10
10
|
].each{|mod|require "utility/#{mod}"}
|
|
11
11
|
|
|
12
|
+
[
|
|
13
|
+
'snmp'
|
|
14
|
+
].each{|mod|require "support/#{mod}"}
|
|
15
|
+
|
|
12
16
|
[
|
|
13
17
|
'document'
|
|
14
18
|
].each{|mod|require "document/#{mod}"}
|
|
@@ -18,5 +22,5 @@
|
|
|
18
22
|
].each{|mod|require mod}
|
|
19
23
|
|
|
20
24
|
module Network
|
|
21
|
-
VERSION = '1.1.
|
|
25
|
+
VERSION = '1.1.25'
|
|
22
26
|
end
|
data/support/snmp.rb
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#coding:utf-8
|
|
2
|
+
|
|
3
|
+
module SNMP
|
|
4
|
+
module Resolve
|
|
5
|
+
module_function
|
|
6
|
+
|
|
7
|
+
def file path, rtype=:tree
|
|
8
|
+
self.parse(File.read(path).split("\n"), rtype)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def parse texts, rtype=:tree
|
|
12
|
+
list = texts.reduce([])do|list, line|
|
|
13
|
+
if line.include?('=') && line.include?(': ')
|
|
14
|
+
list << line
|
|
15
|
+
else
|
|
16
|
+
list[-1] += "\n#{line}"
|
|
17
|
+
end
|
|
18
|
+
list
|
|
19
|
+
end
|
|
20
|
+
result_list = list.map do|line|
|
|
21
|
+
head, tail = line.split('=')
|
|
22
|
+
type, val = tail.to_s.split(': ')
|
|
23
|
+
[(head[0]=='.' ? head[1..-1] : head).strip, type.to_s.strip, val.to_s.strip]
|
|
24
|
+
end
|
|
25
|
+
return result_list if rtype==:list
|
|
26
|
+
result_tree = result_list.reduce({}){|tree,term|tree[term.first]=term;tree}
|
|
27
|
+
if rtype==:tree
|
|
28
|
+
return result_tree
|
|
29
|
+
elsif rtype==:all
|
|
30
|
+
return result_list, result_tree
|
|
31
|
+
else
|
|
32
|
+
return [], {}
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: network-utility
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.25
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt
|
|
@@ -82,6 +82,7 @@ files:
|
|
|
82
82
|
- document/bgp-NE5000E-X16A.md
|
|
83
83
|
- document/bgp-NE80E.md
|
|
84
84
|
- document/config.md
|
|
85
|
+
- document/config.rb
|
|
85
86
|
- document/document.rb
|
|
86
87
|
- document/if-ALCATEL7750.md
|
|
87
88
|
- document/if-C7609.md
|
|
@@ -218,6 +219,7 @@ files:
|
|
|
218
219
|
- document/system-NE80E.md
|
|
219
220
|
- document/telnet.md
|
|
220
221
|
- network.rb
|
|
222
|
+
- support/snmp.rb
|
|
221
223
|
- utility/ipv4_address.rb
|
|
222
224
|
- utility/ipv6_address.rb
|
|
223
225
|
- utility/mac_address.rb
|