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
data/document/bgp-M6000-18S.md
CHANGED
|
@@ -1,12 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
# M6000-18S BGP
|
|
1
|
+
# M6000-18S bgp
|
|
3
2
|
|
|
4
3
|
```ruby
|
|
4
|
+
@sign << ['M6000-18S', 'bgp']
|
|
5
|
+
@sign << ['M6000-18S', 'bgp地址族']
|
|
5
6
|
@sign << ['M6000-18S', '宣告网段解析']
|
|
6
7
|
|
|
7
8
|
module M6000_18S
|
|
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']
|
data/document/bgp-M6000-8.md
CHANGED
|
@@ -1,12 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
# M6000-8 BGP
|
|
1
|
+
# M6000-8 bgp
|
|
3
2
|
|
|
4
3
|
```ruby
|
|
4
|
+
@sign << ['M6000-8', 'bgp']
|
|
5
|
+
@sign << ['M6000-8', 'bgp地址族']
|
|
5
6
|
@sign << ['M6000-8', '宣告网段解析']
|
|
6
7
|
|
|
7
8
|
module M6000_8
|
|
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']
|
data/document/bgp-M6000-8E.md
CHANGED
|
@@ -1,12 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
# M6000-8E BGP
|
|
1
|
+
# M6000-8E bgp
|
|
3
2
|
|
|
4
3
|
```ruby
|
|
4
|
+
@sign << ['M6000-8E', 'bgp']
|
|
5
|
+
@sign << ['M6000-8E', 'bgp地址族']
|
|
5
6
|
@sign << ['M6000-8E', '宣告网段解析']
|
|
6
7
|
|
|
7
8
|
module M6000_8E
|
|
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']
|
data/document/bgp-ME60-16.md
CHANGED
|
@@ -1,12 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
# ME60-16 BGP
|
|
1
|
+
# ME60-16 bgp
|
|
3
2
|
|
|
4
3
|
```ruby
|
|
4
|
+
@sign << ['ME60-16', 'bgp']
|
|
5
|
+
@sign << ['ME60-16', 'bgp地址族']
|
|
5
6
|
@sign << ['ME60-16', '宣告网段解析']
|
|
6
7
|
|
|
7
8
|
module ME60_16
|
|
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-ME60-X16.md
CHANGED
|
@@ -1,12 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
# ME60-X16 BGP
|
|
1
|
+
# ME60-X16 bgp
|
|
3
2
|
|
|
4
3
|
```ruby
|
|
4
|
+
@sign << ['ME60-X16', 'bgp']
|
|
5
|
+
@sign << ['ME60-X16', 'bgp地址族']
|
|
5
6
|
@sign << ['ME60-X16', '宣告网段解析']
|
|
6
7
|
|
|
7
8
|
module ME60_X16
|
|
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|
|