aio_elin 0.0.1 → 1.0.0
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/config.rb +32 -32
- data/lib/aio/base/toolkit/excel_wps.rb +1 -0
- data/lib/aio/base/toolkit/hash.rb +95 -0
- data/lib/aio/base/toolkit/myers.rb +161 -0
- data/lib/aio/base/toolkit.rb +2 -0
- data/lib/aio/core/device/cmd_switch.rb +1 -1
- data/lib/aio/core/device/h3c.rb +2 -0
- data/lib/aio/core/device/maipu.rb +8 -0
- data/lib/aio/core/device/methods.rb +230 -228
- data/lib/aio/core/device/parent_device.rb +270 -267
- data/lib/aio/core/device_manager.rb +255 -202
- data/lib/aio/core/module/cmd.rb +155 -150
- data/lib/aio/core/module/compare.rb +39 -0
- data/lib/aio/core/module/output_style.rb +2 -0
- data/lib/aio/core/module.rb +1 -0
- data/lib/aio/core/module_loader.rb +11 -0
- data/lib/aio/core/parse/file.rb +12 -14
- data/lib/aio/core/parse/parser.rb +99 -87
- data/lib/aio/core/parse/parser_machine/has_device_state.rb +42 -42
- data/lib/aio/core/parse/parser_machine.rb +44 -44
- data/lib/aio/core/text/block.rb +88 -0
- data/lib/aio/core/text/compare.rb +109 -0
- data/lib/aio/core/text/context.rb +206 -206
- data/lib/aio/core/text/line_string.rb +17 -62
- data/lib/aio/core/text/match_string_info.rb +73 -0
- data/lib/aio/core/text/warning.rb +175 -175
- data/lib/aio/core/text.rb +3 -0
- data/lib/aio/core/warning/warning_summarize.rb +246 -229
- data/lib/aio/core.rb +3 -0
- data/lib/aio/ui/logger.rb +38 -0
- data/lib/aio/ui/verbose.rb +6 -2
- data/lib/aio/ui.rb +135 -134
- data/lib/modules/cmd/cisco/show_version.rb +84 -84
- data/lib/modules/cmd/h3c/display_cpu.rb +41 -41
- data/lib/modules/cmd/h3c/display_version.rb +43 -43
- data/lib/modules/cmd/maipu/show_clock.rb +32 -0
- data/lib/modules/cmd/maipu/show_cpu.rb +36 -0
- data/lib/modules/cmd/maipu/show_ip_interface_brief.rb +44 -0
- data/lib/modules/cmd/maipu/show_memory.rb +22 -22
- data/lib/modules/cmd/maipu/show_version.rb +40 -40
- data/lib/modules/input/style/compare_xml.rb +73 -73
- data/lib/modules/output/style/cmds.rb +3 -3
- data/lib/modules/output/style/compare_diff.rb +23 -0
- data/lib/modules/output/style/excel_table_office.rb +1 -0
- data/lib/modules/output/style/excel_table_wps.rb +1 -0
- data/lib/modules/output/style/summary_report.rb +2 -1
- data/lib/modules/special/style/compare.rb +153 -103
- data/lib/modules/special/style/compare_old.rb +121 -0
- data/lib/modules/special/style/compare_with_device_manager.rb +227 -0
- metadata +16 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ae728450dab4400107566a22aa9e1d102a5311e93f1d4ead17cb844feb010ab
|
4
|
+
data.tar.gz: 1fc85e23825735a437265adb3a2ec68231af9bc325ea600eabf867c90237ae59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3f26b2c23d7bdccf1b732c094fccd484fa0e1bd70452b9b40cbc71c40004e4a96b707721833f4f7aa4dfb894d99a9e41a9223ef9f37985e3e12e3577850d23f
|
7
|
+
data.tar.gz: 475b1f4e5051096bd29764d9d6fc52ab6c6bd4e742cb02167ebce59b800c3b0db9ef83ef668c886f7d378594df45e90069dff77b2ccf79297c4993637fe2d883
|
data/config.rb
CHANGED
@@ -1,39 +1,39 @@
|
|
1
1
|
# 此配置模块用于过滤多余的警告信息
|
2
2
|
|
3
3
|
module Aio::Config
|
4
|
-
|
5
|
-
|
4
|
+
module Warning
|
5
|
+
Pass = "pass"
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
Serious = [
|
8
|
+
#:crc,
|
9
|
+
#:input_errors,
|
10
|
+
]
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
Ordinary = [
|
13
|
+
#:total_output_drops,
|
14
|
+
:iface_resets,
|
15
|
+
:giants,
|
16
|
+
]
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
18
|
+
# 包括数值 或者 Pass
|
19
|
+
Compare = {
|
20
|
+
# version
|
21
|
+
uptime: Pass,
|
22
|
+
# interface
|
23
|
+
crc: 50,
|
24
|
+
frame: Pass,
|
25
|
+
# memory
|
26
|
+
proc_ratio: 50,
|
27
|
+
# cpu
|
28
|
+
minute_1: 10,
|
29
|
+
minutes_5: 10,
|
30
|
+
# clock
|
31
|
+
time: Pass,
|
32
|
+
week: Pass,
|
33
|
+
year: Pass,
|
34
|
+
month: Pass,
|
35
|
+
day: Pass,
|
36
|
+
}
|
37
|
+
end
|
38
38
|
end
|
39
|
-
|
39
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# 这个类是用来对Hash链路进行二元数组化的一个链路存储
|
2
|
+
module Aio::Base::Toolkit
|
3
|
+
class Chain
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@chain = []
|
7
|
+
end
|
8
|
+
|
9
|
+
# 分裂出多条key值数组
|
10
|
+
def split(key, num)
|
11
|
+
|
12
|
+
if @chain.empty?
|
13
|
+
num.times { @chain.push [key.to_s] }
|
14
|
+
|
15
|
+
else
|
16
|
+
last = @chain.pop
|
17
|
+
tmp = ::Array.new(num) { last.clone << key }
|
18
|
+
@chain.concat tmp
|
19
|
+
@chain
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# 获取一条链路
|
24
|
+
def get_line
|
25
|
+
@chain.pop
|
26
|
+
end
|
27
|
+
|
28
|
+
def empty?
|
29
|
+
@chain.empty?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# 将嵌套的Hash变成二元数组
|
34
|
+
module Hash
|
35
|
+
def self.flat_cm1(cm, chain, res)
|
36
|
+
Hash.flat(cm, chain, res, :cm1)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.flat_cm2(cm, chain, res)
|
40
|
+
Hash.flat(cm, chain, res, :cm2)
|
41
|
+
end
|
42
|
+
|
43
|
+
# 返回的是以StringConcat为元素的数组
|
44
|
+
def self.flat(cm, chain, res, cm_type)
|
45
|
+
cm.each_pair do |key, val|
|
46
|
+
|
47
|
+
if val.kind_of? ::Hash
|
48
|
+
chain.split(key, val.size)
|
49
|
+
Aio::Base::Toolkit::Hash.flat(val, chain, res, cm_type)
|
50
|
+
|
51
|
+
else
|
52
|
+
|
53
|
+
last_chain = chain.get_line unless chain.empty?
|
54
|
+
last_chain ||= []
|
55
|
+
|
56
|
+
last_chain.push(key.to_s)
|
57
|
+
last_chain.push(val)
|
58
|
+
|
59
|
+
res << StringConcat.new(last_chain, cm_type)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# 建立一个结构体,方便包含cm的类型进行比较
|
65
|
+
StringConcat = Struct.new(:line, :string, :cm_type) do
|
66
|
+
def initialize(line, cm_type)
|
67
|
+
super(
|
68
|
+
line,
|
69
|
+
long_name(line),
|
70
|
+
cm_type
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
def long_name(arr)
|
75
|
+
res = ''
|
76
|
+
arr.each { |x| res += x.to_s }
|
77
|
+
res
|
78
|
+
end
|
79
|
+
|
80
|
+
# 判断与另一个StringConcat是否相等
|
81
|
+
def eql?(other)
|
82
|
+
self.string == other.string
|
83
|
+
end
|
84
|
+
|
85
|
+
def inspect
|
86
|
+
self.line
|
87
|
+
end
|
88
|
+
|
89
|
+
def to_s
|
90
|
+
self.string
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
@@ -0,0 +1,161 @@
|
|
1
|
+
##
|
2
|
+
# Myers 比较排序算法
|
3
|
+
##
|
4
|
+
|
5
|
+
module Aio::Base::Toolkit
|
6
|
+
|
7
|
+
module Diff
|
8
|
+
Line = Struct.new(:number, :text, :diff?) do
|
9
|
+
def inspect
|
10
|
+
text.to_s
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.lines(document, lines)
|
15
|
+
# document = document.lines if document.is_a?(String)
|
16
|
+
document.map.with_index do |text, i|
|
17
|
+
bool = lines.include?(i)
|
18
|
+
Line.new(i + 1, text, bool)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.empty_line
|
23
|
+
Line.new(0, '', false)
|
24
|
+
end
|
25
|
+
|
26
|
+
# CompareDiff
|
27
|
+
def self.diff(cd, differ: Myers)
|
28
|
+
differ.diff(
|
29
|
+
lines(cd.content, cd.lines),
|
30
|
+
lines(cd.content_compare, cd.lines_compare)
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class Myers
|
36
|
+
|
37
|
+
def self.diff(a, b)
|
38
|
+
new(a, b).diff
|
39
|
+
end
|
40
|
+
|
41
|
+
def initialize(a, b)
|
42
|
+
@a, @b = a, b
|
43
|
+
end
|
44
|
+
|
45
|
+
def shortest_edit
|
46
|
+
n, m = @a.size, @b.size
|
47
|
+
max = n + m
|
48
|
+
|
49
|
+
v = ::Array.new(2 * max + 1)
|
50
|
+
v[1] = 0
|
51
|
+
trace = []
|
52
|
+
|
53
|
+
(0..max).step do |d|
|
54
|
+
trace << v.clone
|
55
|
+
|
56
|
+
(-d..d).step(2) do |k|
|
57
|
+
|
58
|
+
if k == -d or (k != d and v[k-1] < v[k+1])
|
59
|
+
x = v[k+1]
|
60
|
+
else
|
61
|
+
x = v[k-1] + 1
|
62
|
+
end
|
63
|
+
|
64
|
+
y = x - k
|
65
|
+
|
66
|
+
# while x < n and y < m and @a[x].text == @b[y].text
|
67
|
+
while x < n and y < m and !@a[x].diff? and !@b[y].diff?
|
68
|
+
x, y = x + 1, y + 1
|
69
|
+
end
|
70
|
+
|
71
|
+
v[k] = x
|
72
|
+
|
73
|
+
return trace if x >= n and y >= m
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def backtrack
|
79
|
+
x, y = @a.size, @b.size
|
80
|
+
|
81
|
+
shortest_edit.each_with_index.reverse_each do |v, d|
|
82
|
+
k = x - y
|
83
|
+
|
84
|
+
if k == -d or (k != d and v[k-1] < v[k+1])
|
85
|
+
prev_k = k + 1
|
86
|
+
else
|
87
|
+
prev_k = k - 1
|
88
|
+
end
|
89
|
+
|
90
|
+
prev_x = v[prev_k]
|
91
|
+
prev_y = prev_x - prev_k
|
92
|
+
|
93
|
+
while x > prev_x and y > prev_y
|
94
|
+
yield x - 1, y - 1, x, y
|
95
|
+
x, y = x - 1, y - 1
|
96
|
+
end
|
97
|
+
|
98
|
+
yield prev_x, prev_y, x, y if d > 0
|
99
|
+
|
100
|
+
x, y = prev_x, prev_y
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def diff
|
105
|
+
diff = []
|
106
|
+
|
107
|
+
backtrack do |prev_x, prev_y, x, y|
|
108
|
+
a_line, b_line = @a[prev_x], @b[prev_y]
|
109
|
+
|
110
|
+
if x == prev_x
|
111
|
+
diff.unshift(Diff::Edit.new(:ins, nil, b_line))
|
112
|
+
elsif y == prev_y
|
113
|
+
diff.unshift(Diff::Edit.new(:del, a_line, nil))
|
114
|
+
else
|
115
|
+
diff.unshift(Diff::Edit.new(:eql, a_line, b_line))
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# 此时得到的是按顺序排列的数组
|
120
|
+
diff
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
module Diff
|
126
|
+
Edit = Struct.new(:type, :old_line, :new_line) do
|
127
|
+
def old_number
|
128
|
+
return '' if old_line.number.to_s == '0'
|
129
|
+
old_line ? old_line.number.to_s : ''
|
130
|
+
end
|
131
|
+
|
132
|
+
def new_number
|
133
|
+
return '' if new_line.number.to_s == '0'
|
134
|
+
new_line ? new_line.number.to_s : ''
|
135
|
+
end
|
136
|
+
|
137
|
+
def text
|
138
|
+
(old_line || new_line).text
|
139
|
+
end
|
140
|
+
|
141
|
+
def empty?
|
142
|
+
(old_line.empty? and new_line.empty?)
|
143
|
+
end
|
144
|
+
|
145
|
+
def type_class
|
146
|
+
type.to_s + '_style'
|
147
|
+
end
|
148
|
+
|
149
|
+
def type_class_con
|
150
|
+
type.to_s + '_style_con'
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.empty_line
|
154
|
+
Edit.new(:eql, Diff.empty_line, Diff.empty_line)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
|
data/lib/aio/base/toolkit.rb
CHANGED
data/lib/aio/core/device/h3c.rb
CHANGED
@@ -6,6 +6,14 @@ module Aio::Device
|
|
6
6
|
@device_type = "maipu"
|
7
7
|
end
|
8
8
|
|
9
|
+
Interface = {
|
10
|
+
geth: "GigabitEthernet".downcase,
|
11
|
+
feth: "FastEthernet".downcase,
|
12
|
+
eth: "Ethernet".downcase,
|
13
|
+
loopback: "Loopback".downcase,
|
14
|
+
vlan_if: "Vlan-interface".downcase
|
15
|
+
}
|
16
|
+
|
9
17
|
end
|
10
18
|
end
|
11
19
|
|