deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 5/8] CIMI: Added delete operation for MachineAdmin
Date Wed, 07 Dec 2011 15:26:49 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/lib/cimi/model/machine_admin.rb |    4 ++++
 server/lib/cimi/server.rb              |   15 ++++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/server/lib/cimi/model/machine_admin.rb b/server/lib/cimi/model/machine_admin.rb
index b3f2f86..e3f92ee 100644
--- a/server/lib/cimi/model/machine_admin.rb
+++ b/server/lib/cimi/model/machine_admin.rb
@@ -39,6 +39,10 @@ class CIMI::Model::MachineAdmin < CIMI::Model::Base
     from_key(key, context)
   end
 
+  def self.delete!(id, context)
+    context.driver.destroy_key(context.credentials, :id => id)
+  end
+
   private
 
   def self.from_key(key, context)
diff --git a/server/lib/cimi/server.rb b/server/lib/cimi/server.rb
index 757ceb5..746587c 100644
--- a/server/lib/cimi/server.rb
+++ b/server/lib/cimi/server.rb
@@ -155,10 +155,10 @@ global_collection :machine_admins do
     description "List all machine admins"
     with_capability :keys
     control do
-      machine_admins = MachineAdmin.all(self)
+      machine_admins = MachineAdminCollection.default(self)
       respond_to do |format|
-        format.xml { machine_admins.to_xml_cimi_collection(self) }
-        format.json { machine_admins.to_json_cimi_collection(self) }
+        format.xml { machine_admins.to_xml }
+        format.json { machine_admins.to_json }
       end
     end
   end
@@ -193,6 +193,15 @@ global_collection :machine_admins do
     end
   end
 
+  operation :delete, :method => :delete, :member => true do
+    description "Delete specified MachineAdmin entity"
+    param :id,          :string,    :required
+    control do
+      MachineAdmin.delete!(params[:id], self)
+      no_content_with_status(200)
+    end
+  end
+
 end
 
 global_collection :machines do
-- 
1.7.4.4


Mime
View raw message