deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@redhat.com
Subject [PATCH 1/6] CIMI: make CIMI::Model::VolumeImage.find behave like Machine.find
Date Tue, 04 Dec 2012 08:42:29 GMT
From: David Lutterkort <lutter@redhat.com>

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

diff --git a/server/lib/cimi/models/volume.rb b/server/lib/cimi/models/volume.rb
index 7951a99..6a6d42f 100644
--- a/server/lib/cimi/models/volume.rb
+++ b/server/lib/cimi/models/volume.rb
@@ -38,12 +38,15 @@ class CIMI::Model::Volume < CIMI::Model::Base
   end
 
   def self.find(id, context)
-    volumes = []
-    opts = ( id == :all ) ? {} : { :id => id }
-    volumes = context.driver.storage_volumes(context.credentials, opts)
-    volumes.collect!{ |volume| from_storage_volume(volume, context) }
-    return volumes.first unless volumes.length > 1 || volumes.length == 0
-    return volumes
+    creds = context.credentials
+    if id == :all
+      volumes = context.driver.storage_volumes(creds)
+      volumes.collect{ |volume| from_storage_volume(volume, context) }
+    else
+      volume = context.driver.storage_volumes(creds)
+      raise CIMI::Model::NotFound unless volume
+      from_storage_volume(volume)
+    end
   end
 
   def self.all(context); find(:all, context); end
-- 
1.7.7.6


Mime
View raw message