incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r1041917 - in /incubator/deltacloud/trunk/server: lib/deltacloud/drivers/ec2/ec2_driver.rb lib/deltacloud/drivers/rackspace/rackspace_driver.rb views/buckets/index.html.haml views/buckets/show.html.haml
Date Fri, 03 Dec 2010 17:18:10 GMT
Author: marios
Date: Fri Dec  3 17:18:09 2010
New Revision: 1041917

URL: http://svn.apache.org/viewvc?rev=1041917&view=rev
Log:
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)

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
    incubator/deltacloud/trunk/server/views/buckets/index.html.haml
    incubator/deltacloud/trunk/server/views/buckets/show.html.haml

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb?rev=1041917&r1=1041916&r2=1041917&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb Fri Dec  3
17:18:09 2010
@@ -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 => ''
               }

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb?rev=1041917&r1=1041916&r2=1041917&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
(original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
Fri Dec  3 17:18:09 2010
@@ -228,6 +228,33 @@ class RackspaceDriver < Deltacloud::Base
     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
 

Modified: incubator/deltacloud/trunk/server/views/buckets/index.html.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/buckets/index.html.haml?rev=1041917&r1=1041916&r2=1041917&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/buckets/index.html.haml (original)
+++ incubator/deltacloud/trunk/server/views/buckets/index.html.haml Fri Dec  3 17:18:09 2010
@@ -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

Modified: incubator/deltacloud/trunk/server/views/buckets/show.html.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/buckets/show.html.haml?rev=1041917&r1=1041916&r2=1041917&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/buckets/show.html.haml (original)
+++ incubator/deltacloud/trunk/server/views/buckets/show.html.haml Fri Dec  3 17:18:09 2010
@@ -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



Mime
View raw message