network-utility 1.1.31 → 1.1.32

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