deltacloud-commits mailing list archives

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

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

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

Modified: deltacloud/trunk/server/lib/cimi/model/volume.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/lib/cimi/model/volume.rb?rev=1207872&r1=1207871&r2=1207872&view=diff
==============================================================================
--- deltacloud/trunk/server/lib/cimi/model/volume.rb (original)
+++ deltacloud/trunk/server/lib/cimi/model/volume.rb Tue Nov 29 13:32:55 2011
@@ -27,8 +27,37 @@ class CIMI::Model::Volume < CIMI::Model:
   array :meters do
     scalar :ref
   end
-  scalar :eventlog
+  href :eventlog
   array :operations do
     scalar :rel, :href
   end
+
+  def self.find(id, context)
+    volumes = []
+    opts = ( id == :all ) ? {} : { :id => id }
+    volumes = self.driver.storage_volumes(context.credentials, opts)
+    volumes.collect!{ |volume| from_storage_volume(volume, context) }
+    return volumes.first unless volumes.length > 1
+    return volumes
+  end
+
+  def self.all(context); find(:all, context); end
+
+  private
+
+  def self.from_storage_volume(volume, context)
+    self.new( { :name => volume.id,
+                :description => volume.id,
+                :created => volume.created,
+                :uri => context.volume_url(volume.id),
+                :capacity => { :quantity=>volume.capacity, :units=>"gibibyte"  },
#FIXME... units will vary
+                :bootable => "false", #fixme ... will vary... ec2 doesn't expose this
+                :supports_snapshots => "true", #fixme, will vary (true for ec2)
+                :snapshots => [], #fixme...
+                :guest_interface => "",
+                :eventlog => {:href=> "http://eventlogs"},
+                :meters => []
+            } )
+  end
+
 end



Mime
View raw message