network-utility 1.1.26 → 1.1.27

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