deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [2/9] git commit: CIMI: Adds VSPTemplate methods and mocking data for deltacloud mock driver
Date Tue, 20 Mar 2012 10:10:19 GMT
CIMI: Adds VSPTemplate methods and mocking data 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/9ddd4b5e
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/9ddd4b5e
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/9ddd4b5e

Branch: refs/heads/master
Commit: 9ddd4b5eb363682c685f1e006de8b052532186b6
Parents: 7ba2815
Author: marios <marios@redhat.com>
Authored: Fri Mar 16 19:30:41 2012 +0200
Committer: marios <marios@redhat.com>
Committed: Tue Mar 20 12:09:08 2012 +0200

----------------------------------------------------------------------
 .../mock/data/cimi/vsp_template/template1.json     |   10 ++++++++++
 .../mock/data/cimi/vsp_template/template2.json     |   10 ++++++++++
 .../drivers/mock/mock_driver_cimi_methods.rb       |   11 +++++++++++
 3 files changed, 31 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/9ddd4b5e/server/lib/deltacloud/drivers/mock/data/cimi/vsp_template/template1.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/vsp_template/template1.json b/server/lib/deltacloud/drivers/mock/data/cimi/vsp_template/template1.json
new file mode 100644
index 0000000..5df8fdd
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/vsp_template/template1.json
@@ -0,0 +1,10 @@
+{ "id": "http://cimi.example.org/vsp_templates/template1",
+  "name": "template1",
+  "description": "A mock VSP template",
+  "created": "Fri Mar 16 19:26:41 EET 2012",
+  "network": { "href": "http://cimi.example.org/networks/network1"},
+  "vspConfig": { "href": "http://cimi.example.org/vsp_configs/vspconfig1"},
+  "operations": [
+    { "rel": "edit", "href": "http://cimi.example.org/vsp_templates/template1" },
+    { "rel": "delete", "href": "http://cimi.example.org/vsp_templates/template1" }]
+}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/9ddd4b5e/server/lib/deltacloud/drivers/mock/data/cimi/vsp_template/template2.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/vsp_template/template2.json b/server/lib/deltacloud/drivers/mock/data/cimi/vsp_template/template2.json
new file mode 100644
index 0000000..cc17c1b
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/vsp_template/template2.json
@@ -0,0 +1,10 @@
+{ "id": "http://cimi.example.org/vsp_templates/template2",
+  "name": "template2",
+  "description": "A mock VSP template",
+  "created": "Fri Mar 16 19:26:41 EET 2012",
+  "network": { "href": "http://cimi.example.org/networks/network2"},
+  "vspConfig": { "href": "http://cimi.example.org/vsp_configs/vspconfig2"},
+  "operations": [
+    { "rel": "edit", "href": "http://cimi.example.org/vsp_templates/template2" },
+    { "rel": "delete", "href": "http://cimi.example.org/vsp_templates/template2" }]
+}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/9ddd4b5e/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 8718276..bebc45c 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
@@ -98,6 +98,17 @@ module Deltacloud::Drivers::Mock
       end
     end
 
+    def vsp_templates(credentials, opts={})
+      check_credentials(credentials)
+      if opts[:id].nil?
+        vsp_templates = @client.load_all_cimi(:vsp_template).map{|vsp_templ| CIMI::Model::VSPTemplate.from_json(vsp_templ)}
+        vsp_templates.map{|vsp_templ|convert_cimi_mock_urls(:vsp_template, vsp_templ, opts[:env])}.flatten
+      else
+        vsp_template = CIMI::Model::VSPTemplate.from_json(@client.load_cimi(:vsp_template,
opts[:id]))
+        convert_cimi_mock_urls(:vsp_template, vsp_template, opts[:env])
+      end
+    end
+
     private
 
     def convert_cimi_mock_urls(model_name, cimi_object, context)


Mime
View raw message