network-utility 1.1.54 → 1.1.61
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/bgp-CR16010H-F.md +112 -1
- data/document/bgp-CR16018-F.md +112 -2
- data/document/bgp-CR19000-20.md +112 -2
- data/document/bgp-CRS-16.md +178 -2
- data/document/bgp-M6000-16E.md +112 -2
- data/document/bgp-M6000-18S.md +112 -2
- data/document/bgp-M6000-8.md +112 -2
- data/document/bgp-M6000-8E.md +112 -2
- data/document/bgp-ME60-16.md +112 -2
- data/document/bgp-ME60-X16.md +112 -2
- data/document/bgp-NE40E-X16.md +112 -2
- data/document/bgp-NE40E-X16A.md +112 -2
- data/document/bgp-NE40E-X8.md +112 -2
- data/document/bgp-NE5000E-20.md +112 -2
- data/document/bgp-NE5000E-X16.md +112 -2
- data/document/bgp-NE5000E-X16A.md +112 -2
- data/document/bgp-T8000-18.md +112 -1
- data/document/config.md +31 -27
- data/document/if-ALCATEL7750.md +24 -0
- data/document/if-CRS-16.md +28 -0
- data/document/if-NE40E-X16.md +11 -11
- data/document/if-Nokia7750.md +24 -0
- data/document/isis-ALCATEL7750.md +73 -0
- data/document/isis-CR16010H-F.md +66 -0
- data/document/isis-CR16018-F.md +66 -0
- data/document/isis-CR19000-20.md +66 -0
- data/document/isis-CRS-16.md +110 -0
- data/document/isis-CX600-X16A.md +1 -0
- data/document/isis-CX600-X8A.md +1 -0
- data/document/isis-M6000-16E.md +99 -0
- data/document/isis-M6000-18S.md +99 -0
- data/document/isis-M6000-8E.md +99 -0
- data/document/isis-NE40E-X16.md +141 -0
- data/document/isis-NE40E-X16A.md +1 -0
- data/document/isis-NE5000E-20.md +1 -0
- data/document/isis-NE5000E-X16.md +1 -0
- data/document/isis-NE5000E-X16A.md +1 -0
- data/document/isis-NE8000E-X8.md +1 -0
- data/document/isis-NE8100-X8.md +1 -0
- data/document/isis-Nokia7750.md +75 -0
- data/document/isis-T8000-18.md +99 -0
- data/network.rb +2 -1
- data/utility/asnum.rb +62 -0
- metadata +13 -1
|
@@ -1,12 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
# NE5000E-X16A BGP
|
|
1
|
+
# NE5000E-X16A bgp
|
|
3
2
|
|
|
4
3
|
```ruby
|
|
4
|
+
@sign << ['NE5000E-X16A', 'bgp']
|
|
5
|
+
@sign << ['NE5000E-X16A', 'bgp地址族']
|
|
5
6
|
@sign << ['NE5000E-X16A', '宣告网段解析']
|
|
6
7
|
|
|
7
8
|
module NE5000E_X16A
|
|
8
9
|
module_function
|
|
9
10
|
|
|
11
|
+
def bgp bgp配置
|
|
12
|
+
address_family, non_af_conf = self.bgp地址族 bgp配置
|
|
13
|
+
bgp, afs = {}, {}
|
|
14
|
+
non_af_conf.each do|line|
|
|
15
|
+
if line.strip[0..4]=='group'
|
|
16
|
+
groupname,mode = line.split(' ')[1..2]
|
|
17
|
+
bgp['group'] ||= {}
|
|
18
|
+
bgp['group'][groupname] ||= {}
|
|
19
|
+
bgp['group'][groupname].merge!('mode' => mode)
|
|
20
|
+
elsif line.strip[0..3]=='peer'
|
|
21
|
+
afname = 'global'
|
|
22
|
+
words = line.split(' ')
|
|
23
|
+
peername,attribute = words[1..2]
|
|
24
|
+
value = words[3..-1].join(" ")
|
|
25
|
+
afs[afname] ||= {}
|
|
26
|
+
afs[afname]['peer'] ||= {}
|
|
27
|
+
afs[afname]['peer'][peername] ||= {}
|
|
28
|
+
if value.empty?
|
|
29
|
+
afs[afname]['peer'][peername][attribute] = true
|
|
30
|
+
else
|
|
31
|
+
unless afs[afname]['peer'][peername]
|
|
32
|
+
afs[afname]['peer'][peername][attribute] ||= []
|
|
33
|
+
afs[afname]['peer'][peername][attribute] << value
|
|
34
|
+
else
|
|
35
|
+
afs[afname]['peer'][peername][attribute] = value
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
else
|
|
39
|
+
words = line.split(' ')
|
|
40
|
+
attribute = words[0]
|
|
41
|
+
value = words[1..-1].join(" ")
|
|
42
|
+
if value.empty?
|
|
43
|
+
bgp[attribute] = true
|
|
44
|
+
else
|
|
45
|
+
bgp[attribute] ||= []
|
|
46
|
+
bgp[attribute] << value
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
address_family.each do|afname, afconf|
|
|
51
|
+
afs[afname] ||= {}
|
|
52
|
+
afconf.each do|line|
|
|
53
|
+
if line.strip[0..3]=='peer'
|
|
54
|
+
words = line.split(' ')
|
|
55
|
+
peername,attribute = words[1..2]
|
|
56
|
+
value = words[3..-1].join(" ")
|
|
57
|
+
if (bgp['group']||{})[peername]
|
|
58
|
+
if value.empty?
|
|
59
|
+
bgp['group'][peername][attribute] = true
|
|
60
|
+
else
|
|
61
|
+
bgp['group'][peername][attribute] ||= []
|
|
62
|
+
bgp['group'][peername][attribute] << value
|
|
63
|
+
end
|
|
64
|
+
else
|
|
65
|
+
afs[afname]['peer'] ||= {}
|
|
66
|
+
afs[afname]['peer'][peername] ||= {}
|
|
67
|
+
if value.empty?
|
|
68
|
+
afs[afname]['peer'][peername][attribute] = true
|
|
69
|
+
else
|
|
70
|
+
afs[afname]['peer'][peername][attribute] ||= []
|
|
71
|
+
afs[afname]['peer'][peername][attribute] << value
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
elsif line.strip[0..4]=='group'
|
|
75
|
+
groupname = line.split(' ')[1]
|
|
76
|
+
bgp['group'] ||= {}
|
|
77
|
+
bgp['group'][groupname] ||= {}
|
|
78
|
+
else
|
|
79
|
+
words = line.split(' ')
|
|
80
|
+
attribute = words[0]
|
|
81
|
+
value = words[1..-1].join(" ")
|
|
82
|
+
if value.empty?
|
|
83
|
+
afs[afname][attribute] = true
|
|
84
|
+
else
|
|
85
|
+
afs[afname][attribute] ||= []
|
|
86
|
+
afs[afname][attribute] << value
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
bgp.merge!('address-family'=>afs)
|
|
92
|
+
return bgp
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def bgp地址族 bgp配置
|
|
96
|
+
address_family = {};non_af_conf = []
|
|
97
|
+
af_begin = false; af_name = 'global'
|
|
98
|
+
bgp配置.join("\n").split("\n").each do|line|
|
|
99
|
+
if line[0..11]==' ipv4-family' || line[0..11]==' ipv6-family'
|
|
100
|
+
af_begin = true
|
|
101
|
+
af_name = line.strip.gsub(' ','-')
|
|
102
|
+
address_family[af_name] ||= []
|
|
103
|
+
end
|
|
104
|
+
if line[0..1]==' #' # af_end
|
|
105
|
+
af_begin = false
|
|
106
|
+
af_name = 'global'
|
|
107
|
+
elsif line[0]=='#' # bgp_end or no-finisher
|
|
108
|
+
af_begin = false
|
|
109
|
+
af_name = 'global'
|
|
110
|
+
end
|
|
111
|
+
if af_begin
|
|
112
|
+
address_family[af_name] << line
|
|
113
|
+
else
|
|
114
|
+
non_af_conf << line unless line==' #'
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
return address_family, non_af_conf
|
|
118
|
+
end
|
|
119
|
+
|
|
10
120
|
def 宣告网段解析 配置散列
|
|
11
121
|
ranges = []
|
|
12
122
|
配置散列['bgp'].each do|segment|
|
data/document/bgp-T8000-18.md
CHANGED
|
@@ -1,11 +1,122 @@
|
|
|
1
|
-
# T8000-18
|
|
1
|
+
# T8000-18 bgp
|
|
2
2
|
|
|
3
3
|
```ruby
|
|
4
|
+
@sign << ['T8000-18', 'bgp']
|
|
5
|
+
@sign << ['T8000-18', 'bgp地址族']
|
|
4
6
|
@sign << ['T8000-18', '宣告网段解析']
|
|
5
7
|
|
|
6
8
|
module T8000_18
|
|
7
9
|
module_function
|
|
8
10
|
|
|
11
|
+
def bgp bgp配置
|
|
12
|
+
address_family, non_af_conf = self.bgp地址族 bgp配置
|
|
13
|
+
bgp, afs = {}, {}
|
|
14
|
+
non_af_conf.each do|line|
|
|
15
|
+
line = line.strip[2..-1] if line.strip[0..1]=='++' # default
|
|
16
|
+
words = line.strip.split(' ')
|
|
17
|
+
if words.include?('peer-group') && words.size==3
|
|
18
|
+
groupname = words[1]
|
|
19
|
+
bgp['group'] ||= {}
|
|
20
|
+
bgp['group'][groupname] ||= {}
|
|
21
|
+
elsif words[0]=='neighbor'
|
|
22
|
+
afname = 'global'
|
|
23
|
+
peername, attribute = words[1..2]
|
|
24
|
+
value = words[3..-1].join(" ")
|
|
25
|
+
afs[afname] ||= {}
|
|
26
|
+
afs[afname]['peer'] ||= {}
|
|
27
|
+
afs[afname]['peer'][peername] ||= {}
|
|
28
|
+
if value.empty?
|
|
29
|
+
afs[afname]['peer'][peername][attribute] = true
|
|
30
|
+
else
|
|
31
|
+
if !afs[afname]['peer'][peername] || afs[afname]['peer'][peername].is_a?(Hash)
|
|
32
|
+
afs[afname]['peer'][peername][attribute] ||= []
|
|
33
|
+
afs[afname]['peer'][peername][attribute] << value
|
|
34
|
+
else
|
|
35
|
+
afs[afname]['peer'][peername][attribute] = value
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
else
|
|
39
|
+
attribute = words[0]
|
|
40
|
+
value = words[1..-1].join(" ")
|
|
41
|
+
if value.empty?
|
|
42
|
+
bgp[attribute] = true
|
|
43
|
+
else
|
|
44
|
+
bgp[attribute] ||= []
|
|
45
|
+
bgp[attribute] << value
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
address_family.each do|afname, afconf|
|
|
50
|
+
afs[afname] ||= {}
|
|
51
|
+
afconf.each do|line|
|
|
52
|
+
words = line.strip.split(' ')
|
|
53
|
+
if words[0]=='neighbor'
|
|
54
|
+
peername,attribute = words[1..2]
|
|
55
|
+
value = words[3..-1].join(" ")
|
|
56
|
+
if (bgp['group']||{})[peername]
|
|
57
|
+
if value.empty?
|
|
58
|
+
bgp['group'][peername][attribute] = true
|
|
59
|
+
else
|
|
60
|
+
bgp['group'][peername][attribute] ||= []
|
|
61
|
+
bgp['group'][peername][attribute] << value
|
|
62
|
+
end
|
|
63
|
+
else
|
|
64
|
+
afs[afname]['peer'] ||= {}
|
|
65
|
+
afs[afname]['peer'][peername] ||= {}
|
|
66
|
+
if value.empty?
|
|
67
|
+
afs[afname]['peer'][peername][attribute] = true
|
|
68
|
+
else
|
|
69
|
+
afs[afname]['peer'][peername][attribute] ||= []
|
|
70
|
+
afs[afname]['peer'][peername][attribute] << value
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
elsif words.include?('peer-group') && words.size==3
|
|
74
|
+
groupname = line.split(' ')[1]
|
|
75
|
+
bgp['group'] ||= {}
|
|
76
|
+
bgp['group'][groupname] ||= {}
|
|
77
|
+
else
|
|
78
|
+
words = line.split(' ')
|
|
79
|
+
attribute = words[0]
|
|
80
|
+
value = words[1..-1].join(" ")
|
|
81
|
+
if value.empty?
|
|
82
|
+
afs[afname][attribute] = true
|
|
83
|
+
else
|
|
84
|
+
afs[afname][attribute] ||= []
|
|
85
|
+
afs[afname][attribute] << value
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
bgp.merge!('address-family'=>afs)
|
|
91
|
+
return bgp
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def bgp地址族 bgp配置
|
|
95
|
+
address_family = {};non_af_conf = []
|
|
96
|
+
af_begin = false; af_name = 'global'
|
|
97
|
+
bgp配置.join("\n").split("\n").each do|line|
|
|
98
|
+
line = line.strip[2..-1] if line.strip[0..1]=='++' # default
|
|
99
|
+
if line[0..15]==' address-family'
|
|
100
|
+
af_begin = true
|
|
101
|
+
af_name = line.split(' ')[1..-1].join('-')
|
|
102
|
+
address_family[af_name] ||= []
|
|
103
|
+
end
|
|
104
|
+
if line[0..2]==' $' # af_end
|
|
105
|
+
af_begin = false
|
|
106
|
+
af_name = 'global'
|
|
107
|
+
elsif line[0]=='$' # bgp_end or no-finisher
|
|
108
|
+
af_begin = false
|
|
109
|
+
af_name = 'global'
|
|
110
|
+
end
|
|
111
|
+
if af_begin
|
|
112
|
+
address_family[af_name] << line
|
|
113
|
+
else
|
|
114
|
+
non_af_conf << line unless line.strip=='$'
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
return address_family, non_af_conf
|
|
118
|
+
end
|
|
119
|
+
|
|
9
120
|
def 宣告网段解析 配置散列
|
|
10
121
|
ranges = []
|
|
11
122
|
segment = 配置散列['bgp']
|
data/document/config.md
CHANGED
|
@@ -10,20 +10,17 @@ module ALCATEL7750
|
|
|
10
10
|
module_function
|
|
11
11
|
|
|
12
12
|
def 配置解析 raw
|
|
13
|
-
conf = {}; name = nil;
|
|
13
|
+
conf = {}; name = nil;conf[name] ||= []
|
|
14
14
|
raw.gsub("\r",'').split("\n").each do|line|
|
|
15
15
|
if line[0..4]=='echo '
|
|
16
|
-
conf[name] = temp
|
|
17
|
-
temp = []
|
|
18
16
|
name = line.split('"')[1]
|
|
19
|
-
conf[name]
|
|
17
|
+
conf[name] ||= []
|
|
20
18
|
elsif line.include?('#--------------------------------------------------')
|
|
21
19
|
next
|
|
22
20
|
else
|
|
23
|
-
|
|
21
|
+
conf[name] << line
|
|
24
22
|
end
|
|
25
23
|
end
|
|
26
|
-
conf[name] = temp
|
|
27
24
|
conf.delete(nil)
|
|
28
25
|
return conf
|
|
29
26
|
end
|
|
@@ -37,20 +34,17 @@ module Nokia7750
|
|
|
37
34
|
module_function
|
|
38
35
|
|
|
39
36
|
def 配置解析 raw
|
|
40
|
-
conf = {}; name = nil;
|
|
37
|
+
conf = {}; name = nil;conf[name] ||= []
|
|
41
38
|
raw.gsub("\r",'').split("\n").each do|line|
|
|
42
39
|
if line[0..4]=='echo '
|
|
43
|
-
conf[name] = temp
|
|
44
|
-
temp = []
|
|
45
40
|
name = line.split('"')[1]
|
|
46
|
-
conf[name]
|
|
41
|
+
conf[name] ||= []
|
|
47
42
|
elsif line.include?('#--------------------------------------------------')
|
|
48
43
|
next
|
|
49
44
|
else
|
|
50
|
-
|
|
45
|
+
conf[name] << line
|
|
51
46
|
end
|
|
52
47
|
end
|
|
53
|
-
conf[name] = temp
|
|
54
48
|
conf.delete(nil)
|
|
55
49
|
return conf
|
|
56
50
|
end
|
|
@@ -457,10 +451,17 @@ module NE40E_X16A
|
|
|
457
451
|
end
|
|
458
452
|
cfg = {}
|
|
459
453
|
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
454
|
+
if raw.include?("<#{hostname}>\ndisplay current-configuration\n") # unsync calling
|
|
455
|
+
pretent = raw.split("display current-configuration")[1..-1].join('display current-configuration').split("\nreturn")[0]
|
|
456
|
+
else
|
|
457
|
+
if matcher = raw.match(/#{hostname}>( )*display current-configuration( )*\n/) # sync calling
|
|
458
|
+
prepart = raw.split(matcher.to_s).last
|
|
459
|
+
else # no 'display current-configuration' cmd calling
|
|
460
|
+
prepart = raw
|
|
461
|
+
end
|
|
462
|
+
content = prepart.split("\nreturn\n<")[0]
|
|
463
|
+
pretent = "\n"+content+"\nreturn"
|
|
464
|
+
end
|
|
464
465
|
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
|
465
466
|
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
|
466
467
|
pieces.each do|piece|
|
|
@@ -576,13 +577,16 @@ module NE5000E_20
|
|
|
576
577
|
end
|
|
577
578
|
cfg = {}
|
|
578
579
|
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
|
579
|
-
if raw.include?("<#{hostname}>\ndisplay current-configuration\n")
|
|
580
|
-
pretent = raw.split("display current-configuration")[1].split("\nreturn")[0]
|
|
580
|
+
if raw.include?("<#{hostname}>\ndisplay current-configuration\n") # unsync calling
|
|
581
|
+
pretent = raw.split("display current-configuration")[1..-1].join('display current-configuration').split("\nreturn")[0]
|
|
581
582
|
else
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
583
|
+
if matcher = raw.match(/#{hostname}>( )*display current-configuration( )*\n/) # sync calling
|
|
584
|
+
prepart = raw.split(matcher.to_s).last
|
|
585
|
+
else # no 'display current-configuration' cmd calling
|
|
586
|
+
prepart = raw
|
|
587
|
+
end
|
|
588
|
+
content = prepart.split("\nreturn\n<")[0]
|
|
589
|
+
pretent = "\n"+content+"\nreturn"
|
|
586
590
|
end
|
|
587
591
|
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
|
588
592
|
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
|
@@ -1350,11 +1354,11 @@ module CR19000_20
|
|
|
1350
1354
|
end
|
|
1351
1355
|
cfg = {}
|
|
1352
1356
|
hostname = guards[0] || raw.split("\n").find{|line|line.include?("sysname ")}.to_s.split("sysname ")[1]
|
|
1353
|
-
prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
|
1354
|
-
prepart = raw.split("#{hostname}>display current-configuration\n")[1] unless prepart
|
|
1355
|
-
return cfg unless prepart
|
|
1356
|
-
content = prepart.split(/<#{hostname}>( )
|
|
1357
|
-
content = prepart.split("\nreturn")[0] unless content
|
|
1357
|
+
# prepart = raw.split(/#{hostname}>( )*display current-configuration( )*\n/)[1]
|
|
1358
|
+
# prepart = raw.split("#{hostname}>display current-configuration\n")[1] unless prepart
|
|
1359
|
+
# return cfg unless prepart
|
|
1360
|
+
content = raw#prepart.split(/<#{hostname}>( )*\n/)[0]
|
|
1361
|
+
# content = prepart.split("\nreturn")[0] unless content
|
|
1358
1362
|
pretent = "\n"+content
|
|
1359
1363
|
while pretent.include?("\n#\n#"); pretent = pretent.gsub("\n#\n#","\n#") end
|
|
1360
1364
|
pieces = pretent.split("\n#\n").select{|pc|pc.strip != ''}
|
data/document/if-ALCATEL7750.md
CHANGED
|
@@ -206,5 +206,29 @@ module ALCATEL7750
|
|
|
206
206
|
|
|
207
207
|
def 接口流策略 接口配置
|
|
208
208
|
end
|
|
209
|
+
|
|
210
|
+
#####################################################################################################
|
|
211
|
+
# 聚合接口判定相关
|
|
212
|
+
#####################################################################################################
|
|
213
|
+
|
|
214
|
+
# func: 根据一个接口的描述信息,给出其所属聚合接口的信息,若非聚合端口返回空
|
|
215
|
+
def 聚合接口判定 配置
|
|
216
|
+
{}
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# func: 给出聚合接口和物理接口的集合,通过计算找出所有聚合接口的集合
|
|
220
|
+
def 聚合接口分捡 聚合接口,物理接口集合
|
|
221
|
+
聚合接口 = self.端口识别(聚合接口)
|
|
222
|
+
聚合接口集合 = [聚合接口.join]
|
|
223
|
+
物理接口集合.each do|物理接口| 物理接口.each_line do|line|
|
|
224
|
+
聚合接口集合 << self.端口识别(物理接口).join if line.include?("bundle id #{聚合接口[-1]}")
|
|
225
|
+
end end
|
|
226
|
+
聚合接口集合
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# func: 根据一个接口的描述信息,给出其所属聚合接口的逻辑接口,若无返回空
|
|
230
|
+
def 聚合逻辑接口 配置
|
|
231
|
+
return nil
|
|
232
|
+
end
|
|
209
233
|
end
|
|
210
234
|
```
|
data/document/if-CRS-16.md
CHANGED
|
@@ -95,5 +95,33 @@ module CRS_16
|
|
|
95
95
|
end
|
|
96
96
|
traffic
|
|
97
97
|
end
|
|
98
|
+
|
|
99
|
+
#####################################################################################################
|
|
100
|
+
# 聚合接口判定相关
|
|
101
|
+
#####################################################################################################
|
|
102
|
+
|
|
103
|
+
# func: 根据一个接口的描述信息,给出其所属聚合接口的信息,若非聚合端口返回空
|
|
104
|
+
def 聚合接口判定 配置
|
|
105
|
+
配置.split("\n").each do|描述|
|
|
106
|
+
if 描述.include?("bundle id") && !描述.include?("description")
|
|
107
|
+
return {self.端口识别(配置).join=>"Bundle-Ether"+描述.split("id ")[1].split(' ').first}
|
|
108
|
+
end
|
|
109
|
+
end;{}
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# func: 给出聚合接口和物理接口的集合,通过计算找出所有聚合接口的集合
|
|
113
|
+
def 聚合接口分捡 聚合接口,物理接口集合
|
|
114
|
+
聚合接口 = self.端口识别(聚合接口)
|
|
115
|
+
聚合接口集合 = [聚合接口.join]
|
|
116
|
+
物理接口集合.each do|物理接口| 物理接口.each_line do|line|
|
|
117
|
+
聚合接口集合 << self.端口识别(物理接口).join if line.include?("bundle id #{聚合接口[-1]}")
|
|
118
|
+
end end
|
|
119
|
+
聚合接口集合
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# func: 根据一个接口的描述信息,给出其所属聚合接口的逻辑接口,若无返回空
|
|
123
|
+
def 聚合逻辑接口 配置
|
|
124
|
+
return nil
|
|
125
|
+
end
|
|
98
126
|
end
|
|
99
127
|
```
|
data/document/if-NE40E-X16.md
CHANGED
|
@@ -68,7 +68,7 @@ module NE40E_X16
|
|
|
68
68
|
# func: 根据一个端口的描述信息,给出其格式化的类型、连接符、端口编号
|
|
69
69
|
def 端口识别 描述
|
|
70
70
|
连接符 = ''
|
|
71
|
-
type = /100GE|GE|GigabitEthernet|Global\-VE|Pos|Ethernet|Eth\-Trunk|Ip-Trunk|ServiceIf|Tunnel|Vlanif|Virtual\-Template|NULL|LoopBack|Logic\-Channel|Aux/.match(描述)
|
|
71
|
+
type = /100GE|GE|GigabitEthernet|Global\-VE|Pos|Ethernet|Eth\-Trunk|Ip-Trunk|ServiceIf|Tunnel|Vlanif|Virtual\-Template|NULL|LoopBack|Logic\-Channel|Atm|Aux/.match(描述)
|
|
72
72
|
类型 = type ? type.to_s : '未知类型'
|
|
73
73
|
port = /(\d+|\/|\.)*(\d+)/.match(描述.split(类型).join)
|
|
74
74
|
端口 = port ? port.to_s : '未知端口'
|
|
@@ -121,14 +121,14 @@ module NE40E_X16
|
|
|
121
121
|
# func: 根据一个端口的配置给出其开关状态(配置层面的"端口管理状态")
|
|
122
122
|
def 接口开关 接口配置
|
|
123
123
|
描述 = ''
|
|
124
|
-
接口配置.each_line do|line|
|
|
124
|
+
接口配置.each_line do|line|
|
|
125
125
|
if line.include?('shutdown') and !line.include?('no') and !line.include?('undo') and !line.include?('description')
|
|
126
126
|
描述 = 'shutdown'; break
|
|
127
127
|
end
|
|
128
128
|
end
|
|
129
129
|
描述
|
|
130
130
|
end
|
|
131
|
-
|
|
131
|
+
|
|
132
132
|
# func: 根据一个端口的配置给出其关联的vpn实例
|
|
133
133
|
def 接口vpn实例 接口配置
|
|
134
134
|
实例 = ''
|
|
@@ -214,7 +214,7 @@ module NE40E_X16
|
|
|
214
214
|
#####################################################################################################
|
|
215
215
|
# 聚合接口判定相关
|
|
216
216
|
#####################################################################################################
|
|
217
|
-
|
|
217
|
+
|
|
218
218
|
# func: 根据一个接口的描述信息,给出其所属聚合接口的信息,若非聚合端口返回空
|
|
219
219
|
def 聚合接口判定 配置
|
|
220
220
|
配置.split("\n").each do|描述|
|
|
@@ -290,18 +290,18 @@ module NE40E_X16
|
|
|
290
290
|
end
|
|
291
291
|
return vlan # {vlan:[ int|range ] qinq:[ [int,int|range] ] dot1q:[ int ]}
|
|
292
292
|
end
|
|
293
|
-
|
|
293
|
+
|
|
294
294
|
def vlan统计 name,物理接口集合,子接口集合
|
|
295
295
|
bas子接口数据库,聚合接口表 = {},[]
|
|
296
296
|
聚合接口集合 = 物理接口集合.select{|物理接口|self.端口识别(物理接口)[0]=='Eth-Trunk'}
|
|
297
297
|
聚合接口表 += 聚合接口集合.collect{|聚合接口|self.聚合接口分捡(聚合接口,物理接口集合)}
|
|
298
|
-
|
|
298
|
+
|
|
299
299
|
子接口集合.each do|接口配置|
|
|
300
300
|
物理接口名称 = self.端口识别(接口配置).join.split(".")[0]
|
|
301
301
|
物理接口 = 物理接口集合.find{|物理接口|物理接口.split("\n")[0].split(" ")[1]==(物理接口名称)}
|
|
302
302
|
next unless self.端口管理状态(物理接口) # 物理接口关闭的不统计
|
|
303
303
|
next unless self.端口管理状态(接口配置) # 子接口关闭的不统计
|
|
304
|
-
|
|
304
|
+
|
|
305
305
|
vlan配置 = {}
|
|
306
306
|
self.vlan分捡(接口配置).each do|type,data|
|
|
307
307
|
if type=='vlan'
|
|
@@ -312,7 +312,7 @@ module NE40E_X16
|
|
|
312
312
|
# discard dot1q
|
|
313
313
|
end
|
|
314
314
|
end
|
|
315
|
-
|
|
315
|
+
|
|
316
316
|
子接口名称 = self.端口识别(接口配置)
|
|
317
317
|
bas子接口数据库[name] ||= {}
|
|
318
318
|
子接口索引 = []
|
|
@@ -320,7 +320,7 @@ module NE40E_X16
|
|
|
320
320
|
# 子接口索引 = ["eth--"+子接口名称[-1].split(".")[0].split('/')[-3..-1].join(',')] # AIBOS风格
|
|
321
321
|
子接口索引 = [子接口名称.join.split(".")[0]] # 原生风格
|
|
322
322
|
end
|
|
323
|
-
if 子接口名称[0].include?("Eth-Trunk") &&
|
|
323
|
+
if 子接口名称[0].include?("Eth-Trunk") &&
|
|
324
324
|
聚合接口组 = 聚合接口表.find{|聚合接口组|聚合接口组.include?(子接口名称.join.split('.')[0])}
|
|
325
325
|
聚合接口的等效名称 = 聚合接口组.clone
|
|
326
326
|
#聚合接口的等效名称.delete(子接口名称.join.split('.')[0]) # 除了trunk自身,为所有等效接口创建 # 是否保留Trunk是个争议
|
|
@@ -329,7 +329,7 @@ module NE40E_X16
|
|
|
329
329
|
self.端口识别(等效名称).join.split(".")[0] # 原生风格
|
|
330
330
|
end
|
|
331
331
|
end
|
|
332
|
-
|
|
332
|
+
|
|
333
333
|
子接口索引.each do|索引|
|
|
334
334
|
bas子接口数据库[name][索引] ||= {}
|
|
335
335
|
vlan配置.each do|pv,cv|
|
|
@@ -346,7 +346,7 @@ module NE40E_X16
|
|
|
346
346
|
#####################################################################################################
|
|
347
347
|
# 接口相关统计信息的处理
|
|
348
348
|
#####################################################################################################
|
|
349
|
-
|
|
349
|
+
|
|
350
350
|
# 针对display interface brief main
|
|
351
351
|
def 统计接口 文本
|
|
352
352
|
文本.split("\n").inject([]) do|表格, 行|
|
data/document/if-Nokia7750.md
CHANGED
|
@@ -206,5 +206,29 @@ module Nokia7750
|
|
|
206
206
|
|
|
207
207
|
def 接口流策略 接口配置
|
|
208
208
|
end
|
|
209
|
+
|
|
210
|
+
#####################################################################################################
|
|
211
|
+
# 聚合接口判定相关
|
|
212
|
+
#####################################################################################################
|
|
213
|
+
|
|
214
|
+
# func: 根据一个接口的描述信息,给出其所属聚合接口的信息,若非聚合端口返回空
|
|
215
|
+
def 聚合接口判定 配置
|
|
216
|
+
{}
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# func: 给出聚合接口和物理接口的集合,通过计算找出所有聚合接口的集合
|
|
220
|
+
def 聚合接口分捡 聚合接口,物理接口集合
|
|
221
|
+
聚合接口 = self.端口识别(聚合接口)
|
|
222
|
+
聚合接口集合 = [聚合接口.join]
|
|
223
|
+
物理接口集合.each do|物理接口| 物理接口.each_line do|line|
|
|
224
|
+
聚合接口集合 << self.端口识别(物理接口).join if line.include?("bundle id #{聚合接口[-1]}")
|
|
225
|
+
end end
|
|
226
|
+
聚合接口集合
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# func: 根据一个接口的描述信息,给出其所属聚合接口的逻辑接口,若无返回空
|
|
230
|
+
def 聚合逻辑接口 配置
|
|
231
|
+
return nil
|
|
232
|
+
end
|
|
209
233
|
end
|
|
210
234
|
```
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# ALCATEL7750 isis
|
|
2
|
+
|
|
3
|
+
```ruby
|
|
4
|
+
@sign << ['ALCATEL7750', '接口isis']
|
|
5
|
+
@sign << ['ALCATEL7750', 'isis']
|
|
6
|
+
|
|
7
|
+
module ALCATEL7750
|
|
8
|
+
module_function
|
|
9
|
+
|
|
10
|
+
def 接口isis 正文
|
|
11
|
+
isis = {}
|
|
12
|
+
isis_conf = 正文['ISIS Configuration'].join("\n").match_paragraph(" isis 0","\n exit")
|
|
13
|
+
interfaces = isis_conf.join.match_paragraph(" interface ","\n exit")
|
|
14
|
+
interfaces.each do|interface|
|
|
15
|
+
if_name = interface.split("\n")[0].gsub('"','')
|
|
16
|
+
interface.split("\n").each_with_index do|line,index|
|
|
17
|
+
if_name = line.strip if index==0
|
|
18
|
+
isis[if_name] ||= {}
|
|
19
|
+
isis[if_name]['level'] = line.split(' ').last if line.include?('level-capability')
|
|
20
|
+
isis[if_name]['interface-type'] = line.split(' ').last if line.include?('interface-type')
|
|
21
|
+
isis[if_name]['status'] = 'no shutdown' if line.strip=='no shutdown'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
lv_num = nil
|
|
25
|
+
level = interface.match_paragraph(" level ","\n exit")
|
|
26
|
+
level.join.split("\n").each_with_index do|line,index|
|
|
27
|
+
lv_num = "level#{line.strip}" if index==0
|
|
28
|
+
isis[if_name][lv_num] ||= {}
|
|
29
|
+
isis[if_name][lv_num]['metric'] = line.split(' ').last.to_i if line.include?('metric')
|
|
30
|
+
isis[if_name][lv_num]['passive'] = 'enable' if line.include?('passive')
|
|
31
|
+
isis[if_name][lv_num]['ipv6-unicast-metric'] = line.split(' ').last.to_i if line.include?('ipv6-unicast-metric')
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
return isis
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def isis 正文
|
|
38
|
+
isis = {}
|
|
39
|
+
isis_conf = 正文['ISIS Configuration'].join("\n").match_paragraph(" isis 0","\n exit")
|
|
40
|
+
isis_conf.join.split("\n").each do|line|
|
|
41
|
+
isis['level'] = line.split(' ').last if line.include?('level-capability')
|
|
42
|
+
isis['area-id'] = line.split(' ').last if line.include?('area-id')
|
|
43
|
+
isis['ignore-lsp-errors'] = 'enable' if line.include?('ignore-lsp-errors')
|
|
44
|
+
if line.include?('lsp')
|
|
45
|
+
isis['lsp'] ||= {}
|
|
46
|
+
isis['lsp']['lifetime'] = line.split(' ').last if line.include?('lsp-lifetime')
|
|
47
|
+
isis['lsp']['refresh-interval'] = line.split('refresh-interval ')[1].split(' ')[0] if line.include?('lsp-refresh-interval')
|
|
48
|
+
isis['lsp']['half-lifetime'] = line.split('half-lifetime ')[1].strip if line.include?('half-lifetime')
|
|
49
|
+
end
|
|
50
|
+
isis['overload-on-boot-timeout'] = line.split(' ').last.to_i if line.include?('overload-on-boot timeout')
|
|
51
|
+
isis['ipv6-routing'] = line.split(' ').last if line.include?('ipv6-routing')
|
|
52
|
+
isis['enable'] = true if line.strip=='no shutdown'
|
|
53
|
+
end
|
|
54
|
+
multi_topology = isis_conf.join.match_paragraph(" multi-topology","\n exit")
|
|
55
|
+
multi_topology.join.split("\n").each do|line|
|
|
56
|
+
if line.include?('ipv6-unicast')
|
|
57
|
+
isis['multi-topology'] ||= {}
|
|
58
|
+
isis['multi-topology']['ipv6-unicast'] = 'enable'
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
lv_num = nil
|
|
62
|
+
level = isis_conf.join.match_paragraph(" level ","\n exit")
|
|
63
|
+
level.join.split("\n").each_with_index do|line,index|
|
|
64
|
+
lv_num = "level#{line.strip}" if index==0
|
|
65
|
+
isis[lv_num] ||= {}
|
|
66
|
+
isis[lv_num]['external-preference'] = line.split(' ').last if line.include?('external-preference')
|
|
67
|
+
isis[lv_num]['preference'] = line.split(' ').last if line.include?('preference') && !line.include?('external')
|
|
68
|
+
isis[lv_num]['wide-metrics-only'] = 'enable' if line.include?('wide-metrics-only')
|
|
69
|
+
end
|
|
70
|
+
return isis
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
```
|