network-utility 1.1.27 → 1.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/document/if-M6000-18S.md +40 -40
- data/document/if-V6000.md +210 -38
- data/document/if-ZXCTN9000-18EA.md +115 -42
- data/document/if-ZXCTN9000-8EA.md +84 -11
- data/network.rb +1 -1
- metadata +1 -1
data/document/if-V6000.md
CHANGED
|
@@ -7,8 +7,11 @@
|
|
|
7
7
|
@sign << ["V6000", "接口基本信息"]
|
|
8
8
|
@sign << ["V6000", "接口vlan信息"]
|
|
9
9
|
@sign << ["V6000", "接口acl信息"]
|
|
10
|
+
@sign << ["V6000", "接口urpf信息"]
|
|
10
11
|
@sign << ["V6000", "接口mpls信息"]
|
|
11
12
|
@sign << ["V6000", "接口lacp信息"]
|
|
13
|
+
@sign << ["V6000", "接口am信息"]
|
|
14
|
+
@sign << ["V6000", "接口uim信息"]
|
|
12
15
|
@sign << ["V6000", "接口isis信息"]
|
|
13
16
|
@sign << ["V6000", "接口multicast信息"]
|
|
14
17
|
@sign << ["V6000", "接口firload信息"]
|
|
@@ -20,6 +23,11 @@
|
|
|
20
23
|
@sign << ["V6000", "接口urpf信息"]
|
|
21
24
|
@sign << ["V6000", "接口am信息"]
|
|
22
25
|
@sign << ["V6000", "接口uim信息"]
|
|
26
|
+
@sign << ["V6000", "接口QoS"]
|
|
27
|
+
@sign << ["V6000", "接口流策略"]
|
|
28
|
+
@sign << ["V6000", "接口统计"]
|
|
29
|
+
@sign << ["V6000", "接口URPF"]
|
|
30
|
+
@sign << ["V6000", "接口接入类型"]
|
|
23
31
|
@sign << ["V6000", "特殊接口配置"]
|
|
24
32
|
@sign << ["V6000", "物理接口配置"]
|
|
25
33
|
@sign << ["V6000", "子接口配置"]
|
|
@@ -44,8 +52,20 @@ module V6000
|
|
|
44
52
|
#####################################################################################################
|
|
45
53
|
# 接口/端口配置的基本查询
|
|
46
54
|
# 接口集合 => 接口分检 => 物理接口集合,子接口集合,特殊接口集合
|
|
47
|
-
|
|
48
|
-
#
|
|
55
|
+
# 1. 接口物理信息
|
|
56
|
+
# 2. 接口基本信息
|
|
57
|
+
# 3. 接口vlan信息
|
|
58
|
+
# 4. 接口acl信息
|
|
59
|
+
# 5. 接口urpf信息
|
|
60
|
+
# 6. 接口mpls信息
|
|
61
|
+
# 7. 接口lacp信息
|
|
62
|
+
# 8. 接口am信息
|
|
63
|
+
# 9. 接口uim信息
|
|
64
|
+
# 10.接口isis信息
|
|
65
|
+
# 11.接口multicast信息
|
|
66
|
+
#
|
|
67
|
+
# 新城更新模块:
|
|
68
|
+
# 1. 主动模块:
|
|
49
69
|
# firload
|
|
50
70
|
# port-request-info
|
|
51
71
|
# if-intf
|
|
@@ -63,8 +83,8 @@ module V6000
|
|
|
63
83
|
# ospfv2
|
|
64
84
|
# ospfv3
|
|
65
85
|
# qos # 未实现
|
|
66
|
-
|
|
67
|
-
# 被动模块:(暂不关联)
|
|
86
|
+
#
|
|
87
|
+
# 2. 被动模块:(暂不关联)
|
|
68
88
|
# samgr
|
|
69
89
|
# monitor
|
|
70
90
|
# alarm
|
|
@@ -78,8 +98,8 @@ module V6000
|
|
|
78
98
|
[self.接口物理信息(正文), self.接口基本信息(正文), self.接口vlan信息(正文), self.接口acl信息(正文),
|
|
79
99
|
self.接口mpls信息(正文), self.接口isis信息(正文), self.接口multicast信息(正文), self.接口lacp信息(正文),
|
|
80
100
|
self.接口firload信息(正文), self.接口port_request_info信息(正文), self.接口ospf信息(正文),
|
|
81
|
-
self.接口arp信息(正文), self.接口nd信息(正文), self.接口interface_performance信息(正文),
|
|
82
|
-
|
|
101
|
+
self.接口arp信息(正文), self.接口nd信息(正文), self.接口interface_performance信息(正文),
|
|
102
|
+
self.接口urpf信息(正文), self.接口am信息(正文), self.接口uim信息(正文),
|
|
83
103
|
].each do|infolist|
|
|
84
104
|
infolist.each do|intf,text|
|
|
85
105
|
接口表[intf]||=[]
|
|
@@ -88,7 +108,7 @@ module V6000
|
|
|
88
108
|
end
|
|
89
109
|
接口表
|
|
90
110
|
end
|
|
91
|
-
|
|
111
|
+
|
|
92
112
|
def 接口物理信息 正文
|
|
93
113
|
tag = 正文["PORT-PHYSICAL-INFO"] ? "PORT-PHYSICAL-INFO" : "port-physical-config"
|
|
94
114
|
接口物理表 = {}
|
|
@@ -99,11 +119,11 @@ module V6000
|
|
|
99
119
|
elsif tag == "port-physical-config"
|
|
100
120
|
(正文[tag]||"").split("\n$")\
|
|
101
121
|
.collect{|l|"<#{tag}>\n"+l.strip+"\n!\n</#{tag}>" if l!="\n!"}\
|
|
102
|
-
.compact.each{|接口|接口物理表[/interface (.)*/.match(接口)[0].to_s.strip] = 接口}
|
|
122
|
+
.compact.each{|接口|接口物理表[/interface (.)*/.match(接口)[0].to_s.strip] = 接口}
|
|
103
123
|
end
|
|
104
124
|
接口物理表
|
|
105
125
|
end
|
|
106
|
-
|
|
126
|
+
|
|
107
127
|
def 接口基本信息 正文
|
|
108
128
|
tag = 正文["INTERFACE"] ? "INTERFACE" : "if-intf"
|
|
109
129
|
接口基本表 = {}
|
|
@@ -120,7 +140,7 @@ module V6000
|
|
|
120
140
|
end
|
|
121
141
|
接口基本表
|
|
122
142
|
end
|
|
123
|
-
|
|
143
|
+
|
|
124
144
|
def 接口vlan信息 正文
|
|
125
145
|
tag = 正文["VLAN"] ? "VLAN" : "vlan"
|
|
126
146
|
接口vlan表 = {}
|
|
@@ -151,6 +171,21 @@ module V6000
|
|
|
151
171
|
接口acl表
|
|
152
172
|
end
|
|
153
173
|
|
|
174
|
+
def 接口urpf信息 正文
|
|
175
|
+
tag = 正文["URPF"] ? "URPF" : "urpf"
|
|
176
|
+
接口urpf表 = {}
|
|
177
|
+
if tag == "URPF"
|
|
178
|
+
(正文[tag]||"").split("\n!")\
|
|
179
|
+
.collect{|l|"<#{tag}>\n"+l.strip+"\n!\n</#{tag}>" if l!="\n!"}\
|
|
180
|
+
.compact.each{|接口|接口urpf表[/interface (.)*/.match(接口)[0].to_s.strip]=接口}
|
|
181
|
+
elsif tag == "urpf"
|
|
182
|
+
(正文[tag]||"").split("\n$")\
|
|
183
|
+
.collect{|l|"<#{tag}>\n"+l.strip+"\n!\n</#{tag}>" if l!="\n!"}\
|
|
184
|
+
.compact.each{|接口|接口urpf表[/interface (.)*/.match(接口)[0].to_s.strip]=接口}
|
|
185
|
+
end
|
|
186
|
+
接口urpf表
|
|
187
|
+
end
|
|
188
|
+
|
|
154
189
|
def 接口mpls信息 正文
|
|
155
190
|
tag = 正文["MPLS"] ? "MPLS" : "ldp"
|
|
156
191
|
接口mpls表 = {}
|
|
@@ -165,7 +200,7 @@ module V6000
|
|
|
165
200
|
end
|
|
166
201
|
接口mpls表
|
|
167
202
|
end
|
|
168
|
-
|
|
203
|
+
|
|
169
204
|
def 接口lacp信息 正文 # trunk
|
|
170
205
|
tag = 正文["LACP"] ? "LACP" : "lacp"
|
|
171
206
|
接口lacp表 = {}
|
|
@@ -181,6 +216,50 @@ module V6000
|
|
|
181
216
|
接口lacp表
|
|
182
217
|
end
|
|
183
218
|
|
|
219
|
+
def 接口am信息 正文
|
|
220
|
+
tag = 正文["AM"] ? "AM" : "am"
|
|
221
|
+
接口am表 = {}
|
|
222
|
+
if tag == "AM"
|
|
223
|
+
context,fragments = TextAbstract.draw_fragments (正文[tag]||""), /^ interface (.)*/, /^ \$/
|
|
224
|
+
head,tail = "<#{tag}>\n#{context[0..-3]}\n","!\n</#{tag}>" # context tail(!\n)
|
|
225
|
+
fragments.each{|frag|接口am表[/interface (.)*/.match(frag)[0].to_s.strip] = head+frag+tail}
|
|
226
|
+
elsif tag == "am"
|
|
227
|
+
context,fragments = TextAbstract.draw_fragments (正文[tag]||""), /^ interface (.)*/, /^ \$/
|
|
228
|
+
head,tail = "<#{tag}>\n#{context[0..-3]}\n","!\n</#{tag}>" # context tail(!\n)
|
|
229
|
+
fragments.each{|frag|接口am表[/interface (.)*/.match(frag)[0].to_s.strip] = head+frag+tail}
|
|
230
|
+
end
|
|
231
|
+
接口am表
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def 接口uim信息 正文
|
|
235
|
+
tag = 正文["UIM"] ? "UIM" : "uim"
|
|
236
|
+
接口uim表 = {}
|
|
237
|
+
if tag =="UIM"
|
|
238
|
+
za,vcc = TextAbstract.draw_fragments (正文[tag]||""), /^vcc\-configuration/, /^\!/
|
|
239
|
+
za,vbui= TextAbstract.draw_fragments (正文[tag]||""), /^vbui\-configuration/, /^\!/
|
|
240
|
+
# vcc
|
|
241
|
+
context,fragments = TextAbstract.draw_fragments vcc.join, /^ interface (.)*/, /^ \$/
|
|
242
|
+
head,tail = "<#{tag}>\n#{context[0..-3]}","!\n</#{tag}>" # context tail(\n!\n)
|
|
243
|
+
fragments.each{|frag|接口uim表[/interface (.)*/.match(frag)[0].to_s.strip] = head+frag+tail}
|
|
244
|
+
# vbui
|
|
245
|
+
context,fragments = TextAbstract.draw_fragments vbui.join, /^ interface (.)*/, /^ \$/
|
|
246
|
+
head,tail = "<#{tag}>\n#{context[0..-3]}","!\n</#{tag}>" # context tail(\n!\n)
|
|
247
|
+
fragments.each{|frag|接口uim表[/interface (.)*/.match(frag)[0].to_s.strip] = head+frag+tail}
|
|
248
|
+
elsif tag =="uim"
|
|
249
|
+
za,vcc = TextAbstract.draw_fragments (正文[tag]||""), /^vcc\-configuration/, /^\$/
|
|
250
|
+
za,vbui= TextAbstract.draw_fragments (正文[tag]||""), /^vbui\-configuration/, /^\$/
|
|
251
|
+
# vcc
|
|
252
|
+
context,fragments = TextAbstract.draw_fragments vcc.join, /^ interface (.)*/, /^ \$/
|
|
253
|
+
head,tail = "<#{tag}>\n#{context[0..-3]}","!\n</#{tag}>" # context tail(\n!\n)
|
|
254
|
+
fragments.each{|frag|接口uim表[/interface (.)*/.match(frag)[0].to_s.strip] = head+frag+tail}
|
|
255
|
+
# vbui
|
|
256
|
+
context,fragments = TextAbstract.draw_fragments vbui.join, /^ interface (.)*/, /^ \$/
|
|
257
|
+
head,tail = "<#{tag}>\n#{context[0..-3]}","!\n</#{tag}>" # context tail(\n!\n)
|
|
258
|
+
fragments.each{|frag|接口uim表[/interface (.)*/.match(frag)[0].to_s.strip] = head+frag+tail}
|
|
259
|
+
end
|
|
260
|
+
接口uim表
|
|
261
|
+
end
|
|
262
|
+
|
|
184
263
|
def 接口isis信息 正文
|
|
185
264
|
tag = 正文["ISIS"] ? "ISIS" : "isis"
|
|
186
265
|
接口isis表 = {}
|
|
@@ -195,7 +274,7 @@ module V6000
|
|
|
195
274
|
end
|
|
196
275
|
接口isis表
|
|
197
276
|
end
|
|
198
|
-
|
|
277
|
+
|
|
199
278
|
def 接口multicast信息 正文
|
|
200
279
|
tag = 正文["MULTICAST"] ? "MULTICAST" : "multicast"
|
|
201
280
|
接口multicast表 = {}
|
|
@@ -304,7 +383,7 @@ module V6000
|
|
|
304
383
|
end
|
|
305
384
|
end
|
|
306
385
|
end
|
|
307
|
-
|
|
386
|
+
|
|
308
387
|
tag = 正文["ospfv3"] ? "ospfv3" : "ospfv3"
|
|
309
388
|
接口ospfv3表 = {}
|
|
310
389
|
if tag == "ospfv3"
|
|
@@ -336,9 +415,9 @@ module V6000
|
|
|
336
415
|
.collect{|l|"<#{tag}>\n"+l.strip+"\n!\n</#{tag}>" if l!="\n!"}\
|
|
337
416
|
.compact.each{|接口|接口urpf表[/interface (.)*/.match(接口)[0].to_s.strip]=接口}
|
|
338
417
|
end
|
|
339
|
-
接口urpf表
|
|
418
|
+
接口urpf表
|
|
340
419
|
end
|
|
341
|
-
|
|
420
|
+
|
|
342
421
|
def 接口am信息 正文
|
|
343
422
|
tag = 正文["AM"] ? "AM" : "am"
|
|
344
423
|
接口am表 = {}
|
|
@@ -353,7 +432,7 @@ module V6000
|
|
|
353
432
|
end
|
|
354
433
|
接口am表
|
|
355
434
|
end
|
|
356
|
-
|
|
435
|
+
|
|
357
436
|
def 接口uim信息 正文
|
|
358
437
|
tag = 正文["UIM"] ? "UIM" : "uim"
|
|
359
438
|
接口uim表 = {}
|
|
@@ -382,18 +461,112 @@ module V6000
|
|
|
382
461
|
end
|
|
383
462
|
接口uim表
|
|
384
463
|
end
|
|
385
|
-
|
|
464
|
+
|
|
465
|
+
# func: 端口应用QoS模板
|
|
466
|
+
def 接口QoS 正文
|
|
467
|
+
# QoS有一部分在流策略,这里只解析car限速
|
|
468
|
+
tag = 正文["CAR"] ? 'CAR' : 'car'
|
|
469
|
+
cars = {};current = nil; cars[current] = {}
|
|
470
|
+
lines = 正文[tag].to_s.split("\n")
|
|
471
|
+
lines.each_with_index do|line, index|
|
|
472
|
+
if line.include?('interface')
|
|
473
|
+
current = line.split('interface ').last
|
|
474
|
+
cars[current] ||= {}
|
|
475
|
+
end
|
|
476
|
+
if line.include?('rate-limit ')
|
|
477
|
+
if line.size==80 && lines[index+1][0..1]!=' '
|
|
478
|
+
words = (line+lines[index+1]).split(" ")
|
|
479
|
+
else
|
|
480
|
+
words = line.split(" ")
|
|
481
|
+
end
|
|
482
|
+
cars[current]['direction'] = words[words.index('rate-limit')+1]
|
|
483
|
+
cars[current]['cir'] = words.index('cir') ? words[(words.index('cir')+1)..(words.index('cir')+2)].join : ''
|
|
484
|
+
cars[current]['pir'] = words.index('pir') ? words[(words.index('pir')+1)..(words.index('pir')+2)].join : ''
|
|
485
|
+
cars[current]['cbs'] = words.index('cbs') ? words[words.index('cbs')+1]+'bytes' : ''
|
|
486
|
+
cars[current]['pbs'] = words.index('pbs') ? words[words.index('pbs')+1]+'bytes' : ''
|
|
487
|
+
cars[current]['action'] = [
|
|
488
|
+
words.index('conform-action') ? words[words.index('conform-action')+1] : '',
|
|
489
|
+
words.index('exceed-action') ? words[words.index('exceed-action')+1] : '',
|
|
490
|
+
words.index('violate-action') ? words[words.index('violate-action')+1] : ''
|
|
491
|
+
]
|
|
492
|
+
end
|
|
493
|
+
end
|
|
494
|
+
cars.delete(nil)
|
|
495
|
+
cars
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
# func: 端口应用流量模板
|
|
499
|
+
def 接口流策略 正文
|
|
500
|
+
tag = 正文["hqos"] ? 'hqos' : 'hqos'
|
|
501
|
+
svc_policy = {}
|
|
502
|
+
lines = 正文[tag].to_s.split("\n")
|
|
503
|
+
lines.each_with_index do|line, index|
|
|
504
|
+
if line.include?('service-policy')
|
|
505
|
+
words = line.split(' ')
|
|
506
|
+
interface = words[words.index('service-policy')+1]
|
|
507
|
+
direction = words[words.index('service-policy')+2]
|
|
508
|
+
template = words[words.index('service-policy')+3]
|
|
509
|
+
svc_policy[interface] ||= {}
|
|
510
|
+
svc_policy[interface][direction] = template
|
|
511
|
+
end
|
|
512
|
+
end
|
|
513
|
+
svc_policy
|
|
514
|
+
end
|
|
515
|
+
|
|
516
|
+
# func: 端口统计功能
|
|
517
|
+
def 接口统计 正文
|
|
518
|
+
tag = 正文["interface-performance"] ? 'interface-performance' : 'interface-performance'
|
|
519
|
+
intf_perf = {}; current = nil; intf_perf[current] = {}
|
|
520
|
+
lines = 正文[tag].to_s.split("\n")
|
|
521
|
+
lines.each_with_index do|line, index|
|
|
522
|
+
if line.include?('interface-performance')
|
|
523
|
+
current = line.split('interface ').last
|
|
524
|
+
end
|
|
525
|
+
if line.include?('traffic-statistics enable')
|
|
526
|
+
intf_perf[current] = :statistic_enable
|
|
527
|
+
end
|
|
528
|
+
end
|
|
529
|
+
intf_perf.delete(nil)
|
|
530
|
+
intf_perf
|
|
531
|
+
end
|
|
532
|
+
|
|
533
|
+
# func: 端口URPF功能
|
|
534
|
+
def 接口URPF 正文
|
|
535
|
+
接口urpf表 = self.接口urpf信息 正文
|
|
536
|
+
urpf = {}
|
|
537
|
+
接口urpf表.each do|intf, conf|
|
|
538
|
+
words = conf.split(' ')
|
|
539
|
+
addr = words.join.include?('ipv4') ? 'ipv4' : 'ipv6'
|
|
540
|
+
mode = words[words.index('reachable-via')+1]=='any' ? 'loose' : 'strict'
|
|
541
|
+
acl = words.index('acl-name') ? words[words.index('acl-name')+1] : 'none'
|
|
542
|
+
ignr = words.include?('ignore-default-route') ? 'ignore-default-route' : 'none'
|
|
543
|
+
urpf[intf.split(' ').last] = {'addr'=>addr, 'mode'=>mode, 'acl'=>acl, 'ignore'=>ignr}
|
|
544
|
+
end
|
|
545
|
+
urpf
|
|
546
|
+
end
|
|
547
|
+
|
|
548
|
+
# func: 端口接入类型
|
|
549
|
+
def 接口接入类型 正文
|
|
550
|
+
接口uim表 = self.接口uim信息 正文
|
|
551
|
+
access_type = {}
|
|
552
|
+
接口uim表.each do|intf, conf|
|
|
553
|
+
type = conf.include?('ip-access-type') ? conf.split('ip-access-type ').last.split("\n").first : nil
|
|
554
|
+
access_type[intf.split(' ').last] = type if type
|
|
555
|
+
end
|
|
556
|
+
access_type
|
|
557
|
+
end
|
|
558
|
+
|
|
386
559
|
def 特殊接口配置 接口集合
|
|
387
560
|
特殊接口集合 = []
|
|
388
561
|
接口集合.each do|key,configs|
|
|
389
562
|
特殊接口集合 << [key]+configs if key.include?('loopback') || key.include?('null') || \
|
|
390
563
|
key.include?('extimer') || key.include?('vbui') || key.include?('spi') || \
|
|
391
564
|
key.include?('gcvi') || key.include?('guvi') || key.include?('mgmt_eth') || \
|
|
392
|
-
key.include?('qx_eth') || key.include?('qx') || key.include?('gre_tunnel')
|
|
565
|
+
key.include?('qx_eth') || key.include?('qx') || key.include?('gre_tunnel') || key.include?('vxlan_tunnel')
|
|
393
566
|
end
|
|
394
567
|
特殊接口集合
|
|
395
568
|
end
|
|
396
|
-
|
|
569
|
+
|
|
397
570
|
def 物理接口配置 接口集合,特殊接口集合=nil
|
|
398
571
|
物理接口集合 = []
|
|
399
572
|
例外 = (特殊接口集合 ? 特殊接口集合 : (self.特殊接口配置 接口集合)).collect{|c|c[0]}
|
|
@@ -402,7 +575,7 @@ module V6000
|
|
|
402
575
|
end
|
|
403
576
|
物理接口集合
|
|
404
577
|
end
|
|
405
|
-
|
|
578
|
+
|
|
406
579
|
def 子接口配置 接口集合,特殊接口集合=nil
|
|
407
580
|
子接口集合 = []
|
|
408
581
|
例外 = (特殊接口集合 ? 特殊接口集合 : (self.特殊接口配置 接口集合)).collect{|c|c[0]}
|
|
@@ -411,7 +584,7 @@ module V6000
|
|
|
411
584
|
end
|
|
412
585
|
子接口集合
|
|
413
586
|
end
|
|
414
|
-
|
|
587
|
+
|
|
415
588
|
def 接口分捡 接口集合
|
|
416
589
|
特殊接口集合 = self.特殊接口配置 接口集合
|
|
417
590
|
物理接口集合 = self.物理接口配置 接口集合,特殊接口集合
|
|
@@ -427,19 +600,19 @@ module V6000
|
|
|
427
600
|
# func: 根据一个端口的描述信息,给出其格式化的类型、连接符、端口编号
|
|
428
601
|
def 端口识别 描述
|
|
429
602
|
描述 = 描述[0] if 描述.instance_of?(Array) # M6000取接口配置中名称部分 [name,<tag>...</tag>,...]
|
|
430
|
-
type = /xgei|gei|smartgroup|loopback|extimer|
|
|
603
|
+
type = /xgei|gei|ulei|smartgroup|loopback|eth_dslgroup|extimer|vbui|virtual_template|vei|vnfm|null|guvi|gcvi|gre_tunnel|mgmt|ulei|irb|spi|vxlan_tunnel|flexe_client|flexe_group|ptp|gps|qx_eth|qx|bvi|pw|subvlan/.match(描述)
|
|
431
604
|
类型 = type ? type.to_s : '未知类型'
|
|
432
605
|
port = /(\d+|\/|\.)*(\d+)/.match(描述.split(类型).join)
|
|
433
606
|
端口 = port ? port.to_s : '未知端口'
|
|
434
607
|
端口 = '' if 类型=='mgmt_eth'
|
|
435
|
-
连接符 = if ['smartgroup','loopback','
|
|
436
|
-
''
|
|
437
|
-
elsif ['xgei','gei','
|
|
608
|
+
连接符 = if ['smartgroup','loopback','vbui','vnfm','null','mgmt','irb','vei','vxlan_tunnel','flexe_client','flexe_group','qx','bvi','pw','subvlan','gre_tunnel','virtual_template'].include?(类型)
|
|
609
|
+
''
|
|
610
|
+
elsif ['xgei','gei','ulei','extimer','guvi','gcvi','spi','ptp','gps','qx_eth'].include?(类型)
|
|
438
611
|
'-'
|
|
439
612
|
end
|
|
440
613
|
return 类型,连接符,端口
|
|
441
614
|
end
|
|
442
|
-
|
|
615
|
+
|
|
443
616
|
# func: 根据一个端口的描述信息,给出其mac地址,若无mac则返回nil
|
|
444
617
|
def 端口MAC 描述
|
|
445
618
|
描述.each_line do|line|
|
|
@@ -450,7 +623,7 @@ module V6000
|
|
|
450
623
|
end
|
|
451
624
|
return nil
|
|
452
625
|
end
|
|
453
|
-
|
|
626
|
+
|
|
454
627
|
# func: 根据一个端口的描述信息,给出其管理状态是打开/关闭的判断
|
|
455
628
|
def 端口管理状态 描述
|
|
456
629
|
描述 = 描述[1..-1].join("\n") if 描述.instance_of?(Array) # M6000取接口配置中名称部分 [name,<tag>...</tag>,...]
|
|
@@ -483,7 +656,7 @@ module V6000
|
|
|
483
656
|
end
|
|
484
657
|
地址集
|
|
485
658
|
end
|
|
486
|
-
|
|
659
|
+
|
|
487
660
|
# func: 根据一个端口的配置给出其开关状态(配置层面的"端口管理状态")
|
|
488
661
|
def 接口开关 接口配置
|
|
489
662
|
描述 = '' # for phy_if is shutdown, for sub_if,smartgroup are open
|
|
@@ -500,7 +673,7 @@ module V6000
|
|
|
500
673
|
end
|
|
501
674
|
描述
|
|
502
675
|
end
|
|
503
|
-
|
|
676
|
+
|
|
504
677
|
# func: 根据一个端口的配置给出其关联的vpn实例
|
|
505
678
|
def 接口vpn实例 接口配置
|
|
506
679
|
实例 = ''
|
|
@@ -510,15 +683,14 @@ module V6000
|
|
|
510
683
|
实例
|
|
511
684
|
end
|
|
512
685
|
|
|
513
|
-
|
|
514
686
|
#####################################################################################################
|
|
515
687
|
# 聚合接口判定相关
|
|
516
688
|
#####################################################################################################
|
|
517
|
-
|
|
689
|
+
|
|
518
690
|
# func: 根据一个接口的描述信息,给出其所属聚合接口的信息,若非聚合端口返回空
|
|
519
691
|
def 聚合接口判定 配置
|
|
520
692
|
配置.join.split("\n").each do|描述|
|
|
521
|
-
if 描述.include?("smartgroup") && 描述.include?("mode") &&
|
|
693
|
+
if 描述.include?("smartgroup") && 描述.include?("mode") &&
|
|
522
694
|
!描述.include?("description") && !self.端口识别(配置).join.include?("smartgroup")
|
|
523
695
|
return {self.端口识别(配置).join=>"smartgroup"+描述.strip.split(" ")[1]}
|
|
524
696
|
end
|
|
@@ -574,7 +746,7 @@ module V6000
|
|
|
574
746
|
invlan = eval(pattern[1].to_s.gsub('-','..'))
|
|
575
747
|
if exvlan.instance_of?(Range)
|
|
576
748
|
exvlan.each{|exv|vlan['qinq'] << [exv,invlan]}
|
|
577
|
-
elsif exvlan.instance_of?(Fixnum
|
|
749
|
+
elsif exvlan.instance_of?(Integer) # Fixnum
|
|
578
750
|
vlan['qinq'] << [exvlan,invlan]
|
|
579
751
|
end;next
|
|
580
752
|
end
|
|
@@ -585,7 +757,7 @@ module V6000
|
|
|
585
757
|
end
|
|
586
758
|
return vlan # {vlan:[ int|range ] qinq:[ [int,int|range] ] dot1q:[ int ]}
|
|
587
759
|
end
|
|
588
|
-
|
|
760
|
+
|
|
589
761
|
def vlan统计 name,物理接口集合,子接口集合
|
|
590
762
|
bas子接口数据库,聚合接口表 = {},[]
|
|
591
763
|
聚合接口集合 = 物理接口集合.select{|物理接口|self.端口识别(物理接口)[0]=='smartgroup'}
|
|
@@ -596,7 +768,7 @@ module V6000
|
|
|
596
768
|
物理接口 = 物理接口集合.find{|物理接口|物理接口[0].split(" ")[1]==(物理接口名称)}
|
|
597
769
|
next unless self.端口管理状态(物理接口) # 物理接口关闭的不统计
|
|
598
770
|
next unless self.端口管理状态(接口配置) # 子接口关闭的不统计
|
|
599
|
-
|
|
771
|
+
|
|
600
772
|
vlan配置 = {}
|
|
601
773
|
self.vlan分捡(接口配置).each do|type,data|
|
|
602
774
|
if type=='vlan' || type=='dot1q'
|
|
@@ -605,13 +777,13 @@ module V6000
|
|
|
605
777
|
data.each{|pvlan,cvlan|vlan配置[pvlan] ||= []; vlan配置[pvlan] << cvlan}
|
|
606
778
|
end
|
|
607
779
|
end
|
|
608
|
-
|
|
780
|
+
|
|
609
781
|
子接口名称 = self.端口识别(接口配置)
|
|
610
782
|
if 子接口名称[0].include?("gei")
|
|
611
783
|
# 子接口索引 = ["eth--"+子接口名称[-1].split(".")[0].split('/')[-3..-1].join(',')] # AIBOS风格
|
|
612
784
|
子接口索引 = [子接口名称.join.split(".")[0]] # 原生风格
|
|
613
785
|
end
|
|
614
|
-
if 子接口名称[0].include?("smartgroup") &&
|
|
786
|
+
if 子接口名称[0].include?("smartgroup") &&
|
|
615
787
|
聚合接口组 = 聚合接口表.find{|聚合接口组|聚合接口组.include?(子接口名称.join.split('.')[0])}
|
|
616
788
|
聚合接口的等效名称 = 聚合接口组.clone;
|
|
617
789
|
# 聚合接口的等效名称.delete(子接口名称.join.split('.')[0]) # 除了smartgroup自身,为所有等效接口创建 # 是否保留smartgroup是个争议
|
|
@@ -640,7 +812,7 @@ module V6000
|
|
|
640
812
|
#####################################################################################################
|
|
641
813
|
# 接口相关统计信息的处理
|
|
642
814
|
#####################################################################################################
|
|
643
|
-
|
|
815
|
+
|
|
644
816
|
# gei-x/x/x.00000xxx => gei-x/x/x.xxx
|
|
645
817
|
# 一些统计场合子接口会补前置0,这里可以将其去掉
|
|
646
818
|
def 端口去0 描述
|