network-utility 1.1.50 → 1.1.51
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 +12 -8
- data/document/bgp-CR16018-F.md +12 -8
- data/document/bgp-CR19000-20.md +12 -8
- data/document/bgp-M6000-16E.md +8 -8
- data/document/bgp-M6000-18S.md +8 -8
- data/document/bgp-M6000-8.md +8 -8
- data/document/bgp-M6000-8E.md +8 -8
- data/document/bgp-MA5200G-8.md +12 -8
- data/document/bgp-ME60-16.md +12 -8
- data/document/bgp-ME60-X16.md +12 -8
- data/document/bgp-NE40E-X16.md +12 -8
- data/document/bgp-NE40E-X16A.md +12 -8
- data/document/bgp-NE40E-X8.md +12 -8
- data/document/bgp-NE40E.md +12 -8
- data/document/bgp-NE5000E-20.md +12 -8
- data/document/bgp-NE5000E-X16.md +12 -8
- data/document/bgp-NE5000E-X16A.md +12 -8
- data/document/bgp-NE80E.md +12 -8
- data/document/bgp-T8000-18.md +24 -0
- data/document/config.md +45 -44
- data/document/if-ALCATEL7750.md +174 -12
- data/document/if-CRS-16.md +54 -2
- data/document/if-Nokia7750.md +174 -12
- data/document/isis-NE5000E-20.md +141 -0
- data/document/isis-NE5000E-X16.md +141 -0
- data/document/isis-NE5000E-X16A.md +141 -0
- data/document/pool-ALCATEL7750.md +20 -0
- data/document/pool-CR16010H-F.md +108 -0
- data/document/pool-CR16018-F.md +108 -0
- data/document/pool-Nokia7750.md +20 -0
- data/document/pool-V6000.md +126 -0
- data/document/pool-VNE9000.md +63 -0
- data/document/static-ALCATEL7750.md +32 -0
- data/document/static-CR16010H-F.md +2 -2
- data/document/static-CR16018-F.md +2 -2
- data/document/static-CRS-16.md +40 -0
- data/document/static-Nokia7750.md +32 -0
- data/document/static-V6000.md +34 -0
- data/document/static-VNE9000.md +28 -0
- data/network.rb +1 -1
- data/utility/ipv4_address.rb +7 -0
- metadata +16 -1
data/document/config.md
CHANGED
|
@@ -7,26 +7,26 @@
|
|
|
7
7
|
@sign << ['ALCATEL7750', '配置解析']
|
|
8
8
|
|
|
9
9
|
module ALCATEL7750
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
10
|
+
module_function
|
|
11
|
+
|
|
12
|
+
def 配置解析 raw
|
|
13
|
+
conf = {}; name = nil; temp = []
|
|
14
|
+
raw.gsub("\r",'').split("\n").each do|line|
|
|
15
|
+
if line[0..4]=='echo '
|
|
16
|
+
conf[name] = temp
|
|
17
|
+
temp = []
|
|
18
|
+
name = line.split('"')[1]
|
|
19
|
+
conf[name] = ''
|
|
20
|
+
elsif line.include?('#--------------------------------------------------')
|
|
21
|
+
next
|
|
22
|
+
else
|
|
23
|
+
temp << line
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
conf[name] = temp
|
|
27
|
+
conf.delete(nil)
|
|
28
|
+
return conf
|
|
29
|
+
end
|
|
30
30
|
end
|
|
31
31
|
```
|
|
32
32
|
|
|
@@ -34,26 +34,26 @@ end
|
|
|
34
34
|
@sign << ['Nokia7750', '配置解析']
|
|
35
35
|
|
|
36
36
|
module Nokia7750
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
37
|
+
module_function
|
|
38
|
+
|
|
39
|
+
def 配置解析 raw
|
|
40
|
+
conf = {}; name = nil; temp = []
|
|
41
|
+
raw.gsub("\r",'').split("\n").each do|line|
|
|
42
|
+
if line[0..4]=='echo '
|
|
43
|
+
conf[name] = temp
|
|
44
|
+
temp = []
|
|
45
|
+
name = line.split('"')[1]
|
|
46
|
+
conf[name] = ''
|
|
47
|
+
elsif line.include?('#--------------------------------------------------')
|
|
48
|
+
next
|
|
49
|
+
else
|
|
50
|
+
temp << line
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
conf[name] = temp
|
|
54
|
+
conf.delete(nil)
|
|
55
|
+
return conf
|
|
56
|
+
end
|
|
57
57
|
end
|
|
58
58
|
```
|
|
59
59
|
|
|
@@ -76,15 +76,16 @@ end
|
|
|
76
76
|
@sign << ['CRS-16', '配置解析']
|
|
77
77
|
|
|
78
78
|
module CRS_16
|
|
79
|
-
|
|
79
|
+
module_function
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
def 配置解析 raw, *guards
|
|
82
|
+
config = {}
|
|
83
83
|
hostname = guards[0] || raw.split("\n").find{|line|line.include?("hostname ")}.to_s.split("hostname ")[1]
|
|
84
84
|
prepart = raw.split("show running-config")[1]
|
|
85
85
|
return {} unless prepart
|
|
86
86
|
content = prepart.split("\nend\n")[0]
|
|
87
87
|
config, pretent = {}, content
|
|
88
|
+
while pretent.include?("!\n^C\n"); pretent = pretent.gsub("!\n^C\n","^C\n!\n") end
|
|
88
89
|
while pretent.include?("!\n!"); pretent = pretent.gsub("!\n!","!") end
|
|
89
90
|
pieces = pretent.split("\n!\n").select{|pc|pc.strip != ''}
|
|
90
91
|
pieces.each do|piece|
|
|
@@ -92,7 +93,7 @@ module CRS_16
|
|
|
92
93
|
(config[tag] ||= []) << piece
|
|
93
94
|
end
|
|
94
95
|
return config
|
|
95
|
-
|
|
96
|
+
end
|
|
96
97
|
end
|
|
97
98
|
```
|
|
98
99
|
|
data/document/if-ALCATEL7750.md
CHANGED
|
@@ -2,34 +2,196 @@
|
|
|
2
2
|
# Alcatel7750 IF
|
|
3
3
|
|
|
4
4
|
```ruby
|
|
5
|
-
@sign << ['ALCATEL7750', '
|
|
6
|
-
@sign << ['ALCATEL7750', '
|
|
7
|
-
@sign << ['ALCATEL7750', '
|
|
8
|
-
@sign << ['ALCATEL7750', '
|
|
9
|
-
@sign << ['ALCATEL7750', '
|
|
10
|
-
@sign << ['ALCATEL7750', '
|
|
11
|
-
@sign << ['ALCATEL7750', '
|
|
12
|
-
@sign << ['ALCATEL7750', '
|
|
13
|
-
@sign << ['ALCATEL7750', '
|
|
5
|
+
@sign << ['ALCATEL7750', '接口关联']
|
|
6
|
+
@sign << ['ALCATEL7750', '接口配置']
|
|
7
|
+
@sign << ['ALCATEL7750', '接口分捡']
|
|
8
|
+
@sign << ['ALCATEL7750', '端口识别']
|
|
9
|
+
@sign << ['ALCATEL7750', '接口地址']
|
|
10
|
+
@sign << ['ALCATEL7750', '接口描述']
|
|
11
|
+
@sign << ['ALCATEL7750', '接口vpn实例']
|
|
12
|
+
@sign << ['ALCATEL7750', '接口开关']
|
|
13
|
+
@sign << ['ALCATEL7750', '接口QoS']
|
|
14
|
+
@sign << ['ALCATEL7750', '接口流策略']
|
|
14
15
|
|
|
15
16
|
module ALCATEL7750
|
|
16
17
|
module_function
|
|
17
18
|
|
|
19
|
+
def extract_token(str)
|
|
20
|
+
if str =~ /"([^"\\]*(?:\\.[^"\\]*)*)"/
|
|
21
|
+
$1
|
|
22
|
+
else
|
|
23
|
+
str.strip.split(/\s+/).first
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def 接口关联 正文
|
|
28
|
+
# ies
|
|
29
|
+
# +----> name as ies-id
|
|
30
|
+
# +----> description as ies-desc
|
|
31
|
+
# +----> interface -----> name as port-desc
|
|
32
|
+
# | +----------> sap as port-name
|
|
33
|
+
# | +----------> address
|
|
34
|
+
# +----> subscriber-interface ----------> name as port-desc-part1
|
|
35
|
+
# +--------------------------> address ※ shared by all group-interface
|
|
36
|
+
# +----> group-interface ----> name as port-desc-part2
|
|
37
|
+
# +-------------> sap as port-name # if exist is a interface, else is a pool
|
|
38
|
+
# vprn
|
|
39
|
+
# +----> name as vrf-name
|
|
40
|
+
# +----> rd
|
|
41
|
+
# +----> rt-in rt-out
|
|
42
|
+
# +----> interface
|
|
43
|
+
# +--------> name as port-desc
|
|
44
|
+
# +--------> sap as port-name
|
|
45
|
+
# +--------> address
|
|
46
|
+
#
|
|
47
|
+
# port-name (ies-id)ies-name ies-desc/port-desc address
|
|
48
|
+
# port-name (ies-id)ies-name ies-desc/port-desc1 port-desc2 address
|
|
49
|
+
# port-name (rd)vrf-name/port-desc address
|
|
50
|
+
|
|
51
|
+
intfs = []; subintfs = []; abpools = []
|
|
52
|
+
iess = 正文['Service Configuration'].join("\n").match_paragraph(" ies ","\n exit")
|
|
53
|
+
iess.each do|ies|
|
|
54
|
+
# ies basic info
|
|
55
|
+
ies_abs = ies.split("\n").first
|
|
56
|
+
ies_id = ies_abs.split(" ").first
|
|
57
|
+
if ies_abs.include?('name')
|
|
58
|
+
ies_name = extract_token(ies_abs.split('name ').last)
|
|
59
|
+
end
|
|
60
|
+
if ies_abs.include?('customer')
|
|
61
|
+
ies_custom = extract_token(ies_abs.split('customer ').last)
|
|
62
|
+
end
|
|
63
|
+
ies_desc = ies.split("\n").find{|line|line.include?('description')}.to_s.split("description ").last.to_s[1..-2].to_s
|
|
64
|
+
|
|
65
|
+
# interface info
|
|
66
|
+
ifs = ies.match_paragraph("\n interface ","\n exit")
|
|
67
|
+
ifs.each do|intf|
|
|
68
|
+
if_name = extract_token(intf.split("\n").first.strip) # as port-desc
|
|
69
|
+
addresses = []
|
|
70
|
+
intf.split("\n").each do|line|
|
|
71
|
+
addresses << line.split("address").last.strip if line.include?(" address ")
|
|
72
|
+
end
|
|
73
|
+
if_sap = intf.split("\n").find{|g|g.include?("sap ")}.to_s.split("sap ").last.to_s.split(" ").first
|
|
74
|
+
if if_sap
|
|
75
|
+
intfs << [if_sap, ["ies:#{ies_id}", "ies:#{ies_name}", ies_desc, if_name], addresses ]
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# subscriber-interface info
|
|
80
|
+
subifs = ies.match_paragraph("\n subscriber-interface ","\n exit")
|
|
81
|
+
subifs.each do|subif|
|
|
82
|
+
subif_name = extract_token(subif.split("\n").first.strip) # as port-desc-p1
|
|
83
|
+
|
|
84
|
+
addresses = []
|
|
85
|
+
subif.split("\n").each do|line|
|
|
86
|
+
addresses << line.split("address").last.strip if line.include?(" address ")
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
groupifs = subif.match_paragraph("\n group-interface ","\n exit")
|
|
90
|
+
groupifs.each do|groupif|
|
|
91
|
+
group_name = extract_token(groupif.split("\n").first.strip) # as port-desc-p2
|
|
92
|
+
group_sap = groupif.split("\n").find{|g|g.include?("sap ")}.to_s.split("sap ").last.to_s.split(" ").first # as port-name
|
|
93
|
+
|
|
94
|
+
if group_sap
|
|
95
|
+
subintfs << [group_sap, ["ies:#{ies_id}", "ies:#{ies_name}", ies_desc, subif_name, group_name], addresses]
|
|
96
|
+
abpools << [group_sap, ["ies:#{ies_id}", "ies:#{ies_name}", ies_desc, subif_name, group_name], addresses]
|
|
97
|
+
else
|
|
98
|
+
abpools << [group_sap, ["ies:#{ies_id}", "ies:#{ies_name}", ies_desc, subif_name, group_name], addresses]
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
vpn_apply = []
|
|
105
|
+
vpns = 正文['Service Configuration'].join("\n").match_paragraph("\n vprn ","\n exit")
|
|
106
|
+
vpns.each do|vpn|
|
|
107
|
+
vpn_abs = vpn.split("\n").first
|
|
108
|
+
vpn_id = vpn_abs.split(" ").first
|
|
109
|
+
if vpn_abs.include?('name')
|
|
110
|
+
vpn_name = extract_token(vpn_abs.split('name ').last)
|
|
111
|
+
end
|
|
112
|
+
if vpn_abs.include?('customer')
|
|
113
|
+
vpn_custom = extract_token(vpn_abs.split('customer ').last)
|
|
114
|
+
end
|
|
115
|
+
vpn_desc = vpn.split("\n").find{|line|line.include?('description')}.to_s.split("description ").last.to_s[1..-2].to_s
|
|
116
|
+
|
|
117
|
+
vpn_as = vpn.split("\n").find{|line|line.include?('autonomous-system')}.to_s.split("autonomous-system ").last.to_s
|
|
118
|
+
vpn_rd = vpn.split("\n").find{|line|line.include?('route-distinguisher')}.to_s.split("route-distinguisher ").last.to_s
|
|
119
|
+
vpn_tag_in = vpn.split("\n").find{|line|line.include?('vrf-target')}.to_s.split("vrf-target ").last.to_s.split("target:").last.to_s
|
|
120
|
+
vpn_tag_out = vpn.split("\n").find{|line|line.include?('vrf-target')}.to_s.split("vrf-target ").last.to_s.split("target:").last.to_s
|
|
121
|
+
vpn_tag_in = vpn.split("\n").find{|line|line.include?('vrf-import')}.to_s.split("vrf-import ").last.to_s[1..-2].to_s
|
|
122
|
+
vpn_tag_out = vpn.split("\n").find{|line|line.include?('vrf-export')}.to_s.split("vrf-export ").last.to_s[1..-2].to_s
|
|
123
|
+
|
|
124
|
+
# interface info
|
|
125
|
+
ifs = vpn.match_paragraph("\n interface ","\n exit")
|
|
126
|
+
ifs.each do|intf|
|
|
127
|
+
if_name = extract_token(intf.split("\n").first.strip) # as port-desc
|
|
128
|
+
addresses = []
|
|
129
|
+
intf.split("\n").each do|line|
|
|
130
|
+
addresses << line.split("address").last.strip if line.include?(" address ")
|
|
131
|
+
end
|
|
132
|
+
if_sap = intf.split("\n").find{|g|g.include?("sap ")}.to_s.split("sap ").last.to_s.split(" ").first
|
|
133
|
+
if if_sap
|
|
134
|
+
intfs << [if_sap, ["vprn:#{vpn_id}", "vprn:#{vpn_name}", vpn_desc, if_name], addresses]
|
|
135
|
+
vpn_apply << [if_sap, [vpn_id, vpn_name, vpn_desc, if_name], [vpn_as, vpn_rd,vpn_tag_in, vpn_tag_out], addresses]
|
|
136
|
+
else
|
|
137
|
+
vpn_apply << [if_sap, [vpn_id, vpn_name, vpn_desc, if_name], [vpn_as, vpn_rd,vpn_tag_in, vpn_tag_out], addresses]
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
return intfs, subintfs, abpools, vpn_apply
|
|
143
|
+
end
|
|
144
|
+
|
|
18
145
|
def 接口配置 正文
|
|
19
|
-
[]
|
|
146
|
+
ports = []
|
|
147
|
+
basics = 正文['Port Configuration'].join("\n").match_paragraph("\n port","\n exit").map{|port|"port "+port}
|
|
148
|
+
basics.each do|basic|
|
|
149
|
+
类型,连接符,端口 = self.端口识别 basic
|
|
150
|
+
ports << [端口, basic]
|
|
151
|
+
end
|
|
152
|
+
networks = 正文['Router (Network Side) Configuration'].join("\n").match_paragraph("\n interface ","\n exit").map{|port|"interface "+port}
|
|
153
|
+
networks.each do|network|
|
|
154
|
+
端口 = network.split("\n").select{|line|line.include?("port ")}.map{|line|line.split("port ").last}.join
|
|
155
|
+
if port = ports.find{|port|port==端口}
|
|
156
|
+
ports.index(port)
|
|
157
|
+
ports[index] << network
|
|
158
|
+
else
|
|
159
|
+
端口 = network.split("\n").select{|line|line.include?("interface ")}.map{|line|line.split("interface ")[1..-1].join(' ')}.join
|
|
160
|
+
ports << [端口, network]
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
return ports
|
|
20
164
|
end
|
|
21
165
|
|
|
22
166
|
def 接口分捡 接口集合
|
|
23
|
-
[]
|
|
167
|
+
return 接口集合,[],[]
|
|
24
168
|
end
|
|
25
169
|
|
|
26
|
-
def 端口识别
|
|
170
|
+
def 端口识别 接口配置
|
|
171
|
+
描述 = 接口配置.is_a?(Array) ? 接口配置[1..-1].join("\n") : 接口配置
|
|
172
|
+
连接符 = ' '
|
|
173
|
+
类型 = 'Port'
|
|
174
|
+
port = /(\w+|\-|\_|\d+|\/|\:|\s+)+/.match(描述.split("\n").first.split(" ")[1..-1].join(' '))
|
|
175
|
+
端口 = port ? port.to_s : '未知端口'
|
|
176
|
+
return 类型,连接符,端口
|
|
27
177
|
end
|
|
28
178
|
|
|
29
179
|
def 接口地址 接口配置
|
|
180
|
+
地址集 = []
|
|
181
|
+
接口配置.join("\n").each_line do|line|
|
|
182
|
+
if line.strip[0..6]=='address'
|
|
183
|
+
地址集 << line.split('address')[-1].strip.split('/')
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
地址集
|
|
30
187
|
end
|
|
31
188
|
|
|
32
189
|
def 接口描述 接口配置
|
|
190
|
+
描述 = ''
|
|
191
|
+
接口配置.join("\n").each_line do|line| if line.strip[0..10]=='description'
|
|
192
|
+
描述 = line.split('description')[-1].strip; break
|
|
193
|
+
end end
|
|
194
|
+
描述.to_s[1..-2]
|
|
33
195
|
end
|
|
34
196
|
|
|
35
197
|
def 接口vpn实例 接口配置
|
data/document/if-CRS-16.md
CHANGED
|
@@ -16,32 +16,84 @@ module CRS_16
|
|
|
16
16
|
module_function
|
|
17
17
|
|
|
18
18
|
def 接口配置 正文
|
|
19
|
-
[]
|
|
19
|
+
正文['interface']
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def 接口分捡 接口集合
|
|
23
|
-
[]
|
|
23
|
+
物理接口集合,子接口集合,特殊接口集合 = [],[],[]
|
|
24
|
+
接口集合.each do|接口|
|
|
25
|
+
类型,连接符,端口 = self.端口识别 接口
|
|
26
|
+
(子接口集合 << 端口;next) if 端口.include?('.')
|
|
27
|
+
(特殊接口集合 << 端口;next) if ['Loopback','MgmtEth','tunnel-ip'].include?(类型)
|
|
28
|
+
物理接口集合 << 端口
|
|
29
|
+
end
|
|
30
|
+
return 物理接口集合,子接口集合,特殊接口集合
|
|
24
31
|
end
|
|
25
32
|
|
|
26
33
|
def 端口识别 描述
|
|
34
|
+
连接符 = ''
|
|
35
|
+
name = 描述.split("\n").first.gsub('preconfigure','').split(' ').last
|
|
36
|
+
type = /MgmtEth|tunnel\-ip|Bundle\-Ether|Loopback|GigabitEthernet|HundredGigE|TenGigE|POS/.match(name)
|
|
37
|
+
类型 = type ? type.to_s : '未知类型'
|
|
38
|
+
port = /\d{1}(\w+|\/|\d+|\.)*/.match(name)
|
|
39
|
+
端口 = port ? port.to_s : '未知端口'
|
|
40
|
+
return 类型,连接符,端口
|
|
27
41
|
end
|
|
28
42
|
|
|
29
43
|
def 接口地址 接口配置
|
|
44
|
+
地址集 = []
|
|
45
|
+
接口配置.each_line do|line|
|
|
46
|
+
if line.strip[0..11]=='ipv4 address' and !line.include?('unnumbered')
|
|
47
|
+
地址集 << line.split('ipv4 address')[-1].strip.split(' ')
|
|
48
|
+
end
|
|
49
|
+
if line.strip[0..11]=='ipv6 address' and !line.include?("auto link-local") and !line.include?('unnumbered')
|
|
50
|
+
地址集 << line.split('ipv6 address')[-1].strip.split('/')
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
地址集
|
|
30
54
|
end
|
|
31
55
|
|
|
32
56
|
def 接口描述 接口配置
|
|
57
|
+
描述 = ''
|
|
58
|
+
接口配置.each_line do|line| if line.strip[0..10]=='description'
|
|
59
|
+
描述 = line.split('description')[-1].strip; break
|
|
60
|
+
end end
|
|
61
|
+
描述.to_s
|
|
33
62
|
end
|
|
34
63
|
|
|
35
64
|
def 接口vpn实例 接口配置
|
|
65
|
+
实例 = ''
|
|
66
|
+
接口配置.each_line do|line|
|
|
67
|
+
实例 = "vpn-inst:" + line.split("vrf").last.strip if line.strip[0..2]=='vrf'
|
|
68
|
+
end
|
|
69
|
+
实例
|
|
36
70
|
end
|
|
37
71
|
|
|
38
72
|
def 接口开关 接口配置
|
|
73
|
+
描述 = ''
|
|
74
|
+
接口配置.each_line do|line|
|
|
75
|
+
if line.include?('shutdown') and !line.include?('no') and !line.include?('undo') and !line.include?('description')
|
|
76
|
+
描述 = 'shutdown'; break
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
描述
|
|
39
80
|
end
|
|
40
81
|
|
|
41
82
|
def 接口QoS 接口配置
|
|
83
|
+
qos = {}
|
|
42
84
|
end
|
|
43
85
|
|
|
44
86
|
def 接口流策略 接口配置
|
|
87
|
+
traffic = {}
|
|
88
|
+
接口配置.each_line do|line|
|
|
89
|
+
if line.include?('service-policy')
|
|
90
|
+
words = line.split(' ')
|
|
91
|
+
direction = line.include?('input') ? 'inbound' : 'outbound'
|
|
92
|
+
profile = words[words.index('service-policy')+2]
|
|
93
|
+
traffic[direction] = profile
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
traffic
|
|
45
97
|
end
|
|
46
98
|
end
|
|
47
99
|
```
|
data/document/if-Nokia7750.md
CHANGED
|
@@ -2,34 +2,196 @@
|
|
|
2
2
|
# Alcatel7750 IF #ALT
|
|
3
3
|
|
|
4
4
|
```ruby
|
|
5
|
-
@sign << ['Nokia7750', '
|
|
6
|
-
@sign << ['Nokia7750', '
|
|
7
|
-
@sign << ['Nokia7750', '
|
|
8
|
-
@sign << ['Nokia7750', '
|
|
9
|
-
@sign << ['Nokia7750', '
|
|
10
|
-
@sign << ['Nokia7750', '
|
|
11
|
-
@sign << ['Nokia7750', '
|
|
12
|
-
@sign << ['Nokia7750', '
|
|
13
|
-
@sign << ['Nokia7750', '
|
|
5
|
+
@sign << ['Nokia7750', '接口关联']
|
|
6
|
+
@sign << ['Nokia7750', '接口配置']
|
|
7
|
+
@sign << ['Nokia7750', '接口分捡']
|
|
8
|
+
@sign << ['Nokia7750', '端口识别']
|
|
9
|
+
@sign << ['Nokia7750', '接口地址']
|
|
10
|
+
@sign << ['Nokia7750', '接口描述']
|
|
11
|
+
@sign << ['Nokia7750', '接口vpn实例']
|
|
12
|
+
@sign << ['Nokia7750', '接口开关']
|
|
13
|
+
@sign << ['Nokia7750', '接口QoS']
|
|
14
|
+
@sign << ['Nokia7750', '接口流策略']
|
|
14
15
|
|
|
15
16
|
module Nokia7750
|
|
16
17
|
module_function
|
|
17
18
|
|
|
19
|
+
def extract_token(str)
|
|
20
|
+
if str =~ /"([^"\\]*(?:\\.[^"\\]*)*)"/
|
|
21
|
+
$1
|
|
22
|
+
else
|
|
23
|
+
str.strip.split(/\s+/).first
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def 接口关联 正文
|
|
28
|
+
# ies
|
|
29
|
+
# +----> name as ies-id
|
|
30
|
+
# +----> description as ies-desc
|
|
31
|
+
# +----> interface -----> name as port-desc
|
|
32
|
+
# | +----------> sap as port-name
|
|
33
|
+
# | +----------> address
|
|
34
|
+
# +----> subscriber-interface ----------> name as port-desc-part1
|
|
35
|
+
# +--------------------------> address ※ shared by all group-interface
|
|
36
|
+
# +----> group-interface ----> name as port-desc-part2
|
|
37
|
+
# +-------------> sap as port-name # if exist is a interface, else is a pool
|
|
38
|
+
# vprn
|
|
39
|
+
# +----> name as vrf-name
|
|
40
|
+
# +----> rd
|
|
41
|
+
# +----> rt-in rt-out
|
|
42
|
+
# +----> interface
|
|
43
|
+
# +--------> name as port-desc
|
|
44
|
+
# +--------> sap as port-name
|
|
45
|
+
# +--------> address
|
|
46
|
+
#
|
|
47
|
+
# port-name (ies-id)ies-name ies-desc/port-desc address
|
|
48
|
+
# port-name (ies-id)ies-name ies-desc/port-desc1 port-desc2 address
|
|
49
|
+
# port-name (rd)vrf-name/port-desc address
|
|
50
|
+
|
|
51
|
+
intfs = []; subintfs = []; abpools = []
|
|
52
|
+
iess = 正文['Service Configuration'].join("\n").match_paragraph(" ies ","\n exit")
|
|
53
|
+
iess.each do|ies|
|
|
54
|
+
# ies basic info
|
|
55
|
+
ies_abs = ies.split("\n").first
|
|
56
|
+
ies_id = ies_abs.split(" ").first
|
|
57
|
+
if ies_abs.include?('name')
|
|
58
|
+
ies_name = extract_token(ies_abs.split('name ').last)
|
|
59
|
+
end
|
|
60
|
+
if ies_abs.include?('customer')
|
|
61
|
+
ies_custom = extract_token(ies_abs.split('customer ').last)
|
|
62
|
+
end
|
|
63
|
+
ies_desc = ies.split("\n").find{|line|line.include?('description')}.to_s.split("description ").last.to_s[1..-2].to_s
|
|
64
|
+
|
|
65
|
+
# interface info
|
|
66
|
+
ifs = ies.match_paragraph("\n interface ","\n exit")
|
|
67
|
+
ifs.each do|intf|
|
|
68
|
+
if_name = extract_token(intf.split("\n").first.strip) # as port-desc
|
|
69
|
+
addresses = []
|
|
70
|
+
intf.split("\n").each do|line|
|
|
71
|
+
addresses << line.split("address").last.strip if line.include?(" address ")
|
|
72
|
+
end
|
|
73
|
+
if_sap = intf.split("\n").find{|g|g.include?("sap ")}.to_s.split("sap ").last.to_s.split(" ").first
|
|
74
|
+
if if_sap
|
|
75
|
+
intfs << [if_sap, ["ies:#{ies_id}", "ies:#{ies_name}", ies_desc, if_name], addresses ]
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# subscriber-interface info
|
|
80
|
+
subifs = ies.match_paragraph("\n subscriber-interface ","\n exit")
|
|
81
|
+
subifs.each do|subif|
|
|
82
|
+
subif_name = extract_token(subif.split("\n").first.strip) # as port-desc-p1
|
|
83
|
+
|
|
84
|
+
addresses = []
|
|
85
|
+
subif.split("\n").each do|line|
|
|
86
|
+
addresses << line.split("address").last.strip if line.include?(" address ")
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
groupifs = subif.match_paragraph("\n group-interface ","\n exit")
|
|
90
|
+
groupifs.each do|groupif|
|
|
91
|
+
group_name = extract_token(groupif.split("\n").first.strip) # as port-desc-p2
|
|
92
|
+
group_sap = groupif.split("\n").find{|g|g.include?("sap ")}.to_s.split("sap ").last.to_s.split(" ").first # as port-name
|
|
93
|
+
|
|
94
|
+
if group_sap
|
|
95
|
+
subintfs << [group_sap, ["ies:#{ies_id}", "ies:#{ies_name}", ies_desc, subif_name, group_name], addresses]
|
|
96
|
+
abpools << [group_sap, ["ies:#{ies_id}", "ies:#{ies_name}", ies_desc, subif_name, group_name], addresses]
|
|
97
|
+
else
|
|
98
|
+
abpools << [group_sap, ["ies:#{ies_id}", "ies:#{ies_name}", ies_desc, subif_name, group_name], addresses]
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
vpn_apply = []
|
|
105
|
+
vpns = 正文['Service Configuration'].join("\n").match_paragraph("\n vprn ","\n exit")
|
|
106
|
+
vpns.each do|vpn|
|
|
107
|
+
vpn_abs = vpn.split("\n").first
|
|
108
|
+
vpn_id = vpn_abs.split(" ").first
|
|
109
|
+
if vpn_abs.include?('name')
|
|
110
|
+
vpn_name = extract_token(vpn_abs.split('name ').last)
|
|
111
|
+
end
|
|
112
|
+
if vpn_abs.include?('customer')
|
|
113
|
+
vpn_custom = extract_token(vpn_abs.split('customer ').last)
|
|
114
|
+
end
|
|
115
|
+
vpn_desc = vpn.split("\n").find{|line|line.include?('description')}.to_s.split("description ").last.to_s[1..-2].to_s
|
|
116
|
+
|
|
117
|
+
vpn_as = vpn.split("\n").find{|line|line.include?('autonomous-system')}.to_s.split("autonomous-system ").last.to_s
|
|
118
|
+
vpn_rd = vpn.split("\n").find{|line|line.include?('route-distinguisher')}.to_s.split("route-distinguisher ").last.to_s
|
|
119
|
+
vpn_tag_in = vpn.split("\n").find{|line|line.include?('vrf-target')}.to_s.split("vrf-target ").last.to_s.split("target:").last.to_s
|
|
120
|
+
vpn_tag_out = vpn.split("\n").find{|line|line.include?('vrf-target')}.to_s.split("vrf-target ").last.to_s.split("target:").last.to_s
|
|
121
|
+
vpn_tag_in = vpn.split("\n").find{|line|line.include?('vrf-import')}.to_s.split("vrf-import ").last.to_s[1..-2].to_s
|
|
122
|
+
vpn_tag_out = vpn.split("\n").find{|line|line.include?('vrf-export')}.to_s.split("vrf-export ").last.to_s[1..-2].to_s
|
|
123
|
+
|
|
124
|
+
# interface info
|
|
125
|
+
ifs = vpn.match_paragraph("\n interface ","\n exit")
|
|
126
|
+
ifs.each do|intf|
|
|
127
|
+
if_name = extract_token(intf.split("\n").first.strip) # as port-desc
|
|
128
|
+
addresses = []
|
|
129
|
+
intf.split("\n").each do|line|
|
|
130
|
+
addresses << line.split("address").last.strip if line.include?(" address ")
|
|
131
|
+
end
|
|
132
|
+
if_sap = intf.split("\n").find{|g|g.include?("sap ")}.to_s.split("sap ").last.to_s.split(" ").first
|
|
133
|
+
if if_sap
|
|
134
|
+
intfs << [if_sap, ["vprn:#{vpn_id}", "vprn:#{vpn_name}", vpn_desc, if_name], addresses]
|
|
135
|
+
vpn_apply << [if_sap, [vpn_id, vpn_name, vpn_desc, if_name], [vpn_as, vpn_rd,vpn_tag_in, vpn_tag_out], addresses]
|
|
136
|
+
else
|
|
137
|
+
vpn_apply << [if_sap, [vpn_id, vpn_name, vpn_desc, if_name], [vpn_as, vpn_rd,vpn_tag_in, vpn_tag_out], addresses]
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
return intfs, subintfs, abpools, vpn_apply
|
|
143
|
+
end
|
|
144
|
+
|
|
18
145
|
def 接口配置 正文
|
|
19
|
-
|
|
146
|
+
ports = []
|
|
147
|
+
basics = 正文['Port Configuration'].join("\n").match_paragraph("\n port","\n exit").map{|port|"port "+port}
|
|
148
|
+
basics.each do|basic|
|
|
149
|
+
类型,连接符,端口 = self.端口识别 basic
|
|
150
|
+
ports << [端口, basic]
|
|
151
|
+
end
|
|
152
|
+
networks = 正文['Router (Network Side) Configuration'].join("\n").match_paragraph("\n interface ","\n exit").map{|port|"interface "+port}
|
|
153
|
+
networks.each do|network|
|
|
154
|
+
端口 = network.split("\n").select{|line|line.include?("port ")}.map{|line|line.split("port ").last}.join
|
|
155
|
+
if port = ports.find{|port|port==端口}
|
|
156
|
+
ports.index(port)
|
|
157
|
+
ports[index] << network
|
|
158
|
+
else
|
|
159
|
+
端口 = network.split("\n").select{|line|line.include?("interface ")}.map{|line|line.split("interface ")[1..-1].join(' ')}.join
|
|
160
|
+
ports << [端口, network]
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
return ports
|
|
20
164
|
end
|
|
21
165
|
|
|
22
166
|
def 接口分捡 接口集合
|
|
23
|
-
[]
|
|
167
|
+
return 接口集合,[],[]
|
|
24
168
|
end
|
|
25
169
|
|
|
26
|
-
def 端口识别
|
|
170
|
+
def 端口识别 接口配置
|
|
171
|
+
描述 = 接口配置.is_a?(Array) ? 接口配置[1..-1].join("\n") : 接口配置
|
|
172
|
+
连接符 = ' '
|
|
173
|
+
类型 = 'Port'
|
|
174
|
+
port = /(\w+|\-|\_|\d+|\/|\:|\s+)+/.match(描述.split("\n").first.split(" ")[1..-1].join(' '))
|
|
175
|
+
端口 = port ? port.to_s : '未知端口'
|
|
176
|
+
return 类型,连接符,端口
|
|
27
177
|
end
|
|
28
178
|
|
|
29
179
|
def 接口地址 接口配置
|
|
180
|
+
地址集 = []
|
|
181
|
+
接口配置.join("\n").each_line do|line|
|
|
182
|
+
if line.strip[0..6]=='address'
|
|
183
|
+
地址集 << line.split('address')[-1].strip.split('/')
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
地址集
|
|
30
187
|
end
|
|
31
188
|
|
|
32
189
|
def 接口描述 接口配置
|
|
190
|
+
描述 = ''
|
|
191
|
+
接口配置.join("\n").each_line do|line| if line.strip[0..10]=='description'
|
|
192
|
+
描述 = line.split('description')[-1].strip; break
|
|
193
|
+
end end
|
|
194
|
+
描述.to_s[1..-2]
|
|
33
195
|
end
|
|
34
196
|
|
|
35
197
|
def 接口vpn实例 接口配置
|