incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1147018 - in /incubator/deltacloud/trunk/server: lib/deltacloud/drivers/ec2/ec2_driver.rb lib/deltacloud/drivers/vsphere/vsphere_driver.rb server.rb views/images/show.html.haml
Date Fri, 15 Jul 2011 08:36:53 GMT
Author: mfojtik
Date: Fri Jul 15 08:36:52 2011
New Revision: 1147018

URL: http://svn.apache.org/viewvc?rev=1147018&view=rev
Log:
Added destroy method for image for VSphere and EC2

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
    incubator/deltacloud/trunk/server/server.rb
    incubator/deltacloud/trunk/server/views/images/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=1147018&r1=1147017&r2=1147018&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 Jul 15
08:36:52 2011
@@ -169,6 +169,15 @@ module Deltacloud
           end
         end
 
+        def destroy_image(credentials, image_id)
+          ec2 = new_client(credentials)
+          safely do
+            unless ec2.deregister_image(image_id)
+              raise "ERROR: Unable to deregister AMI"
+            end
+          end
+        end
+
         def instances(credentials, opts={})
           ec2 = new_client(credentials)
           inst_arr = []

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb?rev=1147018&r1=1147017&r2=1147018&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb Fri
Jul 15 08:36:52 2011
@@ -256,10 +256,12 @@ module Deltacloud::Drivers::VSphere
 
     # Destroy an instance, given its id. Note that this will destory all
     # instance data.
-    def destroy_instance(credentials, id)
-      find_vm(credentials, id)[:instance].Destroy_Task.wait_for_completion
+    def destroy_instance(credentials, instance_id)
+      find_vm(credentials, instance_id)[:instance].Destroy_Task.wait_for_completion
     end
 
+    alias :destroy_image :destroy_instance
+
     exceptions do
 
       on /InvalidLogin/ do

Modified: incubator/deltacloud/trunk/server/server.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/server.rb?rev=1147018&r1=1147017&r2=1147018&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/server.rb (original)
+++ incubator/deltacloud/trunk/server/server.rb Fri Jul 15 08:36:52 2011
@@ -214,6 +214,20 @@ END
     end
   end
 
+  operation :destroy do
+    description "Remove specified image from collection"
+    with_capability :destroy_image
+    param :id,    :string,    :required
+    control do
+      driver.destroy_image(credentials, params[:id])
+      respond_to do |format|
+        format.xml { status 204 }
+        format.json { status 204 }
+        format.html { redirect(images_url) }
+      end
+    end
+  end
+
 end
 
 collection :instance_states do

Modified: incubator/deltacloud/trunk/server/views/images/show.html.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/images/show.html.haml?rev=1147018&r1=1147017&r2=1147018&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/images/show.html.haml (original)
+++ incubator/deltacloud/trunk/server/views/images/show.html.haml Fri Jul 15 08:36:52 2011
@@ -19,3 +19,4 @@
     %dt
     %dd
       = link_to 'Launch', api_url_for("instances/new?image_id=#{@image.id}")
+      = link_to_action 'Destroy', destroy_image_url(@image.id), :delete



Mime
View raw message