You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by lu...@redhat.com on 2012/12/04 09:42:29 UTC
[PATCH 1/6] CIMI: make CIMI::Model::VolumeImage.find behave like Machine.find
From: David Lutterkort <lu...@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