deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [5/11] git commit: CIMI: Adds CIMI::Network create for Deltacloud mock driver
Date Wed, 11 Apr 2012 15:33:08 GMT
CIMI: Adds CIMI::Network create for Deltacloud mock driver


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/769051e0
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/769051e0
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/769051e0

Branch: refs/heads/master
Commit: 769051e0e3fef06e443c7b2ed36275e2de244853
Parents: f4ea118
Author: marios <marios@redhat.com>
Authored: Fri Mar 30 13:43:56 2012 +0300
Committer: marios <marios@redhat.com>
Committed: Wed Apr 11 18:32:07 2012 +0300

----------------------------------------------------------------------
 server/lib/deltacloud/drivers/mock/mock_client.rb  |    5 +++
 .../drivers/mock/mock_driver_cimi_methods.rb       |   21 +++++++++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/769051e0/server/lib/deltacloud/drivers/mock/mock_client.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/mock_client.rb b/server/lib/deltacloud/drivers/mock/mock_client.rb
index 248cc49..b27b84d 100644
--- a/server/lib/deltacloud/drivers/mock/mock_client.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_client.rb
@@ -91,6 +91,11 @@ module Deltacloud::Drivers::Mock
       FileUtils.rm(fname) if File::exists?(fname)
     end
 
+    def store_cimi(collection, obj)
+      raise "Why no obj[\"name\"] ?" unless obj["name"]
+      File::open(cimi_file(collection, obj["name"]), "w") { |f| f.write(JSON.generate(obj))
}
+    end
+
     def load_all_cimi(model_name)
         model_files = Dir[File::join(cimi_dir(model_name), "*.json")]
         model_files.map{|f| File.read(f)}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/769051e0/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
----------------------------------------------------------------------
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 bebc45c..1330d84 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
@@ -32,6 +32,27 @@ module Deltacloud::Drivers::Mock
       end
     end
 
+    def create_network(credentials, opts={})
+      check_credentials(credentials)
+      id = "#{opts[:env].send("networks_url")}/#{opts[:name]}"
+      network = { "id"=> id,
+                  "name" => opts[:name],
+                  "description" => opts[:description],
+                  "created" => Time.now,
+                  "state" => "STARTED",
+                  "access" => opts[:network_config].access,
+                  "bandwithLimit" => opts[:network_config].bandwidth_limit,
+                  "trafficPriority" => opts[:network_config].traffic_priority,
+                  "maxTrafficDelay" => opts[:network_config].max_traffic_delay,
+                  "maxTrafficLoss" =>opts[:network_config].max_traffic_loss,
+                  "maxTrafficJitter" =>opts[:network_config].max_traffic_jitter,
+                  "routingGroup"=> { "href" => opts[:routing_group].id },
+                  "operations" => [{"rel"=>"edit", "href"=> id},
+                                   {"rel"=>"delete", "href"=> id}]    }
+      @client.store_cimi(:network, network)
+      CIMI::Model::Network.from_json(@client.load_cimi(:network, opts[:name]))
+    end
+
     def network_configurations(credentials, opts={})
       check_credentials(credentials)
       if opts[:id].nil?


Mime
View raw message