deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [3/3] git commit: CIMI: make CIMI::Model::VolumeImage.find behavie like Machine.find
Date Mon, 03 Dec 2012 13:56:33 GMT
CIMI: make CIMI::Model::VolumeImage.find behavie like Machine.find


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/14f9103e
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/14f9103e
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/14f9103e

Branch: refs/heads/master
Commit: 14f9103eb0106f4cf74da48e7ab284c172c059d9
Parents: d9e21e0
Author: David Lutterkort <lutter@redhat.com>
Authored: Sun Dec 2 23:54:07 2012 -0800
Committer: marios <marios@redhat.com>
Committed: Mon Dec 3 10:10:42 2012 +0200

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


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/14f9103e/server/lib/cimi/models/volume_image.rb
----------------------------------------------------------------------
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


Mime
View raw message