deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@redhat.com
Subject [PATCH 03/11] CIMI: Adds Network delete (+mock deltacloud mock driver method)
Date Fri, 06 Apr 2012 16:01:18 GMT
From: marios <marios@redhat.com>


Signed-off-by: marios <marios@redhat.com>
---
 server/lib/cimi/model/network.rb                   |    1 +
 server/lib/deltacloud/drivers/mock/mock_client.rb  |    5 +++++
 .../drivers/mock/mock_driver_cimi_methods.rb       |    5 +++++
 3 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/server/lib/cimi/model/network.rb b/server/lib/cimi/model/network.rb
index 5d95919..8ecc8a1 100644
--- a/server/lib/cimi/model/network.rb
+++ b/server/lib/cimi/model/network.rb
@@ -69,6 +69,7 @@ class CIMI::Model::Network < CIMI::Model::Base
   end
 
   def self.delete!(id, context)
+    context.driver.delete_network(context.credentials, id)
   end
 
 #FIXME
diff --git a/server/lib/deltacloud/drivers/mock/mock_client.rb b/server/lib/deltacloud/drivers/mock/mock_client.rb
index b27b84d..7d446db 100644
--- a/server/lib/deltacloud/drivers/mock/mock_client.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_client.rb
@@ -96,6 +96,11 @@ module Deltacloud::Drivers::Mock
       File::open(cimi_file(collection, obj["name"]), "w") { |f| f.write(JSON.generate(obj))
}
     end
 
+    def destroy_cimi(collection, id)
+      fname = cimi_file(collection, id)
+      FileUtils.rm(fname) if File::exists?(fname)
+    end
+
     def load_all_cimi(model_name)
         model_files = Dir[File::join(cimi_dir(model_name), "*.json")]
         model_files.map{|f| File.read(f)}
diff --git a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
index 1330d84..8ffaa23 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
@@ -53,6 +53,11 @@ module Deltacloud::Drivers::Mock
       CIMI::Model::Network.from_json(@client.load_cimi(:network, opts[:name]))
     end
 
+    def delete_network(credentials, id)
+      check_credentials(credentials)
+      @client.destroy_cimi(:network, id)
+    end
+
     def network_configurations(credentials, opts={})
       check_credentials(credentials)
       if opts[:id].nil?
-- 
1.7.6.5


Mime
View raw message