You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by ma...@redhat.com on 2011/11/25 18:27:16 UTC
[PATCH 2/5] Adds find&conversion methods to CIMI::Volume model
From: marios <ma...@redhat.com>
Signed-off-by: marios <ma...@redhat.com>
---
server/lib/cimi/model/volume.rb | 31 ++++++++++++++++++++++++++++++-
1 files changed, 30 insertions(+), 1 deletions(-)
diff --git a/server/lib/cimi/model/volume.rb b/server/lib/cimi/model/volume.rb
index ed80903..4bdd6ca 100644
--- a/server/lib/cimi/model/volume.rb
+++ b/server/lib/cimi/model/volume.rb
@@ -27,8 +27,37 @@ class CIMI::Model::Volume < CIMI::Model::Base
array :meters do
scalar :ref
end
- scalar :eventlog
+ href :eventlog
array :operations do
scalar :rel, :href
end
+
+ def self.find(id, _self)
+ volumes = []
+ opts = ( id == :all ) ? {} : { :id => id }
+ volumes = self.driver.storage_volumes(_self.credentials, opts)
+ volumes.collect!{ |volume| from_storage_volume(volume, _self) }
+ return volumes.first unless volumes.length > 1
+ return volumes
+ end
+
+ def self.all(_self); find(:all, _self); end
+
+ private
+
+ def self.from_storage_volume(volume, _self)
+ self.new( { :name => volume.id,
+ :description => volume.id,
+ :created => volume.created,
+ :uri => _self.volume_url(volume.id),
+ :capacity => { :quantity=>volume.capacity, :units=>"gibibyte" }, #FIXME... units will vary
+ :bootable => "false", #fixme ... will vary... ec2 doesn't expose this
+ :supports_snapshots => "true", #fixme, will vary (true for ec2)
+ :snapshots => [], #fixme...
+ :guest_interface => "",
+ :eventlog => {:href=> "http://eventlogs"},
+ :meters => []
+ } )
+ end
+
end
--
1.7.6.4