You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by ma...@apache.org on 2012/12/18 10:28:09 UTC

[1/2] git commit: CIMI - dont expose 'add' URI for collection if not supported DTACLOUD-400

Updated Branches:
  refs/heads/master e988cf85d -> 92556ea21


CIMI - dont expose 'add' URI for collection if not supported DTACLOUD-400

https://issues.apache.org/jira/browse/DTACLOUD-400


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

Branch: refs/heads/master
Commit: 27225180f05e8d7662cee5e442922dbd51603933
Parents: e988cf8
Author: marios <ma...@redhat.com>
Authored: Fri Dec 14 13:52:51 2012 +0200
Committer: marios <ma...@redhat.com>
Committed: Tue Dec 18 11:11:43 2012 +0200

----------------------------------------------------------------------
 server/lib/cimi/helpers/cimi_helper.rb |   12 ++++++++++++
 server/lib/cimi/models/collection.rb   |    8 +++++---
 2 files changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/27225180/server/lib/cimi/helpers/cimi_helper.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/helpers/cimi_helper.rb b/server/lib/cimi/helpers/cimi_helper.rb
index 8fad786..b062af7 100644
--- a/server/lib/cimi/helpers/cimi_helper.rb
+++ b/server/lib/cimi/helpers/cimi_helper.rb
@@ -92,6 +92,18 @@ module CIMI
       type = (xml)? :xml : :json
     end
 
+    def deltacloud_create_method_for(cimi_entity)
+      case cimi_entity
+        when "machine"                then "create_instance"
+        when "machine_configuration"  then "create_hardware_profile"
+        when "machine_image"          then "create_image"
+        when "volume"                 then "create_storage_volume"
+        when "volume_image"           then "create_storage_snapshot"
+        else "create_#{cimi_entity}"
+      end
+
+    end
+
   end
 end
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/27225180/server/lib/cimi/models/collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/collection.rb b/server/lib/cimi/models/collection.rb
index c7f3b21..0fc5eec 100644
--- a/server/lib/cimi/models/collection.rb
+++ b/server/lib/cimi/models/collection.rb
@@ -118,9 +118,11 @@ module CIMI::Model
         desc = "#{self.name.split("::").last} Collection for the #{context.driver.name.capitalize} driver"
         id = context.send("#{collection_class.entry_name}_url")
         ops = []
-        create = "create_#{collection_class.entry_name.to_s.singularize}_url"
-        if context.respond_to?(create)
-          url = context.send(create)
+        cimi_entity = collection_class.entry_name.to_s.singularize
+        cimi_create = "create_#{cimi_entity}_url"
+        dcloud_create = context.deltacloud_create_method_for(cimi_entity)
+        if context.respond_to?(cimi_create) && context.driver.respond_to?(dcloud_create)
+          url = context.send(cimi_create)
           ops << { :rel => "add", :href => url }
         end
         collection_class.new(:id => id, :name => 'default',