vtysh 0.2.2 → 0.3.1
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/lib/vtysh/diff.rb +23 -6
- data/lib/vtysh/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0ed942b5f955b7ded1197ac751c727cdbb147e398a686404f8a5a8fdbdeddf4c
|
|
4
|
+
data.tar.gz: 8482829a628cc5a749b239a7f85e7772457e948e30176a07307c82fea1478f8f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 44fd6c72180ea3fa3ad2c0f3f1cd0e3b3e459a7215b67e12c443d8f31a53f1e2b5cea95d2da33a60e9a95c42bb432ad79dc3918f37b8bf7e26c70e84f9ad16bb
|
|
7
|
+
data.tar.gz: ef5462c970d6cc8de9f33236c1392c2037b8032cb8efa607ec29628f27e7403c109423c7c16ccf3bf74db55c505de53e7d89cc022a71fee05880dec38d2a5d62
|
data/lib/vtysh/diff.rb
CHANGED
|
@@ -160,11 +160,24 @@ module Vtysh
|
|
|
160
160
|
|
|
161
161
|
def self.reorder_non_bgp(commands)
|
|
162
162
|
prefix_lists = commands.select { |c| c.include?("ip prefix-list") }
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
# Only match route-map block creation (2 -c args), not commands inside route-maps
|
|
164
|
+
route_maps = commands.select { |c| c.include?("route-map") && !c.include?("no ") && c.scan(/-c "/).count == 2 }
|
|
165
|
+
top_level_removals = commands.select { |c| c.include?("no ") && c.scan(/-c "/).count <= 2 } - prefix_lists
|
|
166
|
+
rest = commands - prefix_lists - route_maps - top_level_removals
|
|
167
|
+
|
|
168
|
+
# Within context: group by context path, put removals before additions
|
|
169
|
+
# so FRR replaces set/match statements correctly (remove old, then add new)
|
|
170
|
+
rest = rest.group_by { |c|
|
|
171
|
+
parts = c.scan(/-c "([^"]+)"/).flatten
|
|
172
|
+
parts[0..-2].join("|") # context = all but last -c arg
|
|
173
|
+
}.flat_map { |_ctx, cmds|
|
|
174
|
+
cmds.sort_by { |c|
|
|
175
|
+
last_arg = c.scan(/-c "([^"]+)"/).flatten.last
|
|
176
|
+
last_arg&.start_with?("no ") ? 0 : 1
|
|
177
|
+
}
|
|
178
|
+
}
|
|
166
179
|
|
|
167
|
-
(prefix_lists + route_maps + rest +
|
|
180
|
+
(prefix_lists + route_maps + rest + top_level_removals).uniq
|
|
168
181
|
end
|
|
169
182
|
|
|
170
183
|
def self.reorder_bgp(commands)
|
|
@@ -186,8 +199,12 @@ module Vtysh
|
|
|
186
199
|
config.each_line do |line|
|
|
187
200
|
line = line.strip
|
|
188
201
|
next if line.empty? || line.start_with?('#', '!')
|
|
189
|
-
next if line.start_with?('ip route ')
|
|
190
|
-
next if line.start_with?('hostname ')
|
|
202
|
+
next if line.start_with?('ip route ') # managed by config_db STATIC_ROUTE
|
|
203
|
+
next if line.start_with?('hostname ') # managed by system hostname
|
|
204
|
+
next if line == 'ip nht resolve-via-default' # bgpcfgd managed
|
|
205
|
+
next if line == 'ipv6 nht resolve-via-default' # bgpcfgd managed
|
|
206
|
+
next if line == 'ip protocol bgp route-map RM_SET_SRC' # bgpcfgd managed
|
|
207
|
+
next if line =~ /^(no )?set src / # bgpcfgd managed (inside RM_SET_SRC)
|
|
191
208
|
next if line =~ /^frr (version|defaults)/ || line == 'no service integrated-vtysh-config' || line.start_with?('agentx')
|
|
192
209
|
|
|
193
210
|
if line =~ /^exit(-address-family|-vrf)?$/
|
data/lib/vtysh/version.rb
CHANGED