You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by dk...@apache.org on 2013/07/09 08:25:09 UTC

[3/9] git commit: CIMI: take entity collection url from CEP

CIMI: take entity collection url from CEP


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

Branch: refs/heads/master
Commit: df198d01b476602d647c49cbfba8e274054cd7da
Parents: 8249f4b
Author: Dies Koper <di...@fast.au.fujitsu.com>
Authored: Sun Jun 30 14:32:24 2013 +1000
Committer: Dies Koper <di...@fast.au.fujitsu.com>
Committed: Wed Jul 3 23:51:20 2013 +1000

----------------------------------------------------------------------
 clients/cimi/lib/client.rb | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/df198d01/clients/cimi/lib/client.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/lib/client.rb b/clients/cimi/lib/client.rb
index 7e56255..0418682 100644
--- a/clients/cimi/lib/client.rb
+++ b/clients/cimi/lib/client.rb
@@ -27,7 +27,20 @@ module CIMI
       end
 
       def get_entity_collection(entity_type, credentials)
-        client[entity_type].get(auth_header(credentials))
+        return client[entity_type].get(auth_header(credentials)) if entity_type == 'cloudEntryPoint'
+        entity_href = get_entity_collection_href(entity_type, credentials)
+        raise RestClient::ResourceNotFound if not entity_href
+        RestClient::Resource.new(entity_href).get(auth_header(credentials))
+      end
+
+      # look up entity collection url from cloud entry point
+      # returns nil if entity not in cloud entry point (i.e. not supported)
+      def get_entity_collection_href(entity_type, credentials)
+        entity_type.sub!('configurations', 'configs')
+        entity_type = entity_type.camelize.uncapitalize
+        entry_point_xml = client['cloudEntryPoint'].get(auth_header(credentials))
+        entity_el = XmlSimple.xml_in(entry_point_xml)[entity_type]
+        entity_href = entity_el ? entity_el[0]['href'] : nil
       end
 
       def create_entity(entity_type, body, credentials)