Swift-ring-builder skip line 'Ring up-to-date..'

If a ring is balanced or does not need an update, swift-ring-builder
will print an additional line:
"Ring file /etc/swift/container.ring.gz is up-to-date"
Skip this line in parsing the output to avoid "Warning: Unexpected line:"

Change-Id: Ibc021f62f699c94f36c76b11acefe1000f6a2288
This commit is contained in:
Adam Vinsh 2016-05-13 16:19:50 -04:00 committed by Emilien Macchi
parent 9531e4a400
commit 5323bf83ac
1 changed files with 4 additions and 0 deletions

View File

@ -22,6 +22,10 @@ class Puppet::Provider::SwiftRingBuilder < Puppet::Provider
if File.exists?(builder_file_path)
# Swift < 2.2.2 Skip first 4 info lines from swift-ring-builder output
if rows = swift_ring_builder(builder_file_path).split("\n")[4..-1]
# Skip "Ring file ... is up-to-date" message, if printed.
if !rows[0].nil? and rows[0] =~ /Ring file\b.*\bis up-to-date/
rows.shift
end
# Swift 2.2.2+ Skip additional line to account for Overload info
if !rows[0].nil? and rows[0].start_with?('Devices:')
rows.shift