deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [3/4] git commit: CIMI - Adds mock data for network and network_configs for mock driver
Date Mon, 12 Mar 2012 11:13:44 GMT
CIMI - Adds mock data for network and network_configs for mock driver


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

Branch: refs/heads/master
Commit: 8db4de1d7c397344f04fe0a3b61735a3200b7248
Parents: 61ac9fe
Author: marios <marios@redhat.com>
Authored: Fri Mar 9 19:35:12 2012 +0200
Committer: marios <marios@redhat.com>
Committed: Fri Mar 9 19:40:31 2012 +0200

----------------------------------------------------------------------
 .../drivers/mock/data/cimi/network/network1.json   |    6 +++
 .../drivers/mock/data/cimi/network/network2.json   |    6 +++
 .../network_configuration/network_config1.json     |   15 +++++++++
 .../network_configuration/network_config2.json     |   15 +++++++++
 server/lib/deltacloud/drivers/mock/mock_driver.rb  |   25 ++++++++++----
 5 files changed, 60 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8db4de1d/server/lib/deltacloud/drivers/mock/data/cimi/network/network1.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/network/network1.json b/server/lib/deltacloud/drivers/mock/data/cimi/network/network1.json
index f3af747..165ef8a 100644
--- a/server/lib/deltacloud/drivers/mock/data/cimi/network/network1.json
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/network/network1.json
@@ -4,6 +4,12 @@
   "created": "Thu Jan 12 15:25:41 EET 2012",
   "state": "STARTED",
   "access": "Public",
+  "bandwidthLimit": 2,
+  "trafficPriority": 1,
+  "maxTrafficDelay": 500000,
+  "maxTrafficLoss": 100,
+  "maxTrafficJitter": 100000,
+  "routingGroup": { "href": "http://cimi.example.org/routinggroups/group1" },
   "operations": [
     { "rel": "edit", "href": "http://cimi.example.org/networks/network1" },
     { "rel": "delete", "href": "http://cimi.example.org/networks/network1" }

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8db4de1d/server/lib/deltacloud/drivers/mock/data/cimi/network/network2.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/network/network2.json b/server/lib/deltacloud/drivers/mock/data/cimi/network/network2.json
index f6c7faf..3bd264e 100644
--- a/server/lib/deltacloud/drivers/mock/data/cimi/network/network2.json
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/network/network2.json
@@ -4,6 +4,12 @@
   "created": "Fri Jan 13 17:30:34 EET 2012",
   "state": "STARTED",
   "access": "Public",
+  "bandwidthLimit": 3,
+  "trafficPriority": 2,
+  "maxTrafficDelay": 600000,
+  "maxTrafficLoss": 100,
+  "maxTrafficJitter": 200000,
+  "routingGroup": { "href": "http://cimi.example.org/routinggroups/group1" },
   "operations": [
     { "rel": "edit", "href": "http://cimi.example.org/networks/network2" },
     { "rel": "delete", "href": "http://cimi.example.org/networks/network2" }

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8db4de1d/server/lib/deltacloud/drivers/mock/data/cimi/network_configuration/network_config1.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/network_configuration/network_config1.json
b/server/lib/deltacloud/drivers/mock/data/cimi/network_configuration/network_config1.json
new file mode 100644
index 0000000..f767de9
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/network_configuration/network_config1.json
@@ -0,0 +1,15 @@
+{ "uri": "http://cimi.example.org/network_configurations/network_config1",
+  "name": "network_config1",
+  "description": "a network configuration",
+  "created": "Fri Mar 9 11:57:39 EET 2012",
+  "access": "Public",
+  "bandwidthLimit": 2,
+  "trafficPriority": 1,
+  "maxTrafficDelay": 500000,
+  "maxTrafficLoss": 100,
+  "maxTrafficJitter": 100000,
+  "operations": [
+    { "rel": "edit", "href": "http://cimi.example.org/network_configurations/network_config1"
},
+    { "rel": "delete", "href": "http://cimi.example.org/network_configurations/network_config1"
}
+  ]
+}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8db4de1d/server/lib/deltacloud/drivers/mock/data/cimi/network_configuration/network_config2.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/network_configuration/network_config2.json
b/server/lib/deltacloud/drivers/mock/data/cimi/network_configuration/network_config2.json
new file mode 100644
index 0000000..b22d837
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/network_configuration/network_config2.json
@@ -0,0 +1,15 @@
+{ "uri": "http://cimi.example.org/network_configurations/network_config2",
+  "name": "network_config2",
+  "description": "a network configuration",
+  "created": "Fri Mar 9 12:01:53 EET 2012",
+  "access": "Public",
+  "bandwidthLimit": 3,
+  "trafficPriority": 2,
+  "maxTrafficDelay": 600000,
+  "maxTrafficLoss": 100,
+  "maxTrafficJitter": 200000,
+  "operations": [
+    { "rel": "edit", "href": "http://cimi.example.org/network_configurations/network_config2"
},
+    { "rel": "delete", "href": "http://cimi.example.org/network_configurations/network_config2"
}
+  ]
+}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8db4de1d/server/lib/deltacloud/drivers/mock/mock_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/mock_driver.rb b/server/lib/deltacloud/drivers/mock/mock_driver.rb
index 765338d..e522926 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver.rb
@@ -455,10 +455,21 @@ module Deltacloud::Drivers::Mock
       check_credentials(credentials)
       if opts[:id].nil?
         networks = @client.load_all_cimi(:network).map{|net| CIMI::Model::Network.from_json(net)}
-        networks.map{|net|convert_cimi_network(net,opts[:env])}.flatten
+        networks.map{|net|convert_cimi_mock_urls(:network, net ,opts[:env])}.flatten
       else
         network = CIMI::Model::Network.from_json(@client.load_cimi(:network, opts[:id]))
-        convert_cimi_network(network, opts[:env])
+        convert_cimi_mock_urls(:network, network, opts[:env])
+      end
+    end
+
+    def network_configurations(credentials, opts={})
+      check_credentials(credentials)
+      if opts[:id].nil?
+        network_configs = @client.load_all_cimi(:network_configuration).map{|net_config|
CIMI::Model::NetworkConfiguration.from_json(net_config)}
+        network_configs.map{|net_config|convert_cimi_mock_urls(:network_configuration, net_config,
opts[:env])}.flatten
+      else
+        network_config = CIMI::Model::NetworkConfiguration.from_json(@client.load_cimi(:network_configuration,
opts[:id]))
+        convert_cimi_mock_urls(:network_configuration, network_config, opts[:env])
       end
     end
 
@@ -498,11 +509,11 @@ module Deltacloud::Drivers::Mock
       StorageVolume.new(volume)
     end
 
-    def convert_cimi_network(network, context)
-      uri=context.network_url(network.name)
-      network.uri=uri
-      network.operations.each{|op| op.href=uri}
-      network
+    def convert_cimi_mock_urls(model_name, cimi_object, context)
+      uri=context.send(:"#{model_name}_url", cimi_object.name)
+      cimi_object.uri=uri
+      cimi_object.operations.each{|op| op.href=uri}
+      cimi_object
     end
 
     exceptions do


Mime
View raw message