vtysh 0.3.0 → 0.3.2

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: 82af2f794b12e4604356c693dc1aa73f26f428edc60c2558f8d9705a78f7f8cc
4
- data.tar.gz: 291f564282919ad448c93088ef01feaef15cfc6fffa30c9e891f97fba7831ae0
3
+ metadata.gz: 62c5e8dbb9d45551d43f6ac68445fa4e4a6943638be57c341a36bb0e1e205c0c
4
+ data.tar.gz: 3ec8a30a7efdd26158d091901d757e95f103758e53e9ad9143bf79a8a58832c4
5
5
  SHA512:
6
- metadata.gz: fd57d52ef5fc5e15a59c697c60f69b8d2426da5919bf0a8c11b6dda01758d8e9a2462dc295c953a0eb1c31ee199be308d1d1526a2749f4307d951c3dbdfc8210
7
- data.tar.gz: 811a633022e9b16114947ba5853d1b6295ee29639ed9608ac320db43f327e4ba6b7f37a3d30732a03b1ab9e8d9319af2135d191762abbca47da688910d703fe1
6
+ metadata.gz: e1871a6cf2ac84e722189a5ed99838cb63dfbb01a90fd3f1177c89c2cec2512b8977a40601dde43788b586cbc6c106932db4ef8c6758098216eec127cc8db496
7
+ data.tar.gz: 8cdf921bcad92f66b14e3887006172edc580ff7cd104010f5c0eed72d38289e983f18c44fe00f14eab17cc14cd11f35c7ac030d6768eed691c46f92bc6369d3c
data/lib/vtysh/diff.rb CHANGED
@@ -187,7 +187,22 @@ module Vtysh
187
187
  removals = commands.select { |c| c.include?("no ") }
188
188
  rest = commands - peer_groups - remote_as - listen_range - removals
189
189
 
190
- (peer_groups + remote_as + listen_range + rest + removals).uniq
190
+ # A removal whose slot is reclaimed by an addition must run first, or FRR
191
+ # rejects the addition as overlapping the value it supersedes.
192
+ slots = (commands - removals).map { |c| slot_key(c) }.compact
193
+ superseded, other = removals.partition { |c| slots.include?(slot_key(c)) }
194
+
195
+ (peer_groups + remote_as + superseded + listen_range + rest + other).uniq
196
+ end
197
+
198
+ # Identifies commands that occupy one logical slot, so the "no" form and the
199
+ # form replacing it hash alike. Nil when the command owns no exclusive slot.
200
+ def self.slot_key(command)
201
+ parts = command.scan(/-c "([^"]+)"/).flatten
202
+ slot = case parts.last.to_s.sub(/\Ano /, "")
203
+ when /\Abgp listen range \S+ peer-group (\S+)\z/ then "listen-range:#{$1}"
204
+ end
205
+ slot && (parts[0..-2] + [slot]).join("|")
191
206
  end
192
207
 
193
208
  # --- Parsing ---
@@ -199,7 +214,12 @@ module Vtysh
199
214
  config.each_line do |line|
200
215
  line = line.strip
201
216
  next if line.empty? || line.start_with?('#', '!')
202
- next if line.start_with?('ip route ') # managed by config_db, not vtysh
217
+ next if line.start_with?('ip route ') # managed by config_db STATIC_ROUTE
218
+ next if line.start_with?('hostname ') # managed by system hostname
219
+ next if line == 'ip nht resolve-via-default' # bgpcfgd managed
220
+ next if line == 'ipv6 nht resolve-via-default' # bgpcfgd managed
221
+ next if line == 'ip protocol bgp route-map RM_SET_SRC' # bgpcfgd managed
222
+ next if line =~ /^(no )?set src / # bgpcfgd managed (inside RM_SET_SRC)
203
223
  next if line =~ /^frr (version|defaults)/ || line == 'no service integrated-vtysh-config' || line.start_with?('agentx')
204
224
 
205
225
  if line =~ /^exit(-address-family|-vrf)?$/
data/lib/vtysh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vtysh
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.2"
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.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel