deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvl...@redhat.com
Subject [PATCH] DTACLOUD-402 Add operations for pseudo collections
Date Fri, 04 Jan 2013 20:01:51 GMT
From: Joe VLcek <jvlcek@redhat.com>

---
 server/lib/cimi/helpers/database_helper.rb | 8 ++++++++
 server/lib/cimi/models/collection.rb       | 4 +++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/server/lib/cimi/helpers/database_helper.rb b/server/lib/cimi/helpers/database_helper.rb
index b581c7b..9c203aa 100644
--- a/server/lib/cimi/helpers/database_helper.rb
+++ b/server/lib/cimi/helpers/database_helper.rb
@@ -10,6 +10,14 @@ module Deltacloud
         Deltacloud.test_environment?
       end
 
+     def pseudo_collection?(model)
+       # Could add all pseudo collections here
+       # Or better seed the db with templates for supported
+       # pseudo collections and match against the DB here.
+       return true if model == "create_machine_template"
+       return false
+     end
+
       def load_attributes_for(model)
         return {} if test_environment?
         entity = get_entity(model)
diff --git a/server/lib/cimi/models/collection.rb b/server/lib/cimi/models/collection.rb
index 0587264..4b422d1 100644
--- a/server/lib/cimi/models/collection.rb
+++ b/server/lib/cimi/models/collection.rb
@@ -121,7 +121,9 @@ module CIMI::Model
         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)
+        if(context.respond_to?(cimi_create) && 
+           context.driver.respond_to?(dcloud_create)) ||
+             pseudo_collection?(dcloud_create)
           url = context.send(cimi_create)
           ops << { :rel => "add", :href => url }
         end
-- 
1.7.11.7


Mime
View raw message