vtysh 0.3.1 → 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: 0ed942b5f955b7ded1197ac751c727cdbb147e398a686404f8a5a8fdbdeddf4c
4
- data.tar.gz: 8482829a628cc5a749b239a7f85e7772457e948e30176a07307c82fea1478f8f
3
+ metadata.gz: 62c5e8dbb9d45551d43f6ac68445fa4e4a6943638be57c341a36bb0e1e205c0c
4
+ data.tar.gz: 3ec8a30a7efdd26158d091901d757e95f103758e53e9ad9143bf79a8a58832c4
5
5
  SHA512:
6
- metadata.gz: 44fd6c72180ea3fa3ad2c0f3f1cd0e3b3e459a7215b67e12c443d8f31a53f1e2b5cea95d2da33a60e9a95c42bb432ad79dc3918f37b8bf7e26c70e84f9ad16bb
7
- data.tar.gz: ef5462c970d6cc8de9f33236c1392c2037b8032cb8efa607ec29628f27e7403c109423c7c16ccf3bf74db55c505de53e7d89cc022a71fee05880dec38d2a5d62
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 ---
data/lib/vtysh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vtysh
2
- VERSION = "0.3.1"
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.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel