From: marios <[email protected]>

Signed-off-by: marios <[email protected]>
---
 server/lib/cimi/model/volume.rb |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/server/lib/cimi/model/volume.rb b/server/lib/cimi/model/volume.rb
index ed80903..4bdd6ca 100644
--- a/server/lib/cimi/model/volume.rb
+++ b/server/lib/cimi/model/volume.rb
@@ -27,8 +27,37 @@ class CIMI::Model::Volume < CIMI::Model::Base
   array :meters do
     scalar :ref
   end
-  scalar :eventlog
+  href :eventlog
   array :operations do
     scalar :rel, :href
   end
+
+  def self.find(id, _self)
+    volumes = []
+    opts = ( id == :all ) ? {} : { :id => id }
+    volumes = self.driver.storage_volumes(_self.credentials, opts)
+    volumes.collect!{ |volume| from_storage_volume(volume, _self) }
+    return volumes.first unless volumes.length > 1
+    return volumes
+  end
+
+  def self.all(_self); find(:all, _self); end
+
+  private
+
+  def self.from_storage_volume(volume, _self)
+    self.new( { :name => volume.id,
+                :description => volume.id,
+                :created => volume.created,
+                :uri => _self.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
-- 
1.7.6.4

Reply via email to