in cookbooks/fb_storage/libraries/storage.rb [451:493]
def self.calculate_updated_order(prev, devs)
Chef::Log.debug(
'fb_storage: Attempting to merge old and new config',
)
new_mapping = prev.dup
slots_to_replace = []
Chef::Log.debug("fb_storage: previous list: #{prev}")
Chef::Log.debug("fb_storage: current devs: #{devs}")
prev.each_with_index do |disk, index|
slots_to_replace << index unless devs.include?(disk)
end
new_disks = devs.reject do |disk|
prev.include?(disk)
end
if new_disks.size != slots_to_replace.size
fail 'fb_storage: Could not map disks to previous ' +
"ordering: new disks: #{new_disks}, avail slots: " +
"#{slots_to_replace}."
end
if new_disks.size.zero?
fail 'fb_storage: Found no difference between old' +
' and new disks, but somehow didn\'t think they were the same' +
' before. Bailing out because I\'m very scared.'
end
new_disks.each_with_index do |disk, index|
slot = slots_to_replace[index]
new_mapping[slot] = disk
end
Chef::Log.info(
"fb_storage: Previous disk mapping: #{prev}",
)
Chef::Log.info(
"fb_storage: New disk mapping: #{new_mapping}",
)
new_mapping
end