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 Thu, 10 Jan 2013 20:08:52 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..22d20ac 100644
--- a/server/lib/cimi/helpers/database_helper.rb
+++ b/server/lib/cimi/helpers/database_helper.rb
@@ -6,10 +6,18 @@ module Deltacloud
     module Database
       include Deltacloud::Helpers::Drivers
 
+      DATABASE_COLLECTIONS = [ "machine_template", "address_template",
+        "volume_configuration", "volume_template" ]
+
       def test_environment?
         Deltacloud.test_environment?
       end
 
+     def provides?(entity)
+       return true if DATABASE_COLLECTIONS.include? entity
+       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 1836449..0f2a89e 100644
--- a/server/lib/cimi/models/collection.rb
+++ b/server/lib/cimi/models/collection.rb
@@ -122,7 +122,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)) ||
+             provides?(cimi_entity)
           url = context.send(cimi_create)
           ops << { :rel => "add", :href => url }
         end
-- 
1.7.11.7


Mime
View raw message