deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r1207876 - /deltacloud/trunk/server/lib/cimi/model/volume_image.rb
Date Tue, 29 Nov 2011 13:33:58 GMT
Author: marios
Date: Tue Nov 29 13:33:58 2011
New Revision: 1207876

URL: http://svn.apache.org/viewvc?rev=1207876&view=rev
Log:
Adds find&conversion methods to CIMI::VolumeImage model

Modified:
    deltacloud/trunk/server/lib/cimi/model/volume_image.rb

Modified: deltacloud/trunk/server/lib/cimi/model/volume_image.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/lib/cimi/model/volume_image.rb?rev=1207876&r1=1207875&r2=1207876&view=diff
==============================================================================
--- deltacloud/trunk/server/lib/cimi/model/volume_image.rb (original)
+++ deltacloud/trunk/server/lib/cimi/model/volume_image.rb Tue Nov 29 13:33:58 2011
@@ -20,4 +20,29 @@ class CIMI::Model::VolumeImage < CIMI::M
   array :operations do
     scalar :rel, :href
   end
+
+  def self.find(id, context)
+    storage_snapshots = []
+    opts = ( id==:all  ) ? {}  : { :id=>id }
+    storage_snapshots = self.driver.storage_snapshots(context.credentials, opts)
+    storage_snapshots.collect!{ |snapshot| from_storage_snapshot(snapshot, context) }
+    return storage_snapshots.first unless storage_snapshots.length > 1
+    return storage_snapshots
+  end
+
+  def self.all(context); find(:all, context); end
+
+  private
+
+  def self.from_storage_snapshot(snapshot, context)
+    self.new( {
+               :name => snapshot.id,
+               :description => snapshot.id,
+               :created => snapshot.created,
+               :uri => context.volume_image_url(snapshot.id),
+               :image_location => {:href=>context.volume_url(snapshot.storage_volume_id)},
+               :bootable => "false"  #FIXME
+            } )
+  end
+
 end



Mime
View raw message