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 2013/04/22 18:35:14 UTC

[6/7] git commit: CIMI: CIMI Systems - fixes in collection/base classes to correctly set 'href' for system collections

CIMI: CIMI Systems - fixes in collection/base classes to correctly set 'href' for system collections

(otherwise to_xml explodes)


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

Branch: refs/heads/master
Commit: a749c43fdd10a6908d340b6dae646ff565911abc
Parents: ed68a68
Author: marios <ma...@redhat.com>
Authored: Mon Apr 22 19:33:15 2013 +0300
Committer: marios <ma...@redhat.com>
Committed: Mon Apr 22 19:33:15 2013 +0300

----------------------------------------------------------------------
 server/lib/cimi/models/collection.rb           |   10 ++++++++++
 server/lib/cimi/service/base.rb                |    3 +++
 server/lib/deltacloud/helpers/rabbit_helper.rb |    1 +
 3 files changed, 14 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a749c43f/server/lib/cimi/models/collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/collection.rb b/server/lib/cimi/models/collection.rb
index b06a1e9..b1dc264 100644
--- a/server/lib/cimi/models/collection.rb
+++ b/server/lib/cimi/models/collection.rb
@@ -122,6 +122,16 @@ module CIMI::Model
     # Return a collection of entities
     def list(id, entries, params = {})
       params[:id] = id
+      if params[:system]
+        entries.each do |sys|
+          entry_id = sys.model.id
+          sys.model.attribute_values.each do |k,v|
+            if v.is_a? CIMI::Model::Collection
+              v.href ||= "#{entry_id}/#{k.to_s}"
+            end
+          end
+        end
+      end
       params[:entries] = entries
       params[:count] = params[:entries].size
       if params[:add_url]

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a749c43f/server/lib/cimi/service/base.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/service/base.rb b/server/lib/cimi/service/base.rb
index b829e6a..612542d 100644
--- a/server/lib/cimi/service/base.rb
+++ b/server/lib/cimi/service/base.rb
@@ -124,6 +124,9 @@ module CIMI::Service
       params = {}
       params[:desc] = "#{self.name.split("::").last} Collection for the #{ctx.driver.name.capitalize} driver"
       params[:add_url] = create_url(ctx)
+      if model_class == CIMI::Model::System
+        params[:system] = id
+      end
       model_class.list(id, entries, params).select_by(ctx.params['$select']).filter_by(ctx.params['$filter'])
     end
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a749c43f/server/lib/deltacloud/helpers/rabbit_helper.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/helpers/rabbit_helper.rb b/server/lib/deltacloud/helpers/rabbit_helper.rb
index b249dc6..cdd0ae1 100644
--- a/server/lib/deltacloud/helpers/rabbit_helper.rb
+++ b/server/lib/deltacloud/helpers/rabbit_helper.rb
@@ -81,6 +81,7 @@ module Sinatra::Rabbit
           path = operation.full_path
         end
         path.slice!(root_url) if path.start_with?(root_url)
+        path.chop! if path.end_with?("/")
         url(path)
       end unless respond_to?(helper_method_name)
     end, helper_method_name]