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/04 16:39:56 UTC
[6/6] git commit: CIMI: make CIMI::Model::VolumeImage.find behave
like Machine.find
CIMI: make CIMI::Model::VolumeImage.find behave like Machine.find
TrackedAt: http://tracker.deltacloud.org/patch/31b0b82f80cff66df01e6a4cb3a6e88e91a24f6d
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/775cbdf2
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/775cbdf2
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/775cbdf2
Branch: refs/heads/master
Commit: 775cbdf26226b0460a577b61bb9ff44453bb4dbb
Parents: 1d95d5a
Author: David Lutterkort <lu...@redhat.com>
Authored: Mon Dec 3 21:26:45 2012 -0800
Committer: marios <ma...@redhat.com>
Committed: Tue Dec 4 17:26:38 2012 +0200
----------------------------------------------------------------------
server/lib/cimi/models/volume.rb | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/775cbdf2/server/lib/cimi/models/volume.rb
----------------------------------------------------------------------
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