network-utility 1.1.4
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 +7 -0
- data/README.md +2 -0
- data/document/acl-M6000-16E.md +27 -0
- data/document/acl-M6000-18S.md +27 -0
- data/document/acl-M6000-8.md +27 -0
- data/document/acl-M6000-8E.md +27 -0
- data/document/acl-MA5200G-8.md +204 -0
- data/document/acl-ME60-16.md +177 -0
- data/document/acl-ME60-X16.md +177 -0
- data/document/acl-NE40E-X16.md +204 -0
- data/document/acl-NE40E-X16A.md +204 -0
- data/document/acl-NE40E-X8.md +204 -0
- data/document/acl-NE40E.md +204 -0
- data/document/acl-NE5000E-20.md +25 -0
- data/document/acl-NE5000E-X16.md +25 -0
- data/document/acl-NE5000E-X16A.md +25 -0
- data/document/acl-NE80E.md +204 -0
- data/document/bgp-CR16010H-F.md +25 -0
- data/document/bgp-CR16018-F.md +25 -0
- data/document/bgp-CR19000-20.md +25 -0
- data/document/bgp-M6000-16E.md +25 -0
- data/document/bgp-M6000-18S.md +25 -0
- data/document/bgp-M6000-8.md +25 -0
- data/document/bgp-M6000-8E.md +25 -0
- data/document/bgp-MA5200G-8.md +25 -0
- data/document/bgp-ME60-16.md +25 -0
- data/document/bgp-ME60-X16.md +25 -0
- data/document/bgp-NE40E-X16.md +25 -0
- data/document/bgp-NE40E-X16A.md +25 -0
- data/document/bgp-NE40E-X8.md +25 -0
- data/document/bgp-NE40E.md +25 -0
- data/document/bgp-NE5000E-20.md +25 -0
- data/document/bgp-NE5000E-X16.md +25 -0
- data/document/bgp-NE5000E-X16A.md +25 -0
- data/document/bgp-NE80E.md +25 -0
- data/document/config.md +1153 -0
- data/document/document.rb +27 -0
- data/document/if-ALCATEL7750.md +48 -0
- data/document/if-C7609.md +47 -0
- data/document/if-CR16010H-F.md +300 -0
- data/document/if-CR16018-F.md +300 -0
- data/document/if-CR19000-20.md +300 -0
- data/document/if-CRS-16.md +47 -0
- data/document/if-CX600-X16A.md +349 -0
- data/document/if-CX600-X8A.md +349 -0
- data/document/if-M6000-16E.md +652 -0
- data/document/if-M6000-18S.md +846 -0
- data/document/if-M6000-8.md +653 -0
- data/document/if-M6000-8E.md +653 -0
- data/document/if-MA5200G-8.md +357 -0
- data/document/if-ME60-16.md +357 -0
- data/document/if-ME60-X16.md +357 -0
- data/document/if-NE40E-X16.md +357 -0
- data/document/if-NE40E-X16A.md +357 -0
- data/document/if-NE40E-X8.md +357 -0
- data/document/if-NE40E.md +357 -0
- data/document/if-NE5000E-20.md +357 -0
- data/document/if-NE5000E-X16.md +357 -0
- data/document/if-NE5000E-X16A.md +357 -0
- data/document/if-NE8000E-X8.md +357 -0
- data/document/if-NE80E.md +357 -0
- data/document/if-NE8100-X8.md +357 -0
- data/document/if-Nokia7750.md +48 -0
- data/document/if-T8000-18.md +653 -0
- data/document/if-V6000.md +663 -0
- data/document/if-VNE9000.md +357 -0
- data/document/if-ZXCTN9000-18EA.md +762 -0
- data/document/if-ZXCTN9000-8EA.md +762 -0
- data/document/lic-M6000-16E.md +28 -0
- data/document/lic-M6000-18S.md +28 -0
- data/document/lic-M6000-8.md +28 -0
- data/document/lic-M6000-8E.md +28 -0
- data/document/lic-MA5200G-8.md +27 -0
- data/document/lic-ME60-16.md +27 -0
- data/document/lic-ME60-X16.md +27 -0
- data/document/lic-NE40E-X16.md +27 -0
- data/document/lic-NE40E-X16A.md +27 -0
- data/document/lic-NE40E-X8.md +27 -0
- data/document/log-M6000-16E.md +36 -0
- data/document/log-M6000-18S.md +36 -0
- data/document/log-M6000-8.md +36 -0
- data/document/log-M6000-8E.md +36 -0
- data/document/log-MA5200G-8.md +61 -0
- data/document/log-ME60-16.md +61 -0
- data/document/log-ME60-X16.md +61 -0
- data/document/log-NE40E-X16.md +61 -0
- data/document/log-NE40E-X16A.md +61 -0
- data/document/log-NE40E-X8.md +61 -0
- data/document/log-NE40E.md +61 -0
- data/document/log-NE5000E-20.md +61 -0
- data/document/log-NE5000E-X16.md +61 -0
- data/document/log-NE5000E-X16A.md +61 -0
- data/document/log-NE80E.md +61 -0
- data/document/nat-CR16010H-F.md +27 -0
- data/document/nat-CR16018-F.md +27 -0
- data/document/nat-M6000-16E.md +27 -0
- data/document/nat-M6000-18S.md +27 -0
- data/document/nat-M6000-8.md +27 -0
- data/document/nat-M6000-8E.md +27 -0
- data/document/nat-ME60-16.md +44 -0
- data/document/nat-ME60-X16.md +44 -0
- data/document/nat-NE40E-X16.md +44 -0
- data/document/nat-NE40E-X16A.md +44 -0
- data/document/policy-M6000-16E.md +13 -0
- data/document/policy-M6000-18S.md +13 -0
- data/document/policy-M6000-8.md +13 -0
- data/document/policy-M6000-8E.md +13 -0
- data/document/policy-MA5200G-8.md +87 -0
- data/document/policy-ME60-16.md +87 -0
- data/document/policy-ME60-X16.md +87 -0
- data/document/policy-NE40E-X16.md +87 -0
- data/document/policy-NE40E-X16A.md +87 -0
- data/document/policy-NE40E-X8.md +87 -0
- data/document/policy-NE40E.md +87 -0
- data/document/policy-NE5000E-20.md +87 -0
- data/document/policy-NE5000E-X16.md +87 -0
- data/document/policy-NE5000E-X16A.md +87 -0
- data/document/policy-NE80E.md +87 -0
- data/document/pool-M6000-16E.md +126 -0
- data/document/pool-M6000-18S.md +126 -0
- data/document/pool-M6000-8.md +126 -0
- data/document/pool-M6000-8E.md +126 -0
- data/document/pool-MA5200G-8.md +138 -0
- data/document/pool-ME60-16.md +138 -0
- data/document/pool-ME60-X16.md +138 -0
- data/document/pool-NE40E-X16.md +138 -0
- data/document/pool-NE40E-X16A.md +138 -0
- data/document/pool-NE40E-X8.md +138 -0
- data/document/pool-NE40E.md +138 -0
- data/document/pool-NE80E.md +138 -0
- data/document/static-CR16010H-F.md +60 -0
- data/document/static-CR16018-F.md +60 -0
- data/document/static-CR19000-20.md +60 -0
- data/document/static-CX600-X16A.md +26 -0
- data/document/static-CX600-X8A.md +26 -0
- data/document/static-M6000-16E.md +104 -0
- data/document/static-M6000-18S.md +104 -0
- data/document/static-M6000-8.md +104 -0
- data/document/static-M6000-8E.md +104 -0
- data/document/static-MA5200G-8.md +82 -0
- data/document/static-ME60-16.md +82 -0
- data/document/static-ME60-X16.md +82 -0
- data/document/static-NE40E-X16.md +82 -0
- data/document/static-NE40E-X16A.md +81 -0
- data/document/static-NE40E-X8.md +82 -0
- data/document/static-NE40E.md +67 -0
- data/document/static-NE5000E-20.md +67 -0
- data/document/static-NE5000E-X16.md +67 -0
- data/document/static-NE5000E-X16A.md +67 -0
- data/document/static-NE8000E-X8.md +26 -0
- data/document/static-NE80E.md +67 -0
- data/document/static-NE8100-X8.md +26 -0
- data/document/static-T8000-18.md +34 -0
- data/document/static-ZXCTN9000-18EA.md +34 -0
- data/document/static-ZXCTN9000-8EA.md +34 -0
- data/document/system-M6000-16E.md +75 -0
- data/document/system-M6000-18S.md +76 -0
- data/document/system-M6000-8.md +75 -0
- data/document/system-M6000-8E.md +75 -0
- data/document/system-MA5200G-8.md +51 -0
- data/document/system-ME60-16.md +51 -0
- data/document/system-ME60-X16.md +51 -0
- data/document/system-NE40E-X16.md +51 -0
- data/document/system-NE40E-X16A.md +51 -0
- data/document/system-NE40E-X8.md +51 -0
- data/document/system-NE40E.md +51 -0
- data/document/system-NE5000E-20.md +51 -0
- data/document/system-NE5000E-X16.md +51 -0
- data/document/system-NE5000E-X16A.md +51 -0
- data/document/system-NE80E.md +51 -0
- data/document/telnet.md +332 -0
- data/network.rb +24 -0
- data/utility/ipv4_address.rb +266 -0
- data/utility/ipv6_address.rb +201 -0
- data/utility/mac_address.rb +77 -0
- data/utility/netmerge.rb +46 -0
- data/utility/route.rb +79 -0
- data/utility/whitelist.rb +21 -0
- metadata +258 -0
data/document/config.md
ADDED
@@ -0,0 +1,1153 @@
|
|
1
|
+
|
2
|
+
# 配置文档解析
|
3
|
+
|
4
|
+
## Alcatel
|
5
|
+
|
6
|
+
```ruby
|
7
|
+
@sign << ['ALCATEL7750', '配置解析']
|
8
|
+
|
9
|
+
module ALCATEL7750
|
10
|
+
module_function
|
11
|
+
|
12
|
+
def 配置解析 raw
|
13
|
+
conf = {}; name = nil; temp = []
|
14
|
+
raw.split("\n").each do|line|
|
15
|
+
if line[0..4]=='echo '
|
16
|
+
conf[name] = temp
|
17
|
+
temp = []
|
18
|
+
name = line.split('"')[1]
|
19
|
+
conf[name] = ''
|
20
|
+
elsif line.include?('#--------------------------------------------------')
|
21
|
+
next
|
22
|
+
else
|
23
|
+
temp << line
|
24
|
+
end
|
25
|
+
end
|
26
|
+
conf[name] = temp
|
27
|
+
conf.delete(nil)
|
28
|
+
return conf
|
29
|
+
end
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
@sign << ['Nokia7750', '配置解析']
|
35
|
+
|
36
|
+
module Nokia7750
|
37
|
+
module_function
|
38
|
+
|
39
|
+
def 配置解析 raw
|
40
|
+
conf = {}; name = nil; temp = []
|
41
|
+
raw.split("\n").each do|line|
|
42
|
+
if line[0..4]=='echo '
|
43
|
+
conf[name] = temp
|
44
|
+
temp = []
|
45
|
+
name = line.split('"')[1]
|
46
|
+
conf[name] = ''
|
47
|
+
elsif line.include?('#--------------------------------------------------')
|
48
|
+
next
|
49
|
+
else
|
50
|
+
temp << line
|
51
|
+
end
|
52
|
+
end
|
53
|
+
conf[name] = temp
|
54
|
+
conf.delete(nil)
|
55
|
+
return conf
|
56
|
+
end
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
60
|
+
## 思科
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
@sign << ['C7609', '配置解析']
|
64
|
+
|
65
|
+
module C7609
|
66
|
+
module_function
|
67
|
+
|
68
|
+
def 配置解析 raw
|
69
|
+
conf = {}; name = nil; temp = []
|
70
|
+
return conf
|
71
|
+
end
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
@sign << ['CRS-16', '配置解析']
|
77
|
+
|
78
|
+
module CRS_16
|
79
|
+
module_function
|
80
|
+
|
81
|
+
def 配置解析 raw, *guards
|
82
|
+
config = {}
|
83
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("hostname ")}.to_s.split("hostname ")[1]
|
84
|
+
prepart = raw.split("show running-config")[1]
|
85
|
+
return {} unless prepart
|
86
|
+
content = prepart.split("\nend\n")[0]
|
87
|
+
config, pretent = {}, content
|
88
|
+
while pretent.include?("!\n!"); pretent = pretent.gsub("!\n!","!") end
|
89
|
+
pieces = pretent.split("\n!\n").select{|pc|pc.strip != ''}
|
90
|
+
pieces.each do|piece|
|
91
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
92
|
+
(config[tag] ||= []) << piece
|
93
|
+
end
|
94
|
+
return config
|
95
|
+
end
|
96
|
+
end
|
97
|
+
```
|
98
|
+
|
99
|
+
## 华为
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
@sign << ['CX600-X8A', '配置解析']
|
103
|
+
@sign << ['CX600-X8A', '主机名']
|
104
|
+
|
105
|
+
module CX600_X8A
|
106
|
+
module_function
|
107
|
+
|
108
|
+
def 配置解析 braw,*guards
|
109
|
+
raw = braw
|
110
|
+
begin
|
111
|
+
raw.split("\n")
|
112
|
+
rescue
|
113
|
+
raw = braw.force_encoding('GBK').encode('UTF-8')
|
114
|
+
end
|
115
|
+
cfg = {}
|
116
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
117
|
+
# prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
118
|
+
# return cfg unless prepart
|
119
|
+
content = raw#prepart.split(/<#{hostname}>( )*\n/)[0]
|
120
|
+
pretent = "\n"+content
|
121
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
122
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
123
|
+
pieces.each do|piece|
|
124
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
125
|
+
(cfg[tag] ||= []) << piece
|
126
|
+
end
|
127
|
+
return cfg
|
128
|
+
end
|
129
|
+
|
130
|
+
def 主机名 config
|
131
|
+
config['sysname'].first.to_s.split(' ')[1]
|
132
|
+
end
|
133
|
+
end
|
134
|
+
```
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
@sign << ['CX600-X16A', '配置解析']
|
138
|
+
@sign << ['CX600-X16A', '主机名']
|
139
|
+
|
140
|
+
module CX600_X16A
|
141
|
+
module_function
|
142
|
+
|
143
|
+
def 配置解析 braw,*guards
|
144
|
+
raw = braw
|
145
|
+
begin
|
146
|
+
raw.split("\n")
|
147
|
+
rescue
|
148
|
+
raw = braw.force_encoding('GBK').encode('UTF-8')
|
149
|
+
end
|
150
|
+
cfg = {}
|
151
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
152
|
+
# prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
153
|
+
# return cfg unless prepart
|
154
|
+
content = raw#prepart.split(/<#{hostname}>( )*\n/)[0]
|
155
|
+
pretent = "\n"+content
|
156
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
157
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
158
|
+
pieces.each do|piece|
|
159
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
160
|
+
(cfg[tag] ||= []) << piece
|
161
|
+
end
|
162
|
+
return cfg
|
163
|
+
end
|
164
|
+
|
165
|
+
def 主机名 config
|
166
|
+
config['sysname'].first.to_s.split(' ')[1]
|
167
|
+
end
|
168
|
+
end
|
169
|
+
```
|
170
|
+
|
171
|
+
```ruby
|
172
|
+
@sign << ['MA5200G-8', '配置解析']
|
173
|
+
@sign << ['MA5200G-8', '主机名 ']
|
174
|
+
|
175
|
+
module MA5200G_8
|
176
|
+
module_function
|
177
|
+
|
178
|
+
def 配置解析 braw,*guards
|
179
|
+
raw = braw
|
180
|
+
begin
|
181
|
+
raw.split("\n")
|
182
|
+
rescue
|
183
|
+
raw = braw.force_encoding('GBK').encode('UTF-8')
|
184
|
+
end
|
185
|
+
cfg = {}
|
186
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
187
|
+
prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
188
|
+
return cfg unless prepart
|
189
|
+
content = prepart.split(/<#{hostname}>( )*\n/)[0]
|
190
|
+
pretent = "\n"+content
|
191
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
192
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
193
|
+
pieces.each do|piece|
|
194
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
195
|
+
(cfg[tag] ||= []) << piece
|
196
|
+
end
|
197
|
+
return cfg
|
198
|
+
end
|
199
|
+
|
200
|
+
def 主机名 config
|
201
|
+
config['sysname'].first.to_s.split(' ')[1]
|
202
|
+
end
|
203
|
+
end
|
204
|
+
```
|
205
|
+
|
206
|
+
```ruby
|
207
|
+
@sign << ['NE40E', '配置解析']
|
208
|
+
@sign << ['NE40E', '主机名 ']
|
209
|
+
|
210
|
+
module NE40E
|
211
|
+
module_function
|
212
|
+
|
213
|
+
def 配置解析 raw,*guards
|
214
|
+
cfg = {}
|
215
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
216
|
+
prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
217
|
+
return cfg unless prepart
|
218
|
+
content = prepart.split(/<#{hostname}>( )*\n/)[0]
|
219
|
+
pretent = "\n"+content
|
220
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
221
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
222
|
+
pieces.each do|piece|
|
223
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
224
|
+
(cfg[tag] ||= []) << piece
|
225
|
+
end
|
226
|
+
return cfg
|
227
|
+
end
|
228
|
+
|
229
|
+
def 主机名 config
|
230
|
+
config['sysname'].first.to_s.split(' ')[1]
|
231
|
+
end
|
232
|
+
end
|
233
|
+
```
|
234
|
+
|
235
|
+
```ruby
|
236
|
+
@sign << ['NE80E', '配置解析']
|
237
|
+
@sign << ['NE80E', '主机名 ']
|
238
|
+
|
239
|
+
module NE80E
|
240
|
+
module_function
|
241
|
+
|
242
|
+
def 配置解析 raw,*guards
|
243
|
+
cfg = {}
|
244
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
245
|
+
prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
246
|
+
return cfg unless prepart
|
247
|
+
content = prepart.split(/<#{hostname}>( )*\n/)[0]
|
248
|
+
pretent = "\n"+content
|
249
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
250
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
251
|
+
pieces.each do|piece|
|
252
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
253
|
+
(cfg[tag] ||= []) << piece
|
254
|
+
end
|
255
|
+
return cfg
|
256
|
+
end
|
257
|
+
|
258
|
+
def 主机名 config
|
259
|
+
config['sysname'].first.to_s.split(' ')[1]
|
260
|
+
end
|
261
|
+
|
262
|
+
end
|
263
|
+
```
|
264
|
+
|
265
|
+
```ruby
|
266
|
+
@sign << ['ME60-16', '配置解析']
|
267
|
+
@sign << ['ME60-16', '主机名 ']
|
268
|
+
|
269
|
+
module ME60_16
|
270
|
+
module_function
|
271
|
+
|
272
|
+
def 配置解析 braw,*guards
|
273
|
+
raw = braw
|
274
|
+
begin
|
275
|
+
raw.split("\n")
|
276
|
+
rescue
|
277
|
+
raw = braw.force_encoding('GBK').encode('UTF-8')
|
278
|
+
end
|
279
|
+
cfg = {}
|
280
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
281
|
+
prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
282
|
+
prepart = raw.split("#{hostname}>display current-configuration\n")[1] unless prepart
|
283
|
+
return cfg unless prepart
|
284
|
+
content = prepart.split(/<#{hostname}>( )*/)[0]
|
285
|
+
content = prepart.split("\nreturn")[0] unless content
|
286
|
+
pretent = "\n"+content
|
287
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
288
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
289
|
+
pieces.each do|piece|
|
290
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
291
|
+
(cfg[tag] ||= []) << piece
|
292
|
+
end
|
293
|
+
return cfg
|
294
|
+
end
|
295
|
+
|
296
|
+
def 主机名 config
|
297
|
+
config['sysname'].first.to_s.split(' ')[1]
|
298
|
+
end
|
299
|
+
end
|
300
|
+
```
|
301
|
+
|
302
|
+
```ruby
|
303
|
+
@sign << ['ME60-X16', '配置解析']
|
304
|
+
@sign << ['ME60-X16', '主机名 ']
|
305
|
+
|
306
|
+
module ME60_X16
|
307
|
+
module_function
|
308
|
+
|
309
|
+
def 配置解析 braw,*guards
|
310
|
+
raw = braw
|
311
|
+
begin
|
312
|
+
raw.split("\n")
|
313
|
+
rescue
|
314
|
+
raw = braw.force_encoding('GBK').encode('UTF-8')
|
315
|
+
end
|
316
|
+
cfg = {}
|
317
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
318
|
+
prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
319
|
+
prepart = raw.split("#{hostname}>display current-configuration\n")[1] unless prepart
|
320
|
+
return cfg unless prepart
|
321
|
+
content = prepart.split(/<#{hostname}>( )*/)[0]
|
322
|
+
content = prepart.split("\nreturn")[0] unless content
|
323
|
+
pretent = "\n"+content
|
324
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
325
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
326
|
+
pieces.each do|piece|
|
327
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
328
|
+
(cfg[tag] ||= []) << piece
|
329
|
+
end
|
330
|
+
return cfg
|
331
|
+
end
|
332
|
+
|
333
|
+
def 主机名 config
|
334
|
+
config['sysname'].first.to_s.split(' ')[1]
|
335
|
+
end
|
336
|
+
end
|
337
|
+
```
|
338
|
+
|
339
|
+
```ruby
|
340
|
+
@sign << ['NE40E-X8', '配置解析']
|
341
|
+
@sign << ['NE40E-X8', '主机名 ']
|
342
|
+
|
343
|
+
module NE40E_X8
|
344
|
+
module_function
|
345
|
+
|
346
|
+
def 配置解析 braw,*guards
|
347
|
+
raw = braw
|
348
|
+
begin
|
349
|
+
raw.split("\n")
|
350
|
+
rescue
|
351
|
+
raw = braw.force_encoding('GBK').encode('UTF-8')
|
352
|
+
end
|
353
|
+
cfg = {}
|
354
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
355
|
+
prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
356
|
+
return cfg unless prepart
|
357
|
+
content = prepart.split(/<#{hostname}>( )*\n/)[0]
|
358
|
+
pretent = "\n"+content
|
359
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
360
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
361
|
+
pieces.each do|piece|
|
362
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
363
|
+
(cfg[tag] ||= []) << piece
|
364
|
+
end
|
365
|
+
return cfg
|
366
|
+
end
|
367
|
+
|
368
|
+
def 主机名 config
|
369
|
+
config['sysname'].first.to_s.split(' ')[1]
|
370
|
+
end
|
371
|
+
end
|
372
|
+
```
|
373
|
+
|
374
|
+
```ruby
|
375
|
+
@sign << ['NE40E-X16', '配置解析']
|
376
|
+
@sign << ['NE40E-X16', '主机名 ']
|
377
|
+
|
378
|
+
module NE40E_X16
|
379
|
+
module_function
|
380
|
+
|
381
|
+
def 配置解析 braw,*guards
|
382
|
+
raw = braw
|
383
|
+
begin
|
384
|
+
raw.split("\n")
|
385
|
+
rescue
|
386
|
+
raw = braw.force_encoding('GBK').encode('UTF-8')
|
387
|
+
end
|
388
|
+
cfg = {}
|
389
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
390
|
+
prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
391
|
+
prepart = raw.split("#{hostname}>display current-configuration\n")[1] unless prepart
|
392
|
+
return cfg unless prepart
|
393
|
+
content = prepart.split(/<#{hostname}>( )*/)[0]
|
394
|
+
content = prepart.split("\nreturn")[0] unless content
|
395
|
+
pretent = "\n"+content
|
396
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
397
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
398
|
+
pieces.each do|piece|
|
399
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
400
|
+
(cfg[tag] ||= []) << piece
|
401
|
+
end
|
402
|
+
return cfg
|
403
|
+
end
|
404
|
+
|
405
|
+
def 主机名 config
|
406
|
+
config['sysname'].first.to_s.split(' ')[1]
|
407
|
+
end
|
408
|
+
end
|
409
|
+
```
|
410
|
+
|
411
|
+
```ruby
|
412
|
+
@sign << ['NE40E-X16A', '配置解析']
|
413
|
+
@sign << ['NE40E-X16A', '主机名 ']
|
414
|
+
|
415
|
+
module NE40E_X16A
|
416
|
+
module_function
|
417
|
+
|
418
|
+
def 配置解析 braw,*guards
|
419
|
+
raw = braw
|
420
|
+
begin
|
421
|
+
raw.split("\n")
|
422
|
+
rescue
|
423
|
+
raw = braw.force_encoding('GBK').encode('UTF-8')
|
424
|
+
end
|
425
|
+
cfg = {}
|
426
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
427
|
+
prepart = raw.split("display current-configuration\n").select{|part|!part.include?('>>>>')}
|
428
|
+
return cfg if prepart.empty?
|
429
|
+
content = prepart.join.split("\nreturn\n").first
|
430
|
+
pretent = "\n"+content
|
431
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
432
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
433
|
+
pieces.each do|piece|
|
434
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
435
|
+
(cfg[tag] ||= []) << piece
|
436
|
+
end
|
437
|
+
return cfg
|
438
|
+
end
|
439
|
+
|
440
|
+
def 主机名 config
|
441
|
+
config['sysname'].first.to_s.split(' ')[1]
|
442
|
+
end
|
443
|
+
|
444
|
+
end
|
445
|
+
```
|
446
|
+
|
447
|
+
```ruby
|
448
|
+
@sign << ['NE5000E-X16', '配置解析']
|
449
|
+
@sign << ['NE5000E-X16', '主机名 ']
|
450
|
+
|
451
|
+
module NE5000E_X16
|
452
|
+
module_function
|
453
|
+
|
454
|
+
def 配置解析 braw,*guards
|
455
|
+
raw = braw
|
456
|
+
begin
|
457
|
+
raw.split("\n")
|
458
|
+
rescue
|
459
|
+
raw = braw.force_encoding('GBK').encode('UTF-8')
|
460
|
+
end
|
461
|
+
cfg = {}
|
462
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
463
|
+
prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
464
|
+
return cfg unless prepart
|
465
|
+
content = prepart.split(/<#{hostname}>( )*\n/)[0]
|
466
|
+
pretent = "\n"+content
|
467
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
468
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
469
|
+
pieces.each do|piece|
|
470
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
471
|
+
(cfg[tag] ||= []) << piece
|
472
|
+
end
|
473
|
+
return cfg
|
474
|
+
end
|
475
|
+
|
476
|
+
def 主机名 config
|
477
|
+
config['sysname'].first.to_s.split(' ')[1]
|
478
|
+
end
|
479
|
+
|
480
|
+
end
|
481
|
+
```
|
482
|
+
|
483
|
+
```ruby
|
484
|
+
@sign << ['NE5000E-X16A', '配置解析']
|
485
|
+
@sign << ['NE5000E-X16A', '主机名 ']
|
486
|
+
|
487
|
+
module NE5000E_X16A
|
488
|
+
module_function
|
489
|
+
|
490
|
+
def 配置解析 braw,*guards
|
491
|
+
raw = braw
|
492
|
+
begin
|
493
|
+
raw.split("\n")
|
494
|
+
rescue
|
495
|
+
raw = braw.force_encoding('GBK').encode('UTF-8')
|
496
|
+
end
|
497
|
+
cfg = {}
|
498
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
499
|
+
prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
500
|
+
return cfg unless prepart
|
501
|
+
content = prepart.split(/<#{hostname}>( )*\n/)[0]
|
502
|
+
pretent = "\n"+content
|
503
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
504
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
505
|
+
pieces.each do|piece|
|
506
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
507
|
+
(cfg[tag] ||= []) << piece
|
508
|
+
end
|
509
|
+
return cfg
|
510
|
+
end
|
511
|
+
|
512
|
+
def 主机名 config
|
513
|
+
config['sysname'].first.to_s.split(' ')[1]
|
514
|
+
end
|
515
|
+
end
|
516
|
+
```
|
517
|
+
|
518
|
+
```ruby
|
519
|
+
@sign << ['NE5000E-20', '配置解析']
|
520
|
+
@sign << ['NE5000E-20', '主机名 ']
|
521
|
+
|
522
|
+
module NE5000E_20
|
523
|
+
module_function
|
524
|
+
|
525
|
+
def 配置解析 braw,*guards
|
526
|
+
raw = braw
|
527
|
+
begin
|
528
|
+
raw.split("\n")
|
529
|
+
rescue
|
530
|
+
raw = braw.force_encoding('GBK').encode('UTF-8')
|
531
|
+
end
|
532
|
+
cfg = {}
|
533
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
534
|
+
if raw.include?("<#{hostname}>\ndisplay current-configuration\n")
|
535
|
+
pretent = raw.split("display current-configuration")[1].split("\nreturn")[0]
|
536
|
+
else
|
537
|
+
prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
538
|
+
return cfg unless prepart
|
539
|
+
content = prepart.split(/<#{hostname}>( )*\n/)[0]
|
540
|
+
pretent = "\n"+content
|
541
|
+
end
|
542
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
543
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
544
|
+
pieces.each do|piece|
|
545
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
546
|
+
(cfg[tag] ||= []) << piece
|
547
|
+
end
|
548
|
+
return cfg
|
549
|
+
end
|
550
|
+
|
551
|
+
def 主机名 config
|
552
|
+
config['sysname'].first.to_s.split(' ')[1]
|
553
|
+
end
|
554
|
+
|
555
|
+
end
|
556
|
+
```
|
557
|
+
|
558
|
+
```ruby
|
559
|
+
@sign << ['NE8000E-X8', '配置解析']
|
560
|
+
@sign << ['NE8000E-X8', '主机名 ']
|
561
|
+
|
562
|
+
module NE8000E_X8
|
563
|
+
module_function
|
564
|
+
|
565
|
+
def 配置解析 braw,*guards
|
566
|
+
raw = braw
|
567
|
+
begin
|
568
|
+
raw.split("\n")
|
569
|
+
rescue
|
570
|
+
raw = braw.force_encoding('GBK').encode('UTF-8')
|
571
|
+
end
|
572
|
+
cfg = {}
|
573
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
574
|
+
# prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
575
|
+
# return cfg unless prepart
|
576
|
+
content = raw#prepart.split(/<#{hostname}>( )*\n/)[0]
|
577
|
+
pretent = "\n"+content
|
578
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
579
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
580
|
+
pieces.each do|piece|
|
581
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
582
|
+
(cfg[tag] ||= []) << piece
|
583
|
+
end
|
584
|
+
return cfg
|
585
|
+
end
|
586
|
+
|
587
|
+
def 主机名 config
|
588
|
+
config['sysname'].first.to_s.split(' ')[1]
|
589
|
+
end
|
590
|
+
end
|
591
|
+
```
|
592
|
+
|
593
|
+
```ruby
|
594
|
+
@sign << ['NE8100-X8', '配置解析']
|
595
|
+
@sign << ['NE8100-X8', '主机名 ']
|
596
|
+
|
597
|
+
module NE8100_X8
|
598
|
+
module_function
|
599
|
+
|
600
|
+
def 配置解析 braw,*guards
|
601
|
+
raw = braw
|
602
|
+
begin
|
603
|
+
raw.split("\n")
|
604
|
+
rescue
|
605
|
+
raw = braw.force_encoding('GBK').encode('UTF-8')
|
606
|
+
end
|
607
|
+
cfg = {}
|
608
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
609
|
+
# prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
610
|
+
# return cfg unless prepart
|
611
|
+
content = raw#prepart.split(/<#{hostname}>( )*\n/)[0]
|
612
|
+
pretent = "\n"+content
|
613
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
614
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
615
|
+
pieces.each do|piece|
|
616
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
617
|
+
(cfg[tag] ||= []) << piece
|
618
|
+
end
|
619
|
+
return cfg
|
620
|
+
end
|
621
|
+
|
622
|
+
def 主机名 config
|
623
|
+
config['sysname'].first.to_s.split(' ')[1]
|
624
|
+
end
|
625
|
+
|
626
|
+
end
|
627
|
+
```
|
628
|
+
|
629
|
+
```ruby
|
630
|
+
@sign << ['VNE9000', '配置解析']
|
631
|
+
@sign << ['VNE9000', '主机名 ']
|
632
|
+
|
633
|
+
module VNE9000
|
634
|
+
module_function
|
635
|
+
|
636
|
+
def 配置解析 braw,*guards
|
637
|
+
raw = braw
|
638
|
+
begin
|
639
|
+
raw.split("\n")
|
640
|
+
rescue
|
641
|
+
raw = braw.force_encoding('GBK').encode('UTF-8')
|
642
|
+
end
|
643
|
+
cfg = {}
|
644
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
645
|
+
# prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
646
|
+
# return cfg unless prepart
|
647
|
+
content = raw#prepart.split(/<#{hostname}>( )*\n/)[0]
|
648
|
+
pretent = "\n"+content
|
649
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
650
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
651
|
+
pieces.each do|piece|
|
652
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
653
|
+
(cfg[tag] ||= []) << piece
|
654
|
+
end
|
655
|
+
return cfg
|
656
|
+
end
|
657
|
+
|
658
|
+
def 主机名 config
|
659
|
+
config['sysname'].first.to_s.split(' ')[1]
|
660
|
+
end
|
661
|
+
end
|
662
|
+
```
|
663
|
+
|
664
|
+
## 中兴
|
665
|
+
|
666
|
+
```ruby
|
667
|
+
@sign << ['M6000', '配置解析']
|
668
|
+
@sign << ['M6000', '主机名']
|
669
|
+
|
670
|
+
module M6000
|
671
|
+
module_function
|
672
|
+
|
673
|
+
# Fix a special bug when naming as a tag
|
674
|
+
def preprocess raw
|
675
|
+
new_raw = []
|
676
|
+
raw.split("\n").each do|line|
|
677
|
+
if line.include?('<') && line.include?('>') && line[0..1]!='!<'
|
678
|
+
new_raw << line.gsub('<','<').gsub('>','>')
|
679
|
+
else
|
680
|
+
new_raw << line
|
681
|
+
end
|
682
|
+
end
|
683
|
+
return new_raw.join("\n")
|
684
|
+
end
|
685
|
+
|
686
|
+
def 配置解析 raw,*guards
|
687
|
+
cfg = {}
|
688
|
+
hostname = guards[0] || self.preprocess(raw).split("\n").find{|line|line.include?("hostname ")}.to_s.split("hostname ")[1]
|
689
|
+
# prepart = self.preprocess(raw).split(/#{hostname}#( )*show running-config( )*\n/)[1]
|
690
|
+
# return cfg unless prepart
|
691
|
+
content = self.preprocess(raw)#prepart.split(/#{hostname}#( )*\n/)[0]
|
692
|
+
|
693
|
+
begin
|
694
|
+
XmlParser.parse("<root>#{content}</root>").elements.each do|element|
|
695
|
+
cfg[element.name] = element.attributes[:text]
|
696
|
+
end
|
697
|
+
#rescue
|
698
|
+
end
|
699
|
+
cfg
|
700
|
+
end
|
701
|
+
|
702
|
+
def 主机名 config
|
703
|
+
config['system-config'].to_s.split("\n")[0].split(' ')[1]
|
704
|
+
end
|
705
|
+
end
|
706
|
+
```
|
707
|
+
|
708
|
+
```ruby
|
709
|
+
@sign << ['M6000-8', '配置解析']
|
710
|
+
@sign << ['M6000-8', '主机名']
|
711
|
+
|
712
|
+
module M6000_8
|
713
|
+
module_function
|
714
|
+
|
715
|
+
# Fix a special bug when naming as a tag
|
716
|
+
def preprocess raw
|
717
|
+
new_raw = []
|
718
|
+
raw.split("\n").each do|line|
|
719
|
+
if line.include?('<') && line.include?('>') && line[0..1]!='!<'
|
720
|
+
new_raw << line.gsub('<','<').gsub('>','>')
|
721
|
+
else
|
722
|
+
new_raw << line
|
723
|
+
end
|
724
|
+
end
|
725
|
+
return new_raw.join("\n")
|
726
|
+
end
|
727
|
+
|
728
|
+
def 配置解析 raw,*guards
|
729
|
+
cfg = {}
|
730
|
+
hostname = guards[0] || self.preprocess(raw).split("\n").find{|line|line.include?("hostname ")}.to_s.split("hostname ")[1]
|
731
|
+
prepart = self.preprocess(raw).split(/#{hostname}#( )*show running-config( )*\n/)[1]
|
732
|
+
return cfg unless prepart
|
733
|
+
content = prepart.split(/#{hostname}#( )*\n/)[0]
|
734
|
+
begin
|
735
|
+
XmlParser.parse("<root>#{content}</root>").elements.each do|element|
|
736
|
+
cfg[element.name] = element.attributes[:text]
|
737
|
+
end
|
738
|
+
#rescue
|
739
|
+
end
|
740
|
+
cfg
|
741
|
+
end
|
742
|
+
|
743
|
+
def 主机名 config
|
744
|
+
config['system-config'].to_s.split("\n")[0].split(' ')[1]
|
745
|
+
end
|
746
|
+
end
|
747
|
+
```
|
748
|
+
|
749
|
+
```ruby
|
750
|
+
@sign << ['M6000-8E', '配置解析']
|
751
|
+
@sign << ['M6000-8E', '主机名']
|
752
|
+
|
753
|
+
module M6000_8E
|
754
|
+
module_function
|
755
|
+
|
756
|
+
# Fix a special bug when naming as a tag
|
757
|
+
def preprocess raw
|
758
|
+
new_raw = []
|
759
|
+
raw.split("\n").each do|line|
|
760
|
+
if line.include?('<') && line.include?('>') && line[0..1]!='!<'
|
761
|
+
new_raw << line.gsub('<','<').gsub('>','>')
|
762
|
+
else
|
763
|
+
new_raw << line
|
764
|
+
end
|
765
|
+
end
|
766
|
+
return new_raw.join("\n")
|
767
|
+
end
|
768
|
+
|
769
|
+
def 配置解析 raw,*guards
|
770
|
+
cfg = {}
|
771
|
+
hostname = guards[0] || self.preprocess(raw).split("\n").find{|line|line.include?("hostname ")}.to_s.split("hostname ")[1]
|
772
|
+
prepart = self.preprocess(raw).split(/#{hostname}#( )*show running-config( )*\n/)[1]
|
773
|
+
return cfg unless prepart
|
774
|
+
content = prepart.split(/#{hostname}#( )*\n/)[0]
|
775
|
+
|
776
|
+
begin
|
777
|
+
XmlParser.parse("<root>#{content}</root>").elements.each do|element|
|
778
|
+
cfg[element.name] = element.attributes[:text]
|
779
|
+
end
|
780
|
+
#rescue
|
781
|
+
end
|
782
|
+
cfg
|
783
|
+
end
|
784
|
+
|
785
|
+
def 主机名 config
|
786
|
+
config['system-config'].to_s.split("\n")[0].split(' ')[1]
|
787
|
+
end
|
788
|
+
end
|
789
|
+
```
|
790
|
+
|
791
|
+
```ruby
|
792
|
+
@sign << ['M6000-16E', '配置解析']
|
793
|
+
@sign << ['M6000-16E', '主机名']
|
794
|
+
|
795
|
+
module M6000_16E
|
796
|
+
module_function
|
797
|
+
|
798
|
+
# Fix a special bug when naming as a tag
|
799
|
+
def preprocess raw
|
800
|
+
new_raw = []
|
801
|
+
raw.split("\n").each do|line|
|
802
|
+
if line.include?('<') && line.include?('>') && line[0..1]!='!<'
|
803
|
+
new_raw << line.gsub('<','<').gsub('>','>')
|
804
|
+
else
|
805
|
+
new_raw << line
|
806
|
+
end
|
807
|
+
end
|
808
|
+
return new_raw.join("\n")
|
809
|
+
end
|
810
|
+
|
811
|
+
def 配置解析 raw,*guards
|
812
|
+
cfg = {}
|
813
|
+
hostname = guards[0] || self.preprocess(raw).split("\n").find{|line|line.include?("hostname ")}.to_s.split("hostname ")[1]
|
814
|
+
prepart = self.preprocess(raw).split(/#{hostname}#( )*show running-config( )*\n/)[1]
|
815
|
+
return cfg unless prepart
|
816
|
+
content = prepart.split(/#{hostname}#( )*\n/)[0]
|
817
|
+
begin
|
818
|
+
XmlParser.parse("<root>#{content}</root>").elements.each do|element|
|
819
|
+
cfg[element.name] = element.attributes[:text]
|
820
|
+
end
|
821
|
+
#rescue
|
822
|
+
end
|
823
|
+
cfg
|
824
|
+
end
|
825
|
+
|
826
|
+
def 主机名 config
|
827
|
+
config['system-config'].to_s.split("\n")[0].split(' ')[1]
|
828
|
+
end
|
829
|
+
end
|
830
|
+
```
|
831
|
+
|
832
|
+
```ruby
|
833
|
+
@sign << ['M6000-18S', '配置解析']
|
834
|
+
@sign << ['M6000-18S', '主机名']
|
835
|
+
|
836
|
+
module M6000_18S
|
837
|
+
module_function
|
838
|
+
|
839
|
+
# Fix a special bug when naming as a tag
|
840
|
+
def preprocess raw
|
841
|
+
new_raw = []
|
842
|
+
raw.split("\n").each do|line|
|
843
|
+
if line.include?('<') && line.include?('>') && line[0..1]!='!<'
|
844
|
+
new_raw << line.gsub('<','<').gsub('>','>')
|
845
|
+
else
|
846
|
+
new_raw << line
|
847
|
+
end
|
848
|
+
end
|
849
|
+
return new_raw.join("\n")
|
850
|
+
end
|
851
|
+
|
852
|
+
def 配置解析 raw,*guards
|
853
|
+
cfg = {}
|
854
|
+
hostname = guards[0] || self.preprocess(raw).split("\n").find{|line|line.include?("hostname ")}.to_s.split("hostname ")[1]
|
855
|
+
prepart = self.preprocess(raw).split(/#{hostname}#( )*show running-config( )*\n/)[1]
|
856
|
+
return cfg unless prepart
|
857
|
+
content = prepart.split(/#{hostname}#( )*\n/)[0]
|
858
|
+
|
859
|
+
begin
|
860
|
+
XmlParser.parse("<root>#{content}</root>").elements.each do|element|
|
861
|
+
cfg[element.name] = element.attributes[:text]
|
862
|
+
end
|
863
|
+
#rescue
|
864
|
+
end
|
865
|
+
cfg
|
866
|
+
end
|
867
|
+
|
868
|
+
def 主机名 config
|
869
|
+
config['system-config'].to_s.split("\n")[0].split(' ')[1]
|
870
|
+
end
|
871
|
+
end
|
872
|
+
```
|
873
|
+
|
874
|
+
```ruby
|
875
|
+
@sign << ['T8000-18', '配置解析']
|
876
|
+
@sign << ['T8000-18', '主机名 ']
|
877
|
+
|
878
|
+
module T8000_18
|
879
|
+
module_function
|
880
|
+
|
881
|
+
# Fix a special bug when naming as a tag
|
882
|
+
def preprocess raw
|
883
|
+
new_raw = []
|
884
|
+
raw.split("\n").each do|line|
|
885
|
+
if line.include?('<') && line.include?('>') && line[0..1]!='!<'
|
886
|
+
new_raw << line.gsub('<','<').gsub('>','>')
|
887
|
+
else
|
888
|
+
new_raw << line
|
889
|
+
end
|
890
|
+
end
|
891
|
+
return new_raw.join("\n")
|
892
|
+
end
|
893
|
+
|
894
|
+
def 配置解析 raw,*guards
|
895
|
+
cfg = {}
|
896
|
+
hostname = guards[0] || self.preprocess(raw).split("\n").find{|line|line.include?("hostname ")}.to_s.split("hostname ")[1]
|
897
|
+
prepart = self.preprocess(raw).split(/#{hostname}#( )*show running-config( )*\n/)[1]
|
898
|
+
return cfg unless prepart
|
899
|
+
content = prepart.split(/#{hostname}#( )*\n/)[0]
|
900
|
+
|
901
|
+
begin
|
902
|
+
XmlParser.parse("<root>#{content}</root>").elements.each do|element|
|
903
|
+
cfg[element.name] = element.attributes[:text]
|
904
|
+
end
|
905
|
+
#rescue
|
906
|
+
end
|
907
|
+
cfg
|
908
|
+
end
|
909
|
+
|
910
|
+
def 主机名 config
|
911
|
+
config['system-config'].to_s.split("\n")[0].split(' ')[1]
|
912
|
+
end
|
913
|
+
end
|
914
|
+
```
|
915
|
+
|
916
|
+
```ruby
|
917
|
+
@sign << ['ZXCTN9000-8EA', '配置解析']
|
918
|
+
@sign << ['ZXCTN9000-8EA', '主机名 ']
|
919
|
+
|
920
|
+
module ZXCTN9000_8EA
|
921
|
+
module_function
|
922
|
+
|
923
|
+
# Fix a special bug when naming as a tag
|
924
|
+
def preprocess raw
|
925
|
+
new_raw = []
|
926
|
+
raw.split("\n").each do|line|
|
927
|
+
if line.include?('<') && line.include?('>') && line[0..1]!='!<'
|
928
|
+
new_raw << line.gsub('<','<').gsub('>','>')
|
929
|
+
else
|
930
|
+
new_raw << line
|
931
|
+
end
|
932
|
+
end
|
933
|
+
return new_raw.join("\n")
|
934
|
+
end
|
935
|
+
|
936
|
+
def 配置解析 raw,*guards
|
937
|
+
cfg = {}
|
938
|
+
hostname = guards[0] || self.preprocess(raw).split("\n").find{|line|line.include?("hostname ")}.to_s.split("hostname ")[1]
|
939
|
+
# prepart = self.preprocess(raw).split(/#{hostname}#( )*show running-config( )*\n/)[1]
|
940
|
+
# return cfg unless prepart
|
941
|
+
content = self.preprocess(raw)#prepart.split(/#{hostname}#( )*\n/)[0]
|
942
|
+
|
943
|
+
begin
|
944
|
+
XmlParser.parse("<root>#{content}</root>").elements.each do|element|
|
945
|
+
cfg[element.name] = element.attributes[:text]
|
946
|
+
end
|
947
|
+
#rescue
|
948
|
+
end
|
949
|
+
cfg
|
950
|
+
end
|
951
|
+
|
952
|
+
def 主机名 config
|
953
|
+
config['system-config'].to_s.split("\n")[0].split(' ')[1]
|
954
|
+
end
|
955
|
+
end
|
956
|
+
```
|
957
|
+
|
958
|
+
```ruby
|
959
|
+
@sign << ['ZXCTN9000-18EA', '配置解析']
|
960
|
+
@sign << ['ZXCTN9000-18EA', '主机名 ']
|
961
|
+
|
962
|
+
module ZXCTN9000_18EA
|
963
|
+
module_function
|
964
|
+
|
965
|
+
# Fix a special bug when naming as a tag
|
966
|
+
def preprocess raw
|
967
|
+
new_raw = []
|
968
|
+
raw.split("\n").each do|line|
|
969
|
+
if line.include?('<') && line.include?('>') && line[0..1]!='!<'
|
970
|
+
new_raw << line.gsub('<','<').gsub('>','>')
|
971
|
+
else
|
972
|
+
new_raw << line
|
973
|
+
end
|
974
|
+
end
|
975
|
+
return new_raw.join("\n")
|
976
|
+
end
|
977
|
+
|
978
|
+
def 配置解析 raw,*guards
|
979
|
+
cfg = {}
|
980
|
+
hostname = guards[0] || self.preprocess(raw).split("\n").find{|line|line.include?("hostname ")}.to_s.split("hostname ")[1]
|
981
|
+
# prepart = self.preprocess(raw).split(/#{hostname}#( )*show running-config( )*\n/)[1]
|
982
|
+
# return cfg unless prepart
|
983
|
+
content = self.preprocess(raw)#prepart.split(/#{hostname}#( )*\n/)[0]
|
984
|
+
|
985
|
+
begin
|
986
|
+
XmlParser.parse("<root>#{content}</root>").elements.each do|element|
|
987
|
+
cfg[element.name] = element.attributes[:text]
|
988
|
+
end
|
989
|
+
#rescue
|
990
|
+
end
|
991
|
+
cfg
|
992
|
+
end
|
993
|
+
|
994
|
+
def 主机名 config
|
995
|
+
config['system-config'].to_s.split("\n")[0].split(' ')[1]
|
996
|
+
end
|
997
|
+
end
|
998
|
+
```
|
999
|
+
|
1000
|
+
```ruby
|
1001
|
+
@sign << ['V6000', '配置解析']
|
1002
|
+
@sign << ['V6000', '主机名 ']
|
1003
|
+
|
1004
|
+
module V6000
|
1005
|
+
module_function
|
1006
|
+
|
1007
|
+
# Fix a special bug when naming as a tag
|
1008
|
+
def preprocess raw
|
1009
|
+
new_raw = []
|
1010
|
+
raw.split("\n").each do|line|
|
1011
|
+
if line.include?('<') && line.include?('>') && line[0..1]!='!<'
|
1012
|
+
new_raw << line.gsub('<','<').gsub('>','>')
|
1013
|
+
else
|
1014
|
+
new_raw << line
|
1015
|
+
end
|
1016
|
+
end
|
1017
|
+
return new_raw.join("\n")
|
1018
|
+
end
|
1019
|
+
|
1020
|
+
def 配置解析 raw,*guards
|
1021
|
+
cfg = {}
|
1022
|
+
hostname = guards[0] || self.preprocess(raw).split("\n").find{|line|line.include?("hostname ")}.to_s.split("hostname ")[1]
|
1023
|
+
# prepart = self.preprocess(raw).split(/#{hostname}#( )*show running-config( )*\n/)[1]
|
1024
|
+
# return cfg unless prepart
|
1025
|
+
content = self.preprocess(raw)#prepart.split(/#{hostname}#( )*\n/)[0]
|
1026
|
+
|
1027
|
+
begin
|
1028
|
+
XmlParser.parse("<root>#{content}</root>").elements.each do|element|
|
1029
|
+
cfg[element.name] = element.attributes[:text]
|
1030
|
+
end
|
1031
|
+
#rescue
|
1032
|
+
end
|
1033
|
+
cfg
|
1034
|
+
end
|
1035
|
+
|
1036
|
+
def 主机名 config
|
1037
|
+
config['system-config'].to_s.split("\n")[0].split(' ')[1]
|
1038
|
+
end
|
1039
|
+
end
|
1040
|
+
```
|
1041
|
+
|
1042
|
+
## 华三
|
1043
|
+
|
1044
|
+
```ruby
|
1045
|
+
@sign << ['CR16010H-F', '配置解析']
|
1046
|
+
@sign << ['CR16010H-F', '主机名']
|
1047
|
+
|
1048
|
+
module CR16010H_F
|
1049
|
+
module_function
|
1050
|
+
|
1051
|
+
def 配置解析 braw,*guards
|
1052
|
+
raw = braw
|
1053
|
+
begin
|
1054
|
+
raw.split("\n")
|
1055
|
+
rescue
|
1056
|
+
raw = braw.force_encoding('GBK').encode('UTF-8')
|
1057
|
+
end
|
1058
|
+
cfg = {}
|
1059
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
1060
|
+
prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
1061
|
+
prepart = raw.split("#{hostname}>display current-configuration\n")[1] unless prepart
|
1062
|
+
return cfg unless prepart
|
1063
|
+
content = prepart.split(/<#{hostname}>( )*/)[0]
|
1064
|
+
content = prepart.split("\nreturn")[0] unless content
|
1065
|
+
pretent = "\n"+content
|
1066
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
1067
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
1068
|
+
pieces.each do|piece|
|
1069
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
1070
|
+
(cfg[tag] ||= []) << piece
|
1071
|
+
end
|
1072
|
+
return cfg
|
1073
|
+
end
|
1074
|
+
|
1075
|
+
def 主机名 config
|
1076
|
+
config['sysname'].first.to_s.split(' ')[1]
|
1077
|
+
end
|
1078
|
+
end
|
1079
|
+
```
|
1080
|
+
|
1081
|
+
```ruby
|
1082
|
+
@sign << ['CR16018-F', '配置解析']
|
1083
|
+
@sign << ['CR16018-F', '主机名']
|
1084
|
+
|
1085
|
+
module CR16018_F
|
1086
|
+
module_function
|
1087
|
+
|
1088
|
+
def 配置解析 braw,*guards
|
1089
|
+
raw = braw
|
1090
|
+
begin
|
1091
|
+
raw.split("\n")
|
1092
|
+
rescue
|
1093
|
+
raw = braw.force_encoding('GBK').encode('UTF-8')
|
1094
|
+
end
|
1095
|
+
cfg = {}
|
1096
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
1097
|
+
prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
1098
|
+
prepart = raw.split("#{hostname}>display current-configuration\n")[1] unless prepart
|
1099
|
+
return cfg unless prepart
|
1100
|
+
content = prepart.split(/<#{hostname}>( )*/)[0]
|
1101
|
+
content = prepart.split("\nreturn")[0] unless content
|
1102
|
+
pretent = "\n"+content
|
1103
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
1104
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
1105
|
+
pieces.each do|piece|
|
1106
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
1107
|
+
(cfg[tag] ||= []) << piece
|
1108
|
+
end
|
1109
|
+
return cfg
|
1110
|
+
end
|
1111
|
+
|
1112
|
+
def 主机名 config
|
1113
|
+
config['sysname'].first.to_s.split(' ')[1]
|
1114
|
+
end
|
1115
|
+
end
|
1116
|
+
```
|
1117
|
+
|
1118
|
+
```ruby
|
1119
|
+
@sign << ['CR19000-20', '配置解析']
|
1120
|
+
@sign << ['CR19000-20', '主机名']
|
1121
|
+
|
1122
|
+
module CR19000_20
|
1123
|
+
module_function
|
1124
|
+
|
1125
|
+
def 配置解析 braw,*guards
|
1126
|
+
raw = braw
|
1127
|
+
begin
|
1128
|
+
raw.split("\n")
|
1129
|
+
rescue
|
1130
|
+
raw = braw.force_encoding('GBK').encode('UTF-8')
|
1131
|
+
end
|
1132
|
+
cfg = {}
|
1133
|
+
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
1134
|
+
prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
1135
|
+
prepart = raw.split("#{hostname}>display current-configuration\n")[1] unless prepart
|
1136
|
+
return cfg unless prepart
|
1137
|
+
content = prepart.split(/<#{hostname}>( )*/)[0]
|
1138
|
+
content = prepart.split("\nreturn")[0] unless content
|
1139
|
+
pretent = "\n"+content
|
1140
|
+
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
1141
|
+
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
1142
|
+
pieces.each do|piece|
|
1143
|
+
tag = piece.split("\n")[0].split(" ")[0]
|
1144
|
+
(cfg[tag] ||= []) << piece
|
1145
|
+
end
|
1146
|
+
return cfg
|
1147
|
+
end
|
1148
|
+
|
1149
|
+
def 主机名 config
|
1150
|
+
config['sysname'].first.to_s.split(' ')[1]
|
1151
|
+
end
|
1152
|
+
end
|
1153
|
+
```
|