You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by ma...@apache.org on 2012/12/03 14:56:33 UTC

[3/3] git commit: CIMI: make CIMI::Model::VolumeImage.find behavie like Machine.find

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 <lu...@redhat.com>
Authored: Sun Dec 2 23:54:07 2012 -0800
Committer: marios <ma...@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