You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2010/07/09 01:20:35 UTC
svn commit: r962066 -
/incubator/deltacloud/trunk/drivers/ec2/lib/ec2_driver.rb
Author: lutter
Date: Thu Jul 8 23:20:34 2010
New Revision: 962066
URL: http://svn.apache.org/viewvc?rev=962066&view=rev
Log:
Wrap auth around snapshot and volume stuff.
Modified:
incubator/deltacloud/trunk/drivers/ec2/lib/ec2_driver.rb
Modified: incubator/deltacloud/trunk/drivers/ec2/lib/ec2_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/drivers/ec2/lib/ec2_driver.rb?rev=962066&r1=962065&r2=962066&view=diff
==============================================================================
--- incubator/deltacloud/trunk/drivers/ec2/lib/ec2_driver.rb (original)
+++ incubator/deltacloud/trunk/drivers/ec2/lib/ec2_driver.rb Thu Jul 8 23:20:34 2010
@@ -136,13 +136,15 @@ class Ec2Driver < DeltaCloud::BaseDriver
def storage_volumes(credentials, opts=nil)
ec2 = new_client( credentials )
volumes = []
- if (opts)
- ec2.describe_volumes(opts[:id]).each do |ec2_volume|
- volumes << convert_volume( ec2_volume )
- end
- else
- ec2.describe_volumes().each do |ec2_volume|
- volumes << convert_volume( ec2_volume )
+ safely do
+ if (opts)
+ ec2.describe_volumes(opts[:id]).each do |ec2_volume|
+ volumes << convert_volume( ec2_volume )
+ end
+ else
+ ec2.describe_volumes().each do |ec2_volume|
+ volumes << convert_volume( ec2_volume )
+ end
end
end
volumes
@@ -155,13 +157,15 @@ class Ec2Driver < DeltaCloud::BaseDriver
def storage_snapshots(credentials, opts=nil)
ec2 = new_client( credentials )
snapshots = []
- if (opts)
- ec2.describe_snapshots(opts[:id]).each do |ec2_snapshot|
- snapshots << convert_snapshot( ec2_snapshot )
- end
- else
- ec2.describe_snapshots(opts).each do |ec2_snapshot|
- snapshots << convert_snapshot( ec2_snapshot )
+ safely do
+ if (opts)
+ ec2.describe_snapshots(opts[:id]).each do |ec2_snapshot|
+ snapshots << convert_snapshot( ec2_snapshot )
+ end
+ else
+ ec2.describe_snapshots(opts).each do |ec2_snapshot|
+ snapshots << convert_snapshot( ec2_snapshot )
+ end
end
end
snapshots
@@ -213,12 +217,12 @@ class Ec2Driver < DeltaCloud::BaseDriver
end
def convert_snapshot(ec2_snapshot)
- {
+ StorageSnapshot.new( {
:id=>ec2_snapshot[:aws_id],
:state=>ec2_snapshot[:aws_status].upcase,
- :volume_id=>ec2_snapshot[:aws_volume_id],
+ :storage_volume_id=>ec2_snapshot[:aws_volume_id],
:created=>ec2_snapshot[:aws_started_at],
- }
+ } )
end
def safely(&block)