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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d3f9346d18059a1eaf1fda46792cc7c0af2739c83a142655fa3aed5be4c89fa
4
- data.tar.gz: b0592d6296671e88b50eeb0e78fcee76f2c565bf49c7b4dd54e99525067ed9b0
3
+ metadata.gz: 0ed942b5f955b7ded1197ac751c727cdbb147e398a686404f8a5a8fdbdeddf4c
4
+ data.tar.gz: 8482829a628cc5a749b239a7f85e7772457e948e30176a07307c82fea1478f8f
5
5
  SHA512:
6
- metadata.gz: 8df6e7efc8a4f1eb8b3e5917494ce90c257b131cc7d313daba6d9637ad1092cd2ea23e95646e418cc1381d98bd3309cc09b6c2e7ee8741ed1a6584d07bdc2d56
7
- data.tar.gz: 59fd750b7ca377f69fd1eee1c83595183b464e9ac0d5960279b397a331e15c093843702101cf9b173fa5b1f5fa905c74044c2dea79a8cb25e5e4f1ce9a0abad0
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
- route_maps = commands.select { |c| c.include?("route-map") && !c.include?("no ") }
164
- removals = commands.select { |c| c.include?("no ") } - prefix_lists
165
- rest = commands - prefix_lists - route_maps - removals
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 + removals).uniq
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 ') # managed by config_db, not vtysh
190
- next if line.start_with?('hostname ') # managed by system hostname, FRR auto-inherits
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
@@ -1,3 +1,3 @@
1
1
  module Vtysh
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vtysh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel