deltacloud-dev mailing list archives

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


Signed-off-by: marios <marios@redhat.com>
---
 .../drivers/mock/data/cimi/vsp/vsp1.json           |   16 ++++++++++++++++
 .../drivers/mock/data/cimi/vsp/vsp2.json           |   16 ++++++++++++++++
 .../drivers/mock/data/cimi/vsp/vsp3.json           |   18 ++++++++++++++++++
 .../drivers/mock/data/cimi/vsp/vsp4.json           |   18 ++++++++++++++++++
 .../drivers/mock/mock_driver_cimi_methods.rb       |   11 +++++++++++
 5 files changed, 79 insertions(+), 0 deletions(-)
 create mode 100644 server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp1.json
 create mode 100644 server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp2.json
 create mode 100644 server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp3.json
 create mode 100644 server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp4.json

diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp1.json b/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp1.json
new file mode 100644
index 0000000..191ed4e
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp1.json
@@ -0,0 +1,16 @@
+{ "id": "http://cimi.example.org/vsps/vsp1",
+  "name": "vsp1",
+  "description": "a mock switchport",
+  "created": "Fri Mar 16 17:06:41 EET 2012",
+  "state": "STARTED",
+  "network": {"href": "http://cimi.example.org/networks/network1"},
+  "bandwidthReservation": 0.5,
+  "trafficPriority": 1,
+  "maxTrafficDelay": 500000,
+  "maxTrafficLoss": 100,
+  "maxTrafficJitter": 100000,
+  "operations": [
+    { "rel": "edit", "href": "http://cimi.example.org/vsps/vsp1" },
+    { "rel": "delete", "href": "http://cimi.example.org/vsps/vsp1" }
+  ]
+}
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp2.json b/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp2.json
new file mode 100644
index 0000000..4173f0c
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp2.json
@@ -0,0 +1,16 @@
+{ "id": "http://cimi.example.org/vsps/vsp2",
+  "name": "vsp2",
+  "description": "a mock switchport",
+  "created": "Fri Mar 16 17:09:27 EET 2012",
+  "state": "STARTED",
+  "network": {"href": "http://cimi.example.org/networks/network1"},
+  "bandwidthReservation": 0.5,
+  "trafficPriority": 1,
+  "maxTrafficDelay": 500000,
+  "maxTrafficLoss": 100,
+  "maxTrafficJitter": 100000,
+  "operations": [
+    { "rel": "edit", "href": "http://cimi.example.org/vsps/vsp2" },
+    { "rel": "delete", "href": "http://cimi.example.org/vsps/vsp2" }
+  ]
+}
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp3.json b/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp3.json
new file mode 100644
index 0000000..b7f9cf5
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp3.json
@@ -0,0 +1,18 @@
+{ "id": "http://cimi.example.org/vsps/vsp3",
+  "name": "vsp3",
+  "description": "a mock switchport",
+  "created": "Fri Mar 16 17:10:36 EET 2012",
+  "state": "STARTED",
+  "network": {"href": "http://cimi.example.org/networks/network2"},
+  "bandwidthReservation": 1,
+  "trafficPriority": 1,
+  "maxTrafficDelay": 500000,
+  "maxTrafficLoss": 100,
+  "maxTrafficJitter": 100000,
+  "operations": [
+    { "rel": "edit", "href": "http://cimi.example.org/vsps/vsp3" },
+    { "rel": "delete", "href": "http://cimi.example.org/vsps/vsp3" }
+  ]
+}
+
+
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp4.json b/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp4.json
new file mode 100644
index 0000000..33fcbf8
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp4.json
@@ -0,0 +1,18 @@
+{ "id": "http://cimi.example.org/vsps/vsp4",
+  "name": "vsp4",
+  "description": "a mock switchport",
+  "created": "Fri Mar 16 17:10:36 EET 2012",
+  "state": "STARTED",
+  "network": {"href": "http://cimi.example.org/networks/network2"},
+  "bandwidthReservation": 1,
+  "trafficPriority": 1,
+  "maxTrafficDelay": 500000,
+  "maxTrafficLoss": 100,
+  "maxTrafficJitter": 100000,
+  "operations": [
+    { "rel": "edit", "href": "http://cimi.example.org/vsps/vsp4" },
+    { "rel": "delete", "href": "http://cimi.example.org/vsps/vsp4" }
+  ]
+}
+
+
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 c61e414..7d580ea 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
@@ -76,6 +76,17 @@ module Deltacloud::Drivers::Mock
       end
     end
 
+    def vsps(credentials, opts={})
+      check_credentials(credentials)
+      if opts[:id].nil?
+        vsps = @client.load_all_cimi(:vsp).map{|vsp| CIMI::Model::VSP.from_json(vsp)}
+        vsps.map{|vsp|convert_cimi_mock_urls(:vsp, vsp, opts[:env])}.flatten
+      else
+        vsp = CIMI::Model::VSP.from_json(@client.load_cimi(:vsp, opts[:id]))
+        convert_cimi_mock_urls(:vsp, vsp, opts[:env])
+      end
+    end
+
     private
 
     def convert_cimi_mock_urls(model_name, cimi_object, context)
-- 
1.7.6.5


Mime
View raw message