From: marios <[email protected]>

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

diff --git a/server/lib/cimi/model/volume_image.rb 
b/server/lib/cimi/model/volume_image.rb
index ee35d16..0ebfb01 100644
--- a/server/lib/cimi/model/volume_image.rb
+++ b/server/lib/cimi/model/volume_image.rb
@@ -20,4 +20,29 @@ class CIMI::Model::VolumeImage < CIMI::Model::Base
   array :operations do
     scalar :rel, :href
   end
+
+  def self.find(id, _self)
+    storage_snapshots = []
+    opts = ( id==:all  ) ? {}  : { :id=>id }
+    storage_snapshots = self.driver.storage_snapshots(_self.credentials, opts)
+    storage_snapshots.collect!{ |snapshot| from_storage_snapshot(snapshot, 
_self) }
+    return storage_snapshots.first unless storage_snapshots.length > 1
+    return storage_snapshots
+  end
+
+  def self.all(_self); find(:all, _self); end
+
+  private
+
+  def self.from_storage_snapshot(snapshot, _self)
+    self.new( {
+               :name => snapshot.id,
+               :description => snapshot.id,
+               :created => snapshot.created,
+               :uri => _self.volume_image_url(snapshot.id),
+               :image_location => 
{:href=>_self.volume_url(snapshot.storage_volume_id)},
+               :bootable => "false"
+            } )
+  end
+
 end
-- 
1.7.6.4

Reply via email to