incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michal Fojtik <mfoj...@redhat.com>
Subject Re: [PATCH] - Added the basic feature of create storage volumes at mock driver
Date Mon, 28 Mar 2011 09:17:56 GMT
On Mar 21, 2011, at 9:06 PM, felipe.cardoso.martins@gmail.com wrote:

> From: Felipe Cardoso Martins <felipe.cardoso.martins@gmail.com>
> 
> ---
> server/lib/deltacloud/drivers/mock/mock_driver.rb |   38 +++++++++++++++++++++
> 1 files changed, 38 insertions(+), 0 deletions(-)
> 
> diff --git a/server/lib/deltacloud/drivers/mock/mock_driver.rb b/server/lib/deltacloud/drivers/mock/mock_driver.rb
> index 7d229c4..b18b5c9 100644
> --- a/server/lib/deltacloud/drivers/mock/mock_driver.rb
> +++ b/server/lib/deltacloud/drivers/mock/mock_driver.rb
> @@ -282,6 +282,44 @@ class MockDriver < Deltacloud::BaseDriver
>     volumes
>   end
> 
> +  def create_storage_volume(credentials, opts=nil)
> +    check_credentials(credentials)
> +
> +    ids = Dir[ "#{@storage_root}/storage_volumes/*.yml" ].collect{|e| File.basename(
e, ".yml" )}
> +
> +    count = 0 
> +    while true
> +      next_id = "vol" + count.to_s
> +      if not ids.include?(next_id)
> +        break
> +      end 
> +      count = count + 1 
> +    end 
> +
> +    opts ||= {}
> +    opts[:capacity] ||= "1"
> +    opts[:realm_id] ||= realms(credentials).first.id
> +
> +    volume = {
> +      :owner_id => credentials.user,
> +      :created => Time.now,
> +      :state => 'AVAILABLE',
> +      :capacity => opts[:capacity],
> +      :realm_id => opts[:realm_id],
> +      :device => '',
> +      :instance_id => '',
> +      :actions => [:attach, :detach, :destroy]
> +     }
> +
> +     File.open( "#{@storage_root}/storage_volumes/#{next_id}.yml", 'w' ) {|f|
> +       YAML.dump( volume, f ) 
> +     }
> +
> +     volume[:id] = next_id
> +
> +     StorageVolume.new( volume )
> +  end
> +

ACK. It work's for me.
Btw. Did you have send CLA signed and scanned as PDF document to secretary@apache.org?
Once you will do this, I'll commit this patch to SVN.

  -- Michal

>   #
>   # Storage Snapshots
>   #
> -- 
> 1.7.1
> 

------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org


Mime
View raw message