deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@redhat.com
Subject [PATCH 2/9] CIMI: adds RoutingGroupTemplate methods and mocking data to deltacloud mock driver
Date Fri, 16 Mar 2012 17:34:59 GMT
From: marios <marios@redhat.com>


Signed-off-by: marios <marios@redhat.com>
---
 .../cimi/routing_group_template/template1.json     |   12 ++++++++++++
 .../drivers/mock/mock_driver_cimi_methods.rb       |   11 +++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)
 create mode 100644 server/lib/deltacloud/drivers/mock/data/cimi/routing_group_template/template1.json

diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/routing_group_template/template1.json
b/server/lib/deltacloud/drivers/mock/data/cimi/routing_group_template/template1.json
new file mode 100644
index 0000000..adbe645
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/routing_group_template/template1.json
@@ -0,0 +1,12 @@
+{ "id": "http://cimi.example.org/routing_group_templates/template1",
+  "name": "template1",
+  "description": "A mock routing group template",
+  "created": "Fri Mar 16 16:42:50 EET 2012",
+  "networks": [
+    { "href": "http://cimi.example.org/networks/network1"},
+    { "href": "http://cimi.example.org/networks/network2"}
+  ],
+  "operations": [
+    { "rel": "edit", "href": "http://cimi.example.org/routing_group_templates/template1"
},
+    { "rel": "delete", "href": "http://cimi.example.org/routing_group_templates/template1"
}]
+}
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 1e7b3c2..c61e414 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
@@ -65,6 +65,17 @@ module Deltacloud::Drivers::Mock
       end
     end
 
+    def routing_group_templates(credentials, opts={})
+      check_credentials(credentials)
+      if opts[:id].nil?
+        routing_group_templates = @client.load_all_cimi(:routing_group_template).map{|rg_templ|
CIMI::Model::RoutingGroupTemplate.from_json(rg_templ)}
+        routing_group_templates.map{|rg_templ|convert_cimi_mock_urls(:routing_group_template,
rg_templ, opts[:env])}.flatten
+      else
+        routing_group_template = CIMI::Model::RoutingGroupTemplate.from_json(@client.load_cimi(:routing_group_template,
opts[:id]))
+        convert_cimi_mock_urls(:routing_group_template, routing_group_template, opts[:env])
+      end
+    end
+
     private
 
     def convert_cimi_mock_urls(model_name, cimi_object, context)
-- 
1.7.6.5


Mime
View raw message