incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 5/5] RHEVM: Added destroy_image action
Date Tue, 02 Aug 2011 13:29:23 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 .../lib/deltacloud/drivers/rhevm/rhevm_client.rb   |   10 ++++++++++
 .../lib/deltacloud/drivers/rhevm/rhevm_driver.rb   |    9 +++++++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
index 04bd5b4..b4a2a80 100644
--- a/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
+++ b/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
@@ -96,6 +96,16 @@ module RHEVM
       RHEVM::Template::new(self, Nokogiri::XML(template).root)
     end
 
+    def destroy_template(id, headers={})
+      headers.merge!({
+        :content_type => 'application/xml',
+        :accept => 'application/xml',
+      })
+      headers.merge!(auth_header)
+      RHEVM::client(@api_entrypoint)["/templates/%s" % id].delete(headers)
+      return true
+    end
+
     def templates(opts={})
       headers = {
         :accept => "application/xml"
diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
index bf81683..1a8eaab 100644
--- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
+++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
@@ -116,6 +116,15 @@ class RHEVMDriver < Deltacloud::BaseDriver
     end
   end
 
+  def destroy_image(credentials, image_id)
+    client = new_client(credentials)
+    safely do
+      unless client.destroy_template(image_id)
+        raise "ERROR: Unable to remove image"
+      end
+    end
+  end
+
   def instances(credentials, opts={})
     client = new_client(credentials)
     inst_arr = []
-- 
1.7.4.1


Mime
View raw message