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:18 UTC

[PATCH 4/5] Adds find operation to CIMI::VolumeConfiguration model

From: marios <ma...@redhat.com>

VolumeConfigurations are created on the fly - none of our cloud providers
supports this model... following ec2 where storage_volumes can be 1..1000 GiB

Signed-off-by: marios <ma...@redhat.com>
---
 server/lib/cimi/model/volume_configuration.rb |   32 +++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/server/lib/cimi/model/volume_configuration.rb b/server/lib/cimi/model/volume_configuration.rb
index 4de0032..7304080 100644
--- a/server/lib/cimi/model/volume_configuration.rb
+++ b/server/lib/cimi/model/volume_configuration.rb
@@ -24,4 +24,36 @@ class CIMI::Model::VolumeConfiguration < CIMI::Model::Base
   array :operations do
     scalar :rel, :href
   end
+
+  def self.find(id, _self)
+    volume_configs = []
+    if id == :all
+      #ec2 ebs volumes can 1gb..1tb
+      (1..1000).each do |size|
+        volume_configs << create(size, _self)
+      end
+    else
+      volume_configs << create(id, _self)
+      return volume_configs.first
+    end
+    return volume_configs
+  end
+
+
+  def self.all(_self); find(:all, _self); end
+
+  private
+
+  def self.create(size, _self)
+    self.new( {
+                :uri => _self.machine_configuration_url(size),
+                :name => size,
+                :description => "volume configuration with #{size} GiB",
+                :created => Time.now.to_s,
+                :capacity => {:quantity=>size, :units=>"gibibytes"},
+                :supports_snapshots => "true",
+                :guest_interface => "NFS"
+            } )
+  end
+
 end
-- 
1.7.6.4