incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "marios@redhat.com" <mandr...@redhat.com>
Subject Re: [PATCH] Adds 'create_blob' and 'delete_blob' for rackspace cloudfiles. Also some minor mods to haml for aesthetics (move 'delete' button and only display when bucket.size == 0)
Date Fri, 03 Dec 2010 17:21:53 GMT
thanks, pushed

On 03/12/10 13:40, Michal Fojtik wrote:
> On 29/11/10 16:53 +0200, marios@redhat.com wrote:
>
> Resending this ACK ;-)
>
>> From: marios <marios@redhat.com>
>>
>> ACK. Code looks safe to me. EC2 driver fix is backported also for new EC2
>> driver.
>>
>> -- Michal
>>
>> ---
>> server/lib/deltacloud/drivers/ec2/ec2_driver.rb | 4 +-
>> .../drivers/rackspace/rackspace_driver.rb | 29 +++++++++++++++++++-
>> server/views/buckets/index.html.haml | 3 +-
>> server/views/buckets/show.html.haml | 7 +++--
>> 4 files changed, 36 insertions(+), 7 deletions(-)
>>
>> diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
>> b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
>> index d38f8f7..a7a9dbb 100644
>> --- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
>> +++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
>> @@ -410,11 +410,11 @@ class EC2Driver < Deltacloud::BaseDriver
>> s3_client = s3_client(credentials)
>> #data is a construct with the temporary file created by server @.tempfile
>> #also file[:type] will give us the content-type
>> - res = s3_client.interface.put(bucket_id, blob_id, data.tempfile,
>> {"Content-Type" => data[:type]})
>> + res = s3_client.interface.put(bucket_id, blob_id, data[:tempfile],
>> {"Content-Type" => data[:type]})
>> #create a new Blob object and return that
>> Blob.new( { :id => blob_id,
>> :bucket => bucket_id,
>> - :content_length => data.tempfile.length,
>> + :content_length => data[:tempfile].length,
>> :content_type => data[:type],
>> :last_modified => ''
>> }
>> diff --git
>> a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
>> b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
>> index 7d7d367..e40fb9c 100644
>> --- a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
>> +++ b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
>> @@ -228,6 +228,33 @@ class RackspaceDriver < Deltacloud::BaseDriver
>> end
>> end
>>
>> +#--
>> +# Create Blob
>> +#--
>> + def create_blob(credentials, bucket_id, blob_id, blob_data, opts=nil)
>> + cf = cloudfiles_client(credentials)
>> + #must first create the object using cloudfiles_client.create_object
>> + #then can write using object.write(data)
>> + object = cf.container(bucket_id).create_object(blob_id)
>> + #blob_data is a construct with data in .tempfile and content-type in
>> {:type}
>> + res = object.write(blob_data[:tempfile], {'Content-Type' =>
>> blob_data[:type]})
>> + Blob.new( { :id => object.name,
>> + :bucket => object.container.name,
>> + :content_length => blob_data[:tempfile].length,
>> + :content_type => blob_data[:type],
>> + :last_modified => ''
>> + }
>> + )
>> + end
>> +
>> +#--
>> +# Delete Blob
>> +#--
>> + def delete_blob(credentials, bucket_id, blob_id, opts=nil)
>> + cf = cloudfiles_client(credentials)
>> + cf.container(bucket_id).delete_object(blob_id)
>> + end
>> +
>> private
>>
>> def convert_srv_to_instance(srv)
>> @@ -271,7 +298,7 @@ private
>>
>> def cloudfiles_client(credentials)
>> safely do
>> - CloudFiles::Connection.new(credentials.user, credentials.password)
>> + CloudFiles::Connection.new(:username => credentials.user, :api_key
>> => credentials.password)
>> end
>> end
>>
>> diff --git a/server/views/buckets/index.html.haml
>> b/server/views/buckets/index.html.haml
>> index 279d06d..0cb7ebe 100644
>> --- a/server/views/buckets/index.html.haml
>> +++ b/server/views/buckets/index.html.haml
>> @@ -30,4 +30,5 @@
>> -bucket.blob_list.each do |blob|
>> = blob
>> %td
>> - =link_to_action 'Delete', destroy_bucket_url(bucket.name), :delete
>> + -if bucket.size == 0
>> + =link_to_action 'Delete', destroy_bucket_url(bucket.name), :delete
>> diff --git a/server/views/buckets/show.html.haml
>> b/server/views/buckets/show.html.haml
>> index 6346a50..9be3696 100644
>> --- a/server/views/buckets/show.html.haml
>> +++ b/server/views/buckets/show.html.haml
>> @@ -14,9 +14,10 @@
>> %dd
>> -@bucket.blob_list.each do |blob|
>> = link_to blob, bucket_url(@bucket.name) + '/' + blob
>> - %dt Delete bucket (must be empty)
>> - %dd
>> %dt Create a new blob
>> %dd
>> =link_to 'Create Blob', bucket_url(@bucket.name) + '/new_blob'
>> - =link_to_action 'Delete', destroy_bucket_url(@bucket.name), :delete
>> + %dt Delete bucket (must be empty)
>> + %dd
>> + -if @bucket.size == 0
>> + =link_to_action 'Delete', destroy_bucket_url(@bucket.name), :delete
>> \ No newline at end of file
>> --
>> 1.7.2.3
>>
>


Mime
View raw message