Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

digs into pageable response for snapshot lists #128

Merged
merged 2 commits into from Jun 28, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions libraries/ec2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ module Aws
module Ec2
def find_snapshot_id(volume_id = '', find_most_recent = false)
snapshot_id = nil
snapshots = if find_most_recent
ec2.describe_snapshots.sort { |a, b| a[:start_time] <=> b[:start_time] }
else
ec2.describe_snapshots.sort { |a, b| b[:start_time] <=> a[:start_time] }
response = if find_most_recent
ec2.describe_snapshots.sort { |a, b| a[:start_time] <=> b[:start_time] }
else
ec2.describe_snapshots.sort { |a, b| b[:start_time] <=> a[:start_time] }
end
snapshots.each do |snapshot|
if snapshot[:volume_id] == volume_id
snapshot_id = snapshot[:snapshot_id]
response.each do |page|
page.snapshots.each do |snapshot|
if snapshot[:volume_id] == volume_id && snapshot[:state] == 'completed'
snapshot_id = snapshot[:snapshot_id]
end
end
end
fail 'Cannot find snapshot id!' unless snapshot_id
Expand Down