network-utility 1.1.41 → 1.1.42

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.
@@ -0,0 +1,87 @@
1
+
2
+ # NE8000E-X8 流策略、路由策略
3
+
4
+ ```ruby
5
+ @sign << ['NE8000E-X8', 'traffic']
6
+ @sign << ['NE8000E-X8', 'traffic_classifier']
7
+ @sign << ['NE8000E-X8', 'traffic_behavior']
8
+ @sign << ['NE8000E-X8', 'traffic_policy']
9
+
10
+ module NE8000E_X8
11
+ module_function
12
+
13
+ def traffic conflist
14
+ tc,tb,tp = ['traffic_classifier','traffic_behavior','traffic_policy'].map{|t|self.send(t,conflist)}
15
+ end
16
+
17
+ # {name => {classifier => [matchers], operator => opt}, ...}
18
+ def traffic_classifier conflist
19
+ tc = {}
20
+ conflist['traffic'].each do|traffic|
21
+ next unless traffic.include?('classifier')
22
+ name,tab = nil,{'operator'=>''}
23
+ traffic.split("\n").each do|line|
24
+ if line.include?('traffic classifier ')
25
+ tc[name] = tab
26
+ name, opt, op = line.split(' ')[2..4]
27
+ tab = {'operator'=>op}
28
+ else
29
+ matcher = line.split(' ')
30
+ tab['classifier'] ||= []
31
+ tab['classifier'] << matcher # sequences
32
+ end
33
+ end
34
+ tc[name] = tab # last tc
35
+ tc.delete(nil)
36
+ end if conflist['traffic']
37
+ return tc
38
+ end
39
+
40
+ # {name => [behaviors], ...}
41
+ def traffic_behavior conflist
42
+ tb = {}
43
+ conflist['traffic'].each do|traffic|
44
+ next unless traffic.include?('behavior')
45
+ name,tab = nil,{'behavior'=>[]}
46
+ traffic.split("\n").each do|line|
47
+ if line.include?('traffic behavior ')
48
+ tb[name] = tab
49
+ name,tab = line.split(' ')[2],{'behavior'=>[]}
50
+ else
51
+ behavior = line.split(' ')
52
+ tab['behavior'] << behavior # sequences
53
+ end
54
+ end
55
+ tb[name] = tab # last tb
56
+ tb.delete(nil)
57
+ end if conflist['traffic']
58
+ return tb
59
+ end
60
+
61
+ # {name => {policy => {classifier => [behavior,precedence], ...}, mode => mode}, ...}
62
+ def traffic_policy conflist
63
+ tp = {}
64
+ conflist['traffic'].each do|traffic|
65
+ next unless traffic.include?('policy')
66
+ name,tab = nil,{'policy'=>{}}
67
+ traffic.split("\n").each do|line|
68
+ if line.include?('traffic policy ')
69
+ tp[name] = tab
70
+ name,tab = line.split(' ')[2],{'policy'=>{}}
71
+ elsif line.include?('-mode')
72
+ tab['mode'] = 'share-mode'
73
+ elsif line.include?('statistics ')
74
+ tab['statistics'] = line.split(' ')[1]
75
+ else
76
+ policy = line.split(' ')
77
+ classifier, behavior, precedence = policy[1],policy[3],policy[5]
78
+ tab['policy'].merge!({ classifier => (precedence ? [behavior,precedence] : [behavior]) }) # tree
79
+ end
80
+ end
81
+ tp[name] = tab # last tb
82
+ tp.delete(nil)
83
+ end if conflist['traffic']
84
+ return tp
85
+ end
86
+ end
87
+ ```
@@ -0,0 +1,87 @@
1
+
2
+ # NE8100-X8 流策略、路由策略
3
+
4
+ ```ruby
5
+ @sign << ['NE8100-X8', 'traffic']
6
+ @sign << ['NE8100-X8', 'traffic_classifier']
7
+ @sign << ['NE8100-X8', 'traffic_behavior']
8
+ @sign << ['NE8100-X8', 'traffic_policy']
9
+
10
+ module NE8100_X8
11
+ module_function
12
+
13
+ def traffic conflist
14
+ tc,tb,tp = ['traffic_classifier','traffic_behavior','traffic_policy'].map{|t|self.send(t,conflist)}
15
+ end
16
+
17
+ # {name => {classifier => [matchers], operator => opt}, ...}
18
+ def traffic_classifier conflist
19
+ tc = {}
20
+ conflist['traffic'].each do|traffic|
21
+ next unless traffic.include?('classifier')
22
+ name,tab = nil,{'operator'=>''}
23
+ traffic.split("\n").each do|line|
24
+ if line.include?('traffic classifier ')
25
+ tc[name] = tab
26
+ name, opt, op = line.split(' ')[2..4]
27
+ tab = {'operator'=>op}
28
+ else
29
+ matcher = line.split(' ')
30
+ tab['classifier'] ||= []
31
+ tab['classifier'] << matcher # sequences
32
+ end
33
+ end
34
+ tc[name] = tab # last tc
35
+ tc.delete(nil)
36
+ end if conflist['traffic']
37
+ return tc
38
+ end
39
+
40
+ # {name => [behaviors], ...}
41
+ def traffic_behavior conflist
42
+ tb = {}
43
+ conflist['traffic'].each do|traffic|
44
+ next unless traffic.include?('behavior')
45
+ name,tab = nil,{'behavior'=>[]}
46
+ traffic.split("\n").each do|line|
47
+ if line.include?('traffic behavior ')
48
+ tb[name] = tab
49
+ name,tab = line.split(' ')[2],{'behavior'=>[]}
50
+ else
51
+ behavior = line.split(' ')
52
+ tab['behavior'] << behavior # sequences
53
+ end
54
+ end
55
+ tb[name] = tab # last tb
56
+ tb.delete(nil)
57
+ end if conflist['traffic']
58
+ return tb
59
+ end
60
+
61
+ # {name => {policy => {classifier => [behavior,precedence], ...}, mode => mode}, ...}
62
+ def traffic_policy conflist
63
+ tp = {}
64
+ conflist['traffic'].each do|traffic|
65
+ next unless traffic.include?('policy')
66
+ name,tab = nil,{'policy'=>{}}
67
+ traffic.split("\n").each do|line|
68
+ if line.include?('traffic policy ')
69
+ tp[name] = tab
70
+ name,tab = line.split(' ')[2],{'policy'=>{}}
71
+ elsif line.include?('-mode')
72
+ tab['mode'] = 'share-mode'
73
+ elsif line.include?('statistics ')
74
+ tab['statistics'] = line.split(' ')[1]
75
+ else
76
+ policy = line.split(' ')
77
+ classifier, behavior, precedence = policy[1],policy[3],policy[5]
78
+ tab['policy'].merge!({ classifier => (precedence ? [behavior,precedence] : [behavior]) }) # tree
79
+ end
80
+ end
81
+ tp[name] = tab # last tb
82
+ tp.delete(nil)
83
+ end if conflist['traffic']
84
+ return tp
85
+ end
86
+ end
87
+ ```
@@ -0,0 +1,87 @@
1
+
2
+ # VNE9000 流策略、路由策略
3
+
4
+ ```ruby
5
+ @sign << ['VNE9000', 'traffic']
6
+ @sign << ['VNE9000', 'traffic_classifier']
7
+ @sign << ['VNE9000', 'traffic_behavior']
8
+ @sign << ['VNE9000', 'traffic_policy']
9
+
10
+ module VNE9000
11
+ module_function
12
+
13
+ def traffic conflist
14
+ tc,tb,tp = ['traffic_classifier','traffic_behavior','traffic_policy'].map{|t|self.send(t,conflist)}
15
+ end
16
+
17
+ # {name => {classifier => [matchers], operator => opt}, ...}
18
+ def traffic_classifier conflist
19
+ tc = {}
20
+ conflist['traffic'].each do|traffic|
21
+ next unless traffic.include?('classifier')
22
+ name,tab = nil,{'operator'=>''}
23
+ traffic.split("\n").each do|line|
24
+ if line.include?('traffic classifier ')
25
+ tc[name] = tab
26
+ name, opt, op = line.split(' ')[2..4]
27
+ tab = {'operator'=>op}
28
+ else
29
+ matcher = line.split(' ')
30
+ tab['classifier'] ||= []
31
+ tab['classifier'] << matcher # sequences
32
+ end
33
+ end
34
+ tc[name] = tab # last tc
35
+ tc.delete(nil)
36
+ end if conflist['traffic']
37
+ return tc
38
+ end
39
+
40
+ # {name => [behaviors], ...}
41
+ def traffic_behavior conflist
42
+ tb = {}
43
+ conflist['traffic'].each do|traffic|
44
+ next unless traffic.include?('behavior')
45
+ name,tab = nil,{'behavior'=>[]}
46
+ traffic.split("\n").each do|line|
47
+ if line.include?('traffic behavior ')
48
+ tb[name] = tab
49
+ name,tab = line.split(' ')[2],{'behavior'=>[]}
50
+ else
51
+ behavior = line.split(' ')
52
+ tab['behavior'] << behavior # sequences
53
+ end
54
+ end
55
+ tb[name] = tab # last tb
56
+ tb.delete(nil)
57
+ end if conflist['traffic']
58
+ return tb
59
+ end
60
+
61
+ # {name => {policy => {classifier => [behavior,precedence], ...}, mode => mode}, ...}
62
+ def traffic_policy conflist
63
+ tp = {}
64
+ conflist['traffic'].each do|traffic|
65
+ next unless traffic.include?('policy')
66
+ name,tab = nil,{'policy'=>{}}
67
+ traffic.split("\n").each do|line|
68
+ if line.include?('traffic policy ')
69
+ tp[name] = tab
70
+ name,tab = line.split(' ')[2],{'policy'=>{}}
71
+ elsif line.include?('-mode')
72
+ tab['mode'] = 'share-mode'
73
+ elsif line.include?('statistics ')
74
+ tab['statistics'] = line.split(' ')[1]
75
+ else
76
+ policy = line.split(' ')
77
+ classifier, behavior, precedence = policy[1],policy[3],policy[5]
78
+ tab['policy'].merge!({ classifier => (precedence ? [behavior,precedence] : [behavior]) }) # tree
79
+ end
80
+ end
81
+ tp[name] = tab # last tb
82
+ tp.delete(nil)
83
+ end if conflist['traffic']
84
+ return tp
85
+ end
86
+ end
87
+ ```
@@ -0,0 +1,56 @@
1
+
2
+ # M6000-16E 流量、光功率、用户数统计
3
+
4
+ ```ruby
5
+ @sign << ['M6000-16E', 'flux_statistic']
6
+ @sign << ['M6000-16E', 'optical_statistic']
7
+ @sign << ['M6000-16E', 'subscriber_statistic']
8
+
9
+ module M6000_16E
10
+ module_function
11
+
12
+ def flux_statistic content
13
+ context,flag = [], false
14
+ head = ['interface', 'in_flux(bps)', # Bps => bps
15
+ 'in_percent(bps)','out_flux', # Bps => bps
16
+ 'out_percent','in_error','in_optical','out_optical']
17
+ content.split("\n").each do|line|
18
+ (flag = true;next) if line.include?('#### begin flux ####')
19
+ break if line.include?('#### end flux ####')
20
+ if flag
21
+ words = line.strip.split(' ')
22
+ next if words.size < 8
23
+ context << [words[0], words[1].to_i*8, words[2]+'%', words[3].to_i*8, words[4]+'%', words[5].to_i, words[6].to_f, words[7].to_f]
24
+ end
25
+ end
26
+ context.sort_by!{|c|c[0]}
27
+ context.unshift head
28
+ return context
29
+ end
30
+
31
+ def optical_statistic content_or_table
32
+ content = content_or_table.is_a?(Array) ? content_or_table : (self.flux_statistic content_or_table)
33
+ # head: ['interface', 'in_optical', 'out_optical']
34
+ return content.map{|c|[c[0],c[-2],c[-1]]}
35
+ end
36
+
37
+ def subscriber_statistic content
38
+ context,flag = [], false
39
+ head = ['domain','state','limit','num','num(v4)','num(v6)','num(dual)']
40
+ content.split("\n").each do|line|
41
+ (flag = true;next) if line.include?('#### begin subscriber ####')
42
+ break if line.include?('#### end subscriber ####')
43
+ if flag
44
+ words = line.strip.split(' ')
45
+ next if words.size != 4 || words.include?('subscriber')
46
+ num, sub = words[-1].split('(')
47
+ num4, num6, numd = sub.split(')').first.split('/')
48
+ context << words[0..1]+ [words[2].to_i, num.to_i, num4.to_i, num6.to_i, numd.to_i]
49
+ end
50
+ end
51
+ context.sort_by!{|c|c[0]}
52
+ context.unshift head
53
+ return context
54
+ end
55
+ end
56
+ ```
@@ -0,0 +1,147 @@
1
+
2
+ # M6000-18S 流量、光功率、用户数统计
3
+
4
+ ```ruby
5
+ @sign << ['M6000-18S', 'flux_statistic']
6
+ @sign << ['M6000-18S', 'optical_statistic']
7
+ @sign << ['M6000-18S', 'subscriber_statistic']
8
+
9
+ module M6000_18S
10
+ module_function
11
+
12
+ def flux_statistic content
13
+ context,flag,record = [], false, []
14
+ content.split("\n").each do|line|
15
+ (flag = true;next) if line.include?('#### begin flux ####')
16
+ next if line.include?('show intf-statistics utilization')
17
+ next if line.strip.empty?
18
+ break if line.include?('#### end flux ####')
19
+ if flag
20
+ words = line.strip.split(' ')
21
+ if words.size==4
22
+ if record.size==4 # no desc, add an new record
23
+ context << record+['']
24
+ record = [words[0], words[1]+"%", words[2]+"%", words[3].to_i]
25
+ else # normal
26
+ record += [words[0], words[1]+"%", words[2]+"%", words[3].to_i]
27
+ end
28
+ elsif words.size < 4 # desc, attach to current record
29
+ record += words if record.size==4
30
+ context << record
31
+ record = []
32
+ end
33
+ end
34
+ end
35
+ context = context[1..-1].select{|c|!c.empty?}
36
+ context.sort_by!{|c|c[0]}
37
+ context.unshift head=['interface','in_percent', 'out_percent', 'in_error', 'description']
38
+ return context
39
+ end
40
+
41
+ def optical_statistic content
42
+ context,flag = [], false
43
+ if_name, mod_type, wav_len, in_dbm, in_range, out_dbm, out_range, state = '','','',[],[],[],[],[]
44
+ content.split("\n").each do|line|
45
+ (flag = true;next) if line.include?('#### begin optical ####')
46
+ next if line.include?('show opticalinfo brief')
47
+ next if line.strip.empty?
48
+ break if line.include?('#### end optical ####')
49
+ if flag
50
+ words = line.strip.split(' ')
51
+ next if words[0].include?('Interface') || words[0].include?('TxPower')
52
+ if words.size==4 # if_name, mod_type, wav_len, in_dbm
53
+ if_name, mod_type, wav_len = words[0..2]
54
+ in_optical,others = words[3].split('/[')
55
+ in_ranges = others.gsub(']','').split(',').map{|r|r.to_f} if others
56
+ in_dbm << (in_optical=='N/A' ? 'N/A' : in_optical.to_f)
57
+ in_range << in_ranges if others
58
+ elsif words.size==6 # if_name, mod_type, wav_len, in_dbm, out_dbm, state
59
+ if_name, mod_type, wav_len = words[0..2]
60
+ in_optical,others = words[3].split('/[')
61
+ in_ranges = others.gsub(']','').split(',').map{|r|r.to_f} if others
62
+ in_dbm << (in_optical=='N/A' ? 'N/A' : in_optical.to_f)
63
+ in_range << in_ranges if others
64
+ out_optical, others = words[4].split('/[')
65
+ out_ranges = others.gsub(']','').split(',').map{|r|r.to_f} if others
66
+ out_dbm << (out_optical=='N/A' ? 'N/A' : out_optical.to_f)
67
+ out_range << out_ranges if others
68
+ state << words[5]
69
+ elsif words.size==3 # in_dbm, out_dbm, state
70
+ in_optical,others = words[0].split('/[')
71
+ in_ranges = others.gsub(']','').split(',').map{|r|r.to_f} if others
72
+ in_dbm << (in_optical=='N/A' ? 'N/A' : in_optical.to_f)
73
+ in_range << in_ranges if others
74
+ out_optical, others = words[1].split('/[')
75
+ out_ranges = others.gsub(']','').split(',').map{|r|r.to_f} if others
76
+ out_dbm << (out_optical=='N/A' ? 'N/A' : out_optical.to_f)
77
+ out_range << out_ranges if others
78
+ state << words[2]
79
+ elsif words.size==2
80
+ if words.include?('offline') # if_name, mod_type='offline'
81
+ context << words+['',[],[],[],[],[]]
82
+ if_name, mod_type, wav_len, in_dbm, in_range, out_dbm, out_range, state = '','','',[],[],[],[],[]
83
+ next
84
+ end
85
+ if words[1].match(/(\d|\.)+/) # in_dbm, out_dbm
86
+ in_optical,others = words[0].split('/[')
87
+ in_ranges = others.gsub(']','').split(',').map{|r|r.to_f} if others
88
+ in_dbm << (in_optical=='N/A' ? 'N/A' : in_optical.to_f)
89
+ in_range << in_ranges if others
90
+ out_optical, others = words[1].split('/[')
91
+ out_ranges = others.gsub(']','').split(',').map{|r|r.to_f} if others
92
+ out_dbm << (out_optical=='N/A' ? 'N/A' : out_optical.to_f)
93
+ out_range << out_ranges if others
94
+ else # out_dbm, state
95
+ out_optical, others = words[0].split('/[')
96
+ out_ranges = others.gsub(']','').split(',').map{|r|r.to_f} if others
97
+ out_dbm << (out_optical=='N/A' ? 'N/A' : out_optical.to_f)
98
+ out_range << out_ranges if others
99
+ state << words[1]
100
+ end
101
+ elsif words.size==1 # in_dbm/out_dbm
102
+ optical, others = words[0].split('/[')
103
+ ranges = others.gsub(']','').split(',').map{|r|r.to_f} if others
104
+ in_dbm << (optical=='N/A' ? 'N/A' : optical.to_f) if in_dbm.size<=out_dbm.size
105
+ out_dbm << (optical=='N/A' ? 'N/A' : optical.to_f) if in_dbm.size>out_dbm.size
106
+ in_range << ranges if others && in_range.size<=out_range.size
107
+ out_range << ranges if others && in_range.size>out_range.size
108
+ end
109
+ if ( !if_name.empty? && !mod_type.empty? && !wav_len.empty? && !in_dbm.empty? && !out_dbm.empty? && !state.empty? )
110
+ if if_name.include?('cgei')
111
+ if in_dbm.size > 4 && out_dbm.size > 4
112
+ context << [if_name, mod_type, wav_len, in_dbm, in_range, out_dbm, out_range, state]
113
+ if_name, mod_type, wav_len, in_dbm, in_range, out_dbm, out_range, state = '','','',[],[],[],[],[]
114
+ end
115
+ else
116
+ context << [if_name, mod_type, wav_len, in_dbm, in_range, out_dbm, out_range, state]
117
+ if_name, mod_type, wav_len, in_dbm, in_range, out_dbm, out_range, state = '','','',[],[],[],[],[]
118
+ end
119
+ end
120
+
121
+ end
122
+ end
123
+ context.sort_by!{|c|c[0]}
124
+ context.unshift head=['interface','module_type', 'wave_length', 'in_optical','in_range','out_optical','out_range','state']
125
+ return context
126
+ end
127
+
128
+ def subscriber_statistic content
129
+ context,flag = [], false
130
+ head = ['domain','state','limit','num','num(v4)','num(v6)','num(dual)']
131
+ content.split("\n").each do|line|
132
+ (flag = true;next) if line.include?('#### begin subscriber ####')
133
+ break if line.include?('#### end subscriber ####')
134
+ if flag
135
+ words = line.strip.split(' ')
136
+ next if words.size != 4 || words.include?('subscriber')
137
+ num, sub = words[-1].split('(')
138
+ num4, num6, numd = sub.split(')').first.split('/')
139
+ context << words[0..1]+ [words[2].to_i, num.to_i, num4.to_i, num6.to_i, numd.to_i]
140
+ end
141
+ end
142
+ context.sort_by!{|c|c[0]}
143
+ context.unshift head
144
+ return context
145
+ end
146
+ end
147
+ ```
@@ -0,0 +1,56 @@
1
+
2
+ # M6000-8 流量、光功率、用户数统计
3
+
4
+ ```ruby
5
+ @sign << ['M6000-8', 'flux_statistic']
6
+ @sign << ['M6000-8', 'optical_statistic']
7
+ @sign << ['M6000-8', 'subscriber_statistic']
8
+
9
+ module M6000_8
10
+ module_function
11
+
12
+ def flux_statistic content
13
+ context,flag = [], false
14
+ head = ['interface', 'in_flux(bps)', # Bps => bps
15
+ 'in_percent(bps)','out_flux', # Bps => bps
16
+ 'out_percent','in_error','in_optical','out_optical']
17
+ content.split("\n").each do|line|
18
+ (flag = true;next) if line.include?('#### begin flux ####')
19
+ break if line.include?('#### end flux ####')
20
+ if flag
21
+ words = line.strip.split(' ')
22
+ next if words.size < 8
23
+ context << [words[0], words[1].to_i*8, words[2]+'%', words[3].to_i*8, words[4]+'%', words[5].to_i, words[6].to_f, words[7].to_f]
24
+ end
25
+ end
26
+ context.sort_by!{|c|c[0]}
27
+ context.unshift head
28
+ return context
29
+ end
30
+
31
+ def optical_statistic content_or_table
32
+ content = content_or_table.is_a?(Array) ? content_or_table : (self.flux_statistic content_or_table)
33
+ # head: ['interface', 'in_optical', 'out_optical']
34
+ return content.map{|c|[c[0],c[-2],c[-1]]}
35
+ end
36
+
37
+ def subscriber_statistic content
38
+ context,flag = [], false
39
+ head = ['domain','state','limit','num','num(v4)','num(v6)','num(dual)']
40
+ content.split("\n").each do|line|
41
+ (flag = true;next) if line.include?('#### begin subscriber ####')
42
+ break if line.include?('#### end subscriber ####')
43
+ if flag
44
+ words = line.strip.split(' ')
45
+ next if words.size != 4 || words.include?('subscriber')
46
+ num, sub = words[-1].split('(')
47
+ num4, num6, numd = sub.split(')').first.split('/')
48
+ context << words[0..1]+ [words[2].to_i, num.to_i, num4.to_i, num6.to_i, numd.to_i]
49
+ end
50
+ end
51
+ context.sort_by!{|c|c[0]}
52
+ context.unshift head
53
+ return context
54
+ end
55
+ end
56
+ ```
@@ -0,0 +1,56 @@
1
+
2
+ # M6000-8E 流量、光功率、用户数统计
3
+
4
+ ```ruby
5
+ @sign << ['M6000-8E', 'flux_statistic']
6
+ @sign << ['M6000-8E', 'optical_statistic']
7
+ @sign << ['M6000-8E', 'subscriber_statistic']
8
+
9
+ module M6000_8E
10
+ module_function
11
+
12
+ def flux_statistic content
13
+ context,flag = [], false
14
+ head = ['interface', 'in_flux(bps)', # Bps => bps
15
+ 'in_percent(bps)','out_flux', # Bps => bps
16
+ 'out_percent','in_error','in_optical','out_optical']
17
+ content.split("\n").each do|line|
18
+ (flag = true;next) if line.include?('#### begin flux ####')
19
+ break if line.include?('#### end flux ####')
20
+ if flag
21
+ words = line.strip.split(' ')
22
+ next if words.size < 8
23
+ context << [words[0], words[1].to_i*8, words[2]+'%', words[3].to_i*8, words[4]+'%', words[5].to_i, words[6].to_f, words[7].to_f]
24
+ end
25
+ end
26
+ context.sort_by!{|c|c[0]}
27
+ context.unshift head
28
+ return context
29
+ end
30
+
31
+ def optical_statistic content_or_table
32
+ content = content_or_table.is_a?(Array) ? content_or_table : (self.flux_statistic content_or_table)
33
+ # head: ['interface', 'in_optical', 'out_optical']
34
+ return content.map{|c|[c[0],c[-2],c[-1]]}
35
+ end
36
+
37
+ def subscriber_statistic content
38
+ context,flag = [], false
39
+ head = ['domain','state','limit','num','num(v4)','num(v6)','num(dual)']
40
+ content.split("\n").each do|line|
41
+ (flag = true;next) if line.include?('#### begin subscriber ####')
42
+ break if line.include?('#### end subscriber ####')
43
+ if flag
44
+ words = line.strip.split(' ')
45
+ next if words.size != 4 || words.include?('subscriber')
46
+ num, sub = words[-1].split('(')
47
+ num4, num6, numd = sub.split(')').first.split('/')
48
+ context << words[0..1]+ [words[2].to_i, num.to_i, num4.to_i, num6.to_i, numd.to_i]
49
+ end
50
+ end
51
+ context.sort_by!{|c|c[0]}
52
+ context.unshift head
53
+ return context
54
+ end
55
+ end
56
+ ```
@@ -0,0 +1,78 @@
1
+ # CX600-X16A VPN
2
+
3
+ ```ruby
4
+ @sign << ['CX600-X16A', 'vpn_instance']
5
+ @sign << ['CX600-X16A', 'evpn_instance']
6
+ @sign << ['CX600-X16A', 'bridge_domain']
7
+ @sign << ['CX600-X16A', 'if_bridge_domain']
8
+
9
+ module CX600_X16A
10
+ module_function
11
+
12
+ def vpn_instance conf
13
+ doc = {}
14
+ vpn_family = 'ipv4-family'
15
+ conf.split("\n").each do|line|
16
+ doc['vpn-name'] = line.split('vpn-instance ').last.strip if line.include?('ip') && line.include?('vpn-instance')
17
+ vpn_family = 'ipv4-family' if line.include?('ipv4-family')
18
+ vpn_family = 'ipv6-family' if line.include?('ipv6-family')
19
+ doc[vpn_family] ||= {}
20
+ doc[vpn_family]['route-distinguisher'] = line.split('route-distinguisher ').last.strip if line.include?('route-distinguisher')
21
+ if line.include?('vpn-target')
22
+ family = line.include?('evpn') ? 'evpn' : vpn_family.split('-').first
23
+ direction = 'export' if line.include?('export')
24
+ direction = 'import' if line.include?('import')
25
+ words = line.split('vpn-target ').last.split(' ')
26
+ target = words.select{|w|!w.include?('community') && !w.include?('evpn') && !w.strip.empty?}.map{|w|w.strip}
27
+ doc[vpn_family][family] ||= {}
28
+ doc[vpn_family][family][direction] ||= []
29
+ doc[vpn_family][family][direction] += target
30
+ end
31
+ end
32
+ return doc
33
+ end
34
+
35
+ def evpn_instance conf
36
+ doc = {}
37
+ conf.split("\n").each do|line|
38
+ doc['vpn-name'] = line.split('vpn-instance ')[-1].split(' ').first.strip if line.include?('evpn') && line.include?('vpn-instance')
39
+ doc['mode'] = 'bd-mode' if line.include?('bd-mode') && line.include?('vpn-instance')
40
+ doc['route-distinguisher'] = line.split('route-distinguisher ').last.strip if line.include?('route-distinguisher')
41
+ if line.include?('segment-routing')
42
+ doc['segment-routing'] ||= {}
43
+ family = line.include?('ipv6') ? 'ipv6-family' : 'ipv4-family'
44
+ doc['segment-routing'][family] ||= {}
45
+ doc['segment-routing'][family]['mode'] = 'best-effort' if line.include?('best-effort')
46
+ doc['segment-routing'][family]['locator'] = line.split('locator ').last.strip if line.include?('locator')
47
+ end
48
+ if line.include?('vpn-target')
49
+ direction = 'export' if line.include?('export')
50
+ direction = 'import' if line.include?('import')
51
+ words = line.split('vpn-target ').last.split(' ')
52
+ target = words.select{|w|!w.include?('community') && !w.include?('evpn') && !w.strip.empty?}.map{|w|w.strip}
53
+ doc['vpn-target'] ||= {}
54
+ doc['vpn-target'][direction] ||= []
55
+ doc['vpn-target'][direction] += target
56
+ end
57
+ end
58
+ return doc
59
+ end
60
+
61
+ def bridge_domain bdconf
62
+ bd = {}
63
+ bdconf.split("\n").each do|line|
64
+ bd['bridge-domain'] = line.split(' ').last.strip if line.include?('bridge-domain')
65
+ bd['statistic'] = 'enable' if line.include?('statistic enable')
66
+ bd['evpn-instance'] = line.split("vpn-instance").last.strip if line.include?('vpn-instance')
67
+ end
68
+ return bd
69
+ end
70
+
71
+ def if_bridge_domain ifconf
72
+ ifconf.split("\n").each do|line|
73
+ return line.split(' ').last.strip if line.include?('bridge-domain')
74
+ end
75
+ return nil
76
+ end
77
+ end
78
+ ```