vtysh 0.2.2 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d3f9346d18059a1eaf1fda46792cc7c0af2739c83a142655fa3aed5be4c89fa
4
- data.tar.gz: b0592d6296671e88b50eeb0e78fcee76f2c565bf49c7b4dd54e99525067ed9b0
3
+ metadata.gz: 82af2f794b12e4604356c693dc1aa73f26f428edc60c2558f8d9705a78f7f8cc
4
+ data.tar.gz: 291f564282919ad448c93088ef01feaef15cfc6fffa30c9e891f97fba7831ae0
5
5
  SHA512:
6
- metadata.gz: 8df6e7efc8a4f1eb8b3e5917494ce90c257b131cc7d313daba6d9637ad1092cd2ea23e95646e418cc1381d98bd3309cc09b6c2e7ee8741ed1a6584d07bdc2d56
7
- data.tar.gz: 59fd750b7ca377f69fd1eee1c83595183b464e9ac0d5960279b397a331e15c093843702101cf9b173fa5b1f5fa905c74044c2dea79a8cb25e5e4f1ce9a0abad0
6
+ metadata.gz: fd57d52ef5fc5e15a59c697c60f69b8d2426da5919bf0a8c11b6dda01758d8e9a2462dc295c953a0eb1c31ee199be308d1d1526a2749f4307d951c3dbdfc8210
7
+ data.tar.gz: 811a633022e9b16114947ba5853d1b6295ee29639ed9608ac320db43f327e4ba6b7f37a3d30732a03b1ab9e8d9319af2135d191762abbca47da688910d703fe1
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)
@@ -187,7 +200,6 @@ module Vtysh
187
200
  line = line.strip
188
201
  next if line.empty? || line.start_with?('#', '!')
189
202
  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
191
203
  next if line =~ /^frr (version|defaults)/ || line == 'no service integrated-vtysh-config' || line.start_with?('agentx')
192
204
 
193
205
  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.0"
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel