deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@redhat.com
Subject [PATCH 1/3] CIMI: make CIMI::Model::VolumeImage.find behavie like Machine.find
Date Mon, 03 Dec 2012 07:54:07 GMT
From: David Lutterkort <lutter@redhat.com>

---
 server/lib/cimi/models/volume_image.rb |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/server/lib/cimi/models/volume_image.rb b/server/lib/cimi/models/volume_image.rb
index 5052ff5..811d9c9 100644
--- a/server/lib/cimi/models/volume_image.rb
+++ b/server/lib/cimi/models/volume_image.rb
@@ -25,12 +25,15 @@ class CIMI::Model::VolumeImage < CIMI::Model::Base
   end
 
   def self.find(id, context)
-    storage_snapshots = []
-    opts = ( id==:all  ) ? {}  : { :id=>id }
-    storage_snapshots = context.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
+    creds = context.credentials
+    if id == :all
+      snapshots = context.driver.storage_snapshots(creds)
+      snapshots.collect{ |snapshot| from_storage_snapshot(snapshot, context) }
+    else
+      snapshot = context.driver.storage_snapshots(creds)
+      raise CIMI::Model::NotFound unless snapshot
+      from_storage_snapshot(snapshot)
+    end
   end
 
   def self.all(context); find(:all, context); end
-- 
1.7.7.6


Mime
View raw message