From: David Lutterkort <lut...@redhat.com> --- server/lib/cimi/models/volume_image.rb | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-)
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 -- 1.7.7.6