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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 299e0db358e9ea153b005f1cbb9aaba4238ebbed0c9cd80fa0da927d5dc1bcd6
|
|
4
|
+
data.tar.gz: b9dc80c59407fe49847806b802f40b9b7ea724dc12b355c3e3fd8a9059c9ed5e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9bc3b73f9946689e40c73dbd1a7b75569af7b2ef930fb366150d153284af531b91a0d522b885cbfbd7dd6bc01ef10bec87f0b0b66a85f2539a7fa0e0bdf391b5
|
|
7
|
+
data.tar.gz: a02fc345889a69e9d060fd7e5b1032cff7f018913d9a4143527fc0dcd2082362eb44c72cb38b68d40e6257d8ff87fffe10cd9d54f69ca032696807b81aefa40e
|
data/document/bgp-CR16010H-F.md
CHANGED
|
@@ -1,12 +1,123 @@
|
|
|
1
1
|
|
|
2
|
-
# CR16010H-F
|
|
2
|
+
# CR16010H-F bgp
|
|
3
3
|
|
|
4
4
|
```ruby
|
|
5
|
+
@sign << ['CR16010H-F', 'bgp']
|
|
6
|
+
@sign << ['CR16010H-F', 'bgp地址族']
|
|
5
7
|
@sign << ['CR16010H-F', '宣告网段解析']
|
|
6
8
|
|
|
7
9
|
module CR16010H_F
|
|
8
10
|
module_function
|
|
9
11
|
|
|
12
|
+
def bgp bgp配置
|
|
13
|
+
address_family, non_af_conf = self.bgp地址族 bgp配置
|
|
14
|
+
bgp, afs = {}, {}
|
|
15
|
+
non_af_conf.each do|line|
|
|
16
|
+
if line.strip[0..4]=='group'
|
|
17
|
+
groupname,mode = line.split(' ')[1..2]
|
|
18
|
+
bgp['group'] ||= {}
|
|
19
|
+
bgp['group'][groupname] ||= {}
|
|
20
|
+
bgp['group'][groupname].merge!('mode' => mode)
|
|
21
|
+
elsif line.strip[0..3]=='peer'
|
|
22
|
+
afname = 'global'
|
|
23
|
+
words = line.split(' ')
|
|
24
|
+
peername,attribute = words[1..2]
|
|
25
|
+
value = words[3..-1].join(" ")
|
|
26
|
+
afs[afname] ||= {}
|
|
27
|
+
afs[afname]['peer'] ||= {}
|
|
28
|
+
afs[afname]['peer'][peername] ||= {}
|
|
29
|
+
if value.empty?
|
|
30
|
+
afs[afname]['peer'][peername][attribute] = true
|
|
31
|
+
else
|
|
32
|
+
unless afs[afname]['peer'][peername]
|
|
33
|
+
afs[afname]['peer'][peername][attribute] ||= []
|
|
34
|
+
afs[afname]['peer'][peername][attribute] << value
|
|
35
|
+
else
|
|
36
|
+
afs[afname]['peer'][peername][attribute] = value
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
else
|
|
40
|
+
words = line.split(' ')
|
|
41
|
+
attribute = words[0]
|
|
42
|
+
value = words[1..-1].join(" ")
|
|
43
|
+
if value.empty?
|
|
44
|
+
bgp[attribute] = true
|
|
45
|
+
else
|
|
46
|
+
bgp[attribute] ||= []
|
|
47
|
+
bgp[attribute] << value
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
address_family.each do|afname, afconf|
|
|
52
|
+
afs[afname] ||= {}
|
|
53
|
+
afconf.each do|line|
|
|
54
|
+
if line.strip[0..3]=='peer'
|
|
55
|
+
words = line.split(' ')
|
|
56
|
+
peername,attribute = words[1..2]
|
|
57
|
+
value = words[3..-1].join(" ")
|
|
58
|
+
if (bgp['group']||{})[peername]
|
|
59
|
+
if value.empty?
|
|
60
|
+
bgp['group'][peername][attribute] = true
|
|
61
|
+
else
|
|
62
|
+
bgp['group'][peername][attribute] ||= []
|
|
63
|
+
bgp['group'][peername][attribute] << value
|
|
64
|
+
end
|
|
65
|
+
else
|
|
66
|
+
afs[afname]['peer'] ||= {}
|
|
67
|
+
afs[afname]['peer'][peername] ||= {}
|
|
68
|
+
if value.empty?
|
|
69
|
+
afs[afname]['peer'][peername][attribute] = true
|
|
70
|
+
else
|
|
71
|
+
afs[afname]['peer'][peername][attribute] ||= []
|
|
72
|
+
afs[afname]['peer'][peername][attribute] << value
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
elsif line.strip[0..4]=='group'
|
|
76
|
+
groupname = line.split(' ')[1]
|
|
77
|
+
bgp['group'] ||= {}
|
|
78
|
+
bgp['group'][groupname] ||= {}
|
|
79
|
+
else
|
|
80
|
+
words = line.split(' ')
|
|
81
|
+
attribute = words[0]
|
|
82
|
+
value = words[1..-1].join(" ")
|
|
83
|
+
if value.empty?
|
|
84
|
+
afs[afname][attribute] = true
|
|
85
|
+
else
|
|
86
|
+
afs[afname][attribute] ||= []
|
|
87
|
+
afs[afname][attribute] << value
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
bgp.merge!('address-family'=>afs)
|
|
93
|
+
return bgp
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def bgp地址族 bgp配置
|
|
97
|
+
address_family = {};non_af_conf = []
|
|
98
|
+
af_begin = false; af_name = 'global'
|
|
99
|
+
bgp配置.join("\n").split("\n").each do|line|
|
|
100
|
+
if line[0..14]==' address-family'
|
|
101
|
+
af_begin = true
|
|
102
|
+
af_name = line.split(' ')[1..-1].join('-')
|
|
103
|
+
address_family[af_name] ||= []
|
|
104
|
+
end
|
|
105
|
+
if line[0..1]==' #' # af_end
|
|
106
|
+
af_begin = false
|
|
107
|
+
af_name = 'global'
|
|
108
|
+
elsif line[0]=='#' # bgp_end or no-finisher
|
|
109
|
+
af_begin = false
|
|
110
|
+
af_name = 'global'
|
|
111
|
+
end
|
|
112
|
+
if af_begin
|
|
113
|
+
address_family[af_name] << line
|
|
114
|
+
else
|
|
115
|
+
non_af_conf << line unless line==' #'
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
return address_family, non_af_conf
|
|
119
|
+
end
|
|
120
|
+
|
|
10
121
|
def 宣告网段解析 配置散列
|
|
11
122
|
ranges = []
|
|
12
123
|
配置散列['bgp'].each do|segment|
|
data/document/bgp-CR16018-F.md
CHANGED
|
@@ -1,12 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
# CR16018-F BGP
|
|
1
|
+
# CR16018-F bgp
|
|
3
2
|
|
|
4
3
|
```ruby
|
|
4
|
+
@sign << ['CR16018-F', 'bgp']
|
|
5
|
+
@sign << ['CR16018-F', 'bgp地址族']
|
|
5
6
|
@sign << ['CR16018-F', '宣告网段解析']
|
|
6
7
|
|
|
7
8
|
module CR16018_F
|
|
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..14]==' 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..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-CR19000-20.md
CHANGED
|
@@ -1,12 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
# CR19000-20 BGP
|
|
1
|
+
# CR19000-20 bgp
|
|
3
2
|
|
|
4
3
|
```ruby
|
|
4
|
+
@sign << ['CR19000-20', 'bgp']
|
|
5
|
+
@sign << ['CR19000-20', 'bgp地址族']
|
|
5
6
|
@sign << ['CR19000-20', '宣告网段解析']
|
|
6
7
|
|
|
7
8
|
module CR19000_20
|
|
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..14]==' 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..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-CRS-16.md
CHANGED
|
@@ -1,12 +1,188 @@
|
|
|
1
|
-
|
|
2
1
|
# CRS-16 bgp
|
|
3
2
|
|
|
4
3
|
```ruby
|
|
4
|
+
@sign << ['CRS-16', 'bgp']
|
|
5
|
+
@sign << ['CRS-16', 'bgp地址族']
|
|
5
6
|
@sign << ['CRS-16', '宣告网段解析']
|
|
6
7
|
|
|
7
8
|
module CRS_16
|
|
8
9
|
module_function
|
|
9
10
|
|
|
11
|
+
###########################################################################################################
|
|
12
|
+
# [TODO] PEND TO REFACT
|
|
13
|
+
# vrf 等价于一个全局BGP实例, 目前的解析不对, 需要重构
|
|
14
|
+
###########################################################################################################
|
|
15
|
+
def bgp_vrf 配置
|
|
16
|
+
vrf_flag = false; vrf_name = nil
|
|
17
|
+
bgp_vrf = {};non_af_conf = []
|
|
18
|
+
vrf_conf = {}
|
|
19
|
+
配置.each do|line|
|
|
20
|
+
if line[0..3]=='vrf '
|
|
21
|
+
vrf_flag = true
|
|
22
|
+
vrf_name = line.split(' ').last
|
|
23
|
+
bgp_vrf[vrf_name] ||= []
|
|
24
|
+
bgp_vrf[vrf_name] << "router bgp vrf #{vrf_name}"
|
|
25
|
+
next
|
|
26
|
+
end
|
|
27
|
+
if line[0..1]==' !' && line==' !'
|
|
28
|
+
bgp_vrf[vrf_name] ||= []
|
|
29
|
+
bgp_vrf[vrf_name] << line[1..-1]
|
|
30
|
+
vrf_flag = false; vrf_name = nil
|
|
31
|
+
next
|
|
32
|
+
end
|
|
33
|
+
if vrf_flag
|
|
34
|
+
bgp_vrf[vrf_name] ||= []
|
|
35
|
+
bgp_vrf[vrf_name] << line[1..-1]
|
|
36
|
+
else
|
|
37
|
+
non_af_conf << line
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
bgp_vrf.each do|vrfname, vrftext|
|
|
41
|
+
vrf_conf[vrfname] = self.bgp(vrftext,:vrf)
|
|
42
|
+
end
|
|
43
|
+
return vrf_conf, non_af_conf
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def bgp 配置,default=:bgp
|
|
48
|
+
address_family, non_af_conf = self.bgp地址族(配置,default)
|
|
49
|
+
# vrf_conf, non_af_conf = self.bgp_vrf non_af_conf
|
|
50
|
+
bgp, afs = {}, {}
|
|
51
|
+
group_flag = false;groupname = nil
|
|
52
|
+
peer_flag = false;peername = nil
|
|
53
|
+
af_flag = false;afname = nil
|
|
54
|
+
non_af_conf.each do|line|
|
|
55
|
+
words = line.split(' ');cor = false
|
|
56
|
+
if words.include?('neighbor-group') && words.size==2
|
|
57
|
+
groupname = words[1]
|
|
58
|
+
group_flag = true
|
|
59
|
+
bgp['group'] ||= {}
|
|
60
|
+
bgp['group'][groupname] ||= {}
|
|
61
|
+
cor = true
|
|
62
|
+
end
|
|
63
|
+
if words.include?('neighbor') && words.size==2
|
|
64
|
+
peername = words[1]
|
|
65
|
+
peer_flag = true
|
|
66
|
+
bgp['peer'] ||= {}
|
|
67
|
+
bgp['peer'][peername] ||= {}
|
|
68
|
+
cor = true
|
|
69
|
+
end
|
|
70
|
+
if line[0..16]==' address-family '
|
|
71
|
+
afname = words[1..-1].join('-')
|
|
72
|
+
af_flag = true
|
|
73
|
+
if group_flag
|
|
74
|
+
bgp['group'][groupname]['address-family'] ||= {}
|
|
75
|
+
bgp['group'][groupname]['address-family'][afname] ||= {}
|
|
76
|
+
end
|
|
77
|
+
if peer_flag
|
|
78
|
+
bgp['peer'][peername]['address-family'] ||= {}
|
|
79
|
+
bgp['peer'][peername]['address-family'][afname] ||= {}
|
|
80
|
+
end
|
|
81
|
+
cor = true
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
if line==' !'
|
|
85
|
+
group_flag = false; groupname = nil
|
|
86
|
+
peer_flag = false; peername = nil
|
|
87
|
+
cor = true
|
|
88
|
+
end
|
|
89
|
+
if line==' !'
|
|
90
|
+
af_flag = false; afname = nil
|
|
91
|
+
cor = true
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
unless cor
|
|
95
|
+
attribute = words[0]
|
|
96
|
+
value = words[1..-1].join(' ').empty? ? 'enable' : words[1..-1].join(' ')
|
|
97
|
+
if [group_flag, peer_flag, af_flag] == [false, false, false]
|
|
98
|
+
bgp[attribute] ||= []
|
|
99
|
+
bgp[attribute] << value
|
|
100
|
+
end
|
|
101
|
+
if [group_flag, peer_flag, af_flag] == [false, false, true]
|
|
102
|
+
# SKIP
|
|
103
|
+
end
|
|
104
|
+
if [group_flag, peer_flag, af_flag] == [false, true, false]
|
|
105
|
+
bgp['peer'][peername][attribute] ||= []
|
|
106
|
+
bgp['peer'][peername][attribute] << value
|
|
107
|
+
end
|
|
108
|
+
if [group_flag, peer_flag, af_flag] == [false, true, true]
|
|
109
|
+
bgp['peer'][peername]['address-family'] ||= {}
|
|
110
|
+
bgp['peer'][peername]['address-family'][afname] ||= {}
|
|
111
|
+
bgp['peer'][peername]['address-family'][afname][attribute] ||= []
|
|
112
|
+
bgp['peer'][peername]['address-family'][afname][attribute] << value
|
|
113
|
+
end
|
|
114
|
+
if [group_flag, peer_flag, af_flag] == [true, false, false]
|
|
115
|
+
bgp['group'][groupname][attribute] ||= []
|
|
116
|
+
bgp['group'][groupname][attribute] << value
|
|
117
|
+
end
|
|
118
|
+
if [group_flag, peer_flag, af_flag] == [true, false, true]
|
|
119
|
+
bgp['group'][groupname]['address-family'] ||= {}
|
|
120
|
+
bgp['group'][groupname]['address-family'][afname] ||= {}
|
|
121
|
+
bgp['group'][groupname]['address-family'][afname][attribute] ||= []
|
|
122
|
+
bgp['group'][groupname]['address-family'][afname][attribute] << value
|
|
123
|
+
end
|
|
124
|
+
if [group_flag, peer_flag, af_flag] == [true, true, false]
|
|
125
|
+
# SKIP
|
|
126
|
+
end
|
|
127
|
+
if [group_flag, peer_flag, af_flag] == [true, true, true]
|
|
128
|
+
# SKIP
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
bgp.merge!('address-family' => address_family)
|
|
133
|
+
# bgp.merge!('vrf' => vrf_conf)
|
|
134
|
+
return bgp
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def bgp地址族 配置,default=:bgp
|
|
138
|
+
address_family = {};non_af_conf = []
|
|
139
|
+
af_begin = false; af_name = 'global'
|
|
140
|
+
|
|
141
|
+
(self.bgp配置 配置,default).each do|line|
|
|
142
|
+
if line[0..14]==' address-family'
|
|
143
|
+
af_begin = true
|
|
144
|
+
af_name = line.split(' ')[1..-1].join('-')
|
|
145
|
+
address_family[af_name] ||= {}
|
|
146
|
+
end
|
|
147
|
+
if line[0..1]==' !' && af_begin # af_end
|
|
148
|
+
af_begin = false
|
|
149
|
+
af_name = 'global'
|
|
150
|
+
end
|
|
151
|
+
if line[0]=='!' # bgp_end or no-finisher
|
|
152
|
+
af_begin = false
|
|
153
|
+
af_name = 'global'
|
|
154
|
+
end
|
|
155
|
+
if af_begin
|
|
156
|
+
words = line.strip.split(' ')
|
|
157
|
+
attribute = words[0]; value = words[1..-1].join(" ")
|
|
158
|
+
address_family[af_name][attribute] ||= []
|
|
159
|
+
address_family[af_name][attribute] << value
|
|
160
|
+
else
|
|
161
|
+
non_af_conf << line
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
return address_family, non_af_conf
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def bgp配置 配置, default=:bgp
|
|
168
|
+
fragment = []
|
|
169
|
+
conf = default==:bgp ? 配置['router'] : [配置.join("\n")]
|
|
170
|
+
conf.each do|part|
|
|
171
|
+
flag = false
|
|
172
|
+
part.split("\n").each do|line|
|
|
173
|
+
flag = true if line[0..10]=='router bgp '
|
|
174
|
+
if flag
|
|
175
|
+
if line[0..11]=='snmp-server '
|
|
176
|
+
flag = false;break
|
|
177
|
+
else
|
|
178
|
+
fragment << line
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
return fragment
|
|
184
|
+
end
|
|
185
|
+
|
|
10
186
|
def 宣告网段解析 配置散列
|
|
11
187
|
ranges = []
|
|
12
188
|
配置散列['router'].each do|segment|
|
|
@@ -27,4 +203,4 @@ module CRS_16
|
|
|
27
203
|
return ranges
|
|
28
204
|
end
|
|
29
205
|
end
|
|
30
|
-
```
|
|
206
|
+
```
|
data/document/bgp-M6000-16E.md
CHANGED
|
@@ -1,12 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
# M6000-16E BGP
|
|
1
|
+
# M6000-16E bgp
|
|
3
2
|
|
|
4
3
|
```ruby
|
|
4
|
+
@sign << ['M6000-16E', 'bgp']
|
|
5
|
+
@sign << ['M6000-16E', 'bgp地址族']
|
|
5
6
|
@sign << ['M6000-16E', '宣告网段解析']
|
|
6
7
|
|
|
7
8
|
module M6000_16E
|
|
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
|
+
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
|
+
|
|
10
120
|
def 宣告网段解析 配置散列
|
|
11
121
|
ranges = []
|
|
12
122
|
segment = 配置散列['bgp']
|