From: Dies Koper <di...@fast.au.fujitsu.com>
---
.../drivers/mock/data/cimi/system/system1.json | 2 --
.../drivers/mock/data/cimi/system/system2.json | 2 --
.../drivers/mock/mock_driver_cimi_methods.rb | 28 ++++++++++------------
3 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/system/system1.json
b/server/lib/deltacloud/drivers/mock/data/cimi/system/system1.json
index a73bb5f..f921632 100644
--- a/server/lib/deltacloud/drivers/mock/data/cimi/system/system1.json
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/system/system1.json
@@ -3,8 +3,6 @@
"description": "the first system",
"created": "Fri Feb 08 15:25:41 EET 2013",
"state": "STOPPED",
- "machines": { "href": "http://cimi.example.org/systems/system1/machines"},
- "networks": { "href": "http://cimi.example.org/systems/system1/networks"},
"operations": [
{ "rel": "http://schemas.dmtf.org/cimi/1/action/start", "href":
"http://cimi.example.org/systems/system1/start" },
{ "rel": "edit", "href": "http://cimi.example.org/systems/system1" },
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/system/system2.json
b/server/lib/deltacloud/drivers/mock/data/cimi/system/system2.json
index 5a62e73..208feca 100644
--- a/server/lib/deltacloud/drivers/mock/data/cimi/system/system2.json
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/system/system2.json
@@ -3,8 +3,6 @@
"description": "the second system",
"created": "Fri Feb 08 15:25:41 EET 2013",
"state": "STOPPED",
- "machines": { "href": "http://cimi.example.org/systems/system2/machines"},
- "networks": { "href": "http://cimi.example.org/systems/system2/networks"},
"operations": [
{ "rel": "http://schemas.dmtf.org/cimi/1/action/start", "href":
"http://cimi.example.org/systems/system1/start" },
{ "rel": "edit", "href": "http://cimi.example.org/systems/system2" },
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 b0d4f9a..4ac01aa 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
@@ -44,7 +44,8 @@ module Deltacloud::Drivers::Mock
"created" => Time.now,
"state" => "STOPPED",
"systemTemplate"=> { "href" => opts[:system_template].id },
- "operations" => [{"rel"=>"edit", "href"=> id},
+ "operations" => [{"rel"=>"http://schemas.dmtf.org/cimi/1/action/start",
"href"=> "#{id}/start"},
+ {"rel"=>"edit", "href"=> id},
{"rel"=>"delete", "href"=> id}] }
system = CIMI::Model::System.from_json(JSON.generate(sys_hsh))
@@ -78,9 +79,7 @@ module Deltacloud::Drivers::Mock
return []
end
end
- #FIXME: with ":machines", delete url becomes
'http://localhost:3001/cimi/machines?id=sysmach1'
- #with ":system_machine"/":system_machines", undefined method
`system_machine_url' for #<CIMI::Collections::Systems:0x44fe338> in mock_driver_cimi_methods.rb:261
- machines.map{|mach|convert_cimi_mock_urls(:machines, mach,
opts[:env])}.flatten
+ machines.map{|m|convert_urls(m, opts[:env])}.flatten
end
def system_volumes(credentials, opts={})
@@ -94,9 +93,7 @@ module Deltacloud::Drivers::Mock
return []
end
end
- #FIXME: with ":volumes", delete url becomes
'http://localhost:3001/cimi/volumes?id=sysvol1'
- #with ":system_volume"/":system_volumes", undefined method `system_volume_url'
for #<CIMI::Collections::Systems:0x44fe338> in mock_driver_cimi_methods.rb:261
- volumes.map{|vol|convert_cimi_mock_urls(:volumes, vol,
opts[:env])}.flatten
+ volumes.map{|vol|convert_urls(vol, opts[:env])}.flatten
end
def system_networks(credentials, opts={})
@@ -110,8 +107,7 @@ module Deltacloud::Drivers::Mock
return []
end
end
- #FIXME
- networks.map{|vol|convert_cimi_mock_urls(:networks, vol,
opts[:env])}.flatten
+ networks.map{|n|convert_urls(n, opts[:env])}.flatten
end
def system_addresses(credentials, opts={})
@@ -125,8 +121,7 @@ module Deltacloud::Drivers::Mock
return []
end
end
- #FIXME
- addresses.map{|a|convert_cimi_mock_urls(:addresses, a,
opts[:env])}.flatten
+ addresses.map{|a|convert_urls(a, opts[:env])}.flatten
end
def system_forwarding_groups(credentials, opts={})
@@ -140,8 +135,7 @@ module Deltacloud::Drivers::Mock
return []
end
end
- #FIXME
- groups.map{|group|convert_cimi_mock_urls(:forwarding_groups, group,
opts[:env])}.flatten
+ groups.map{|g|convert_urls(g, opts[:env])}.flatten
end
def system_templates(credentials, opts={})
@@ -337,10 +331,12 @@ module Deltacloud::Drivers::Mock
return s
end
return s unless u.scheme == 'http' && u.host == 'cimi.example.org'
- _, coll, id = u.path.split("/")
- method = "#{coll.singularize}_url"
+ _, coll, id, sub_coll, sub_id = u.path.split("/")
+ method = sub_coll ? "#{coll.singularize}_#{sub_coll.singularize}_url"
+ : "#{coll.singularize}_url"
if context.respond_to?(method)
- context.send(method, id)
+ sub_coll ? context.send(method, :id => id, :ent_id => sub_id)