Hey everyone,

The current Core and Aggregator versions are not working with each
other. I started looking at it, but couldn't finish it today. Since I
won't get to it before Wednesday July 7, here's what I found in case
anybody wants to pick it up.

If not, I'll resume working on it on Wednesday.

1, The most recent deltacloud-core and deltacloud-client gems on
rubygems.org don't work together.

Core serves the hardware profiles XML nodes as <hardware-profile> while
the client library expects "hardware_profile".

2, This is fixed in the most HEAD of the core repo -- the client works
with the core correctly.

However, some things in the client library API changed and that breaks
Aggregator.

The attached patch fixes some of the problems.

Secondly, the core client adds a method `singularize` to the String
class which conflicts with the singularization that Rails uses for its
mapping of classes and tables.

I suggest that the `singularize` method in the core library be renamed
to something else because it can't be used in Rails applications now.

Again, a simple patch included (though you may want to do it
differently).

After you apply both patches (one on core, the other on aggregator), you
need to uninstall the old delcatloud* gems and build the new ones from
the sources.

It still doesn't work, but at least it's closer to being compatible.

Thomas
>From 6d7e3ddd912f6086f85a02e8a4cd8ce1b689206b Mon Sep 17 00:00:00 2001
From: Tomas Sedovic <[email protected]>
Date: Thu, 1 Jul 2010 18:50:12 +0200
Subject: [PATCH aggregator] Update for the changes in the deltacloud-client library.

---
 src/app/models/hardware_profile.rb          |    6 +++---
 src/app/models/hardware_profile_property.rb |    4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/app/models/hardware_profile.rb b/src/app/models/hardware_profile.rb
index a92b658..de9ef23 100644
--- a/src/app/models/hardware_profile.rb
+++ b/src/app/models/hardware_profile.rb
@@ -90,10 +90,10 @@ class HardwareProfile < ActiveRecord::Base
                                                :value => prop.value)
     case prop.kind
     when HardwareProfileProperty::RANGE
-      the_property.range_first = prop.range.first
-      the_property.range_last = prop.range.last
+      the_property.range_first = prop.range[:from]
+      the_property.range_last = prop.range[:to]
     when HardwareProfileProperty::ENUM
-      the_property.property_enum_entries = prop.enum.entries.collect do |entry|
+      the_property.property_enum_entries = prop.options.collect do |entry|
         PropertyEnumEntry.new(:value => entry, :hardware_profile_property => the_property)
       end
     end
diff --git a/src/app/models/hardware_profile_property.rb b/src/app/models/hardware_profile_property.rb
index aedae31..ef519e7 100644
--- a/src/app/models/hardware_profile_property.rb
+++ b/src/app/models/hardware_profile_property.rb
@@ -27,8 +27,8 @@ class HardwareProfileProperty < ActiveRecord::Base
   ARCHITECTURE = "architecture"
 
   FIXED = "fixed"
-  RANGE = "range"
-  ENUM  = "enum"
+  RANGE = :range
+  ENUM  = :enum
 
   UNIT_MB = "MB"
   UNIT_GB = "GB"
-- 
1.6.6.1

>From a88be5388b5bc643c52dc75056721c42cc8856cf Mon Sep 17 00:00:00 2001
From: Tomas Sedovic <[email protected]>
Date: Thu, 1 Jul 2010 18:54:08 +0200
Subject: [PATCH] Rename the singularize method.

---
 client/lib/deltacloud.rb |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb
index 19b6093..cce32db 100644
--- a/client/lib/deltacloud.rb
+++ b/client/lib/deltacloud.rb
@@ -83,7 +83,7 @@ module DeltaCloud
             end
           end
           logger << "[API] Added method #{model}\n"
-          define_method :"#{model.to_s.singularize}" do |*args|
+          define_method :"#{model.to_s.dc_singularize}" do |*args|
             request(:get, "/#{model}/#{args[0]}") do |response|
               # Define a new class based on model name
               c = Kernel.define_class("#{model.to_s.classify}")
@@ -91,10 +91,10 @@ module DeltaCloud
               base_object(c, model, response)
             end
           end
-          logger << "[API] Added method #{model.to_s.singularize}\n"
-          define_method :"fetch_#{model.to_s.singularize}" do |url|
+          logger << "[API] Added method #{model.to_s.dc_singularize}\n"
+          define_method :"fetch_#{model.to_s.dc_singularize}" do |url|
             id = url.grep(/\/#{model}\/(.*)$/)
-            self.send(model.to_s.singularize.to_sym, $1)
+            self.send(model.to_s.dc_singularize.to_sym, $1)
           end
         end
       end
@@ -102,7 +102,7 @@ module DeltaCloud
 
     def base_object_collection(c, model, response)
       collection = []
-      Nokogiri::XML(response).xpath("#{model}/#{model.to_s.singularize}").each do |item|
+      Nokogiri::XML(response).xpath("#{model}/#{model.to_s.dc_singularize}").each do |item|
         c.instance_eval do
           attr_accessor :id
           attr_accessor :uri
@@ -115,7 +115,7 @@ module DeltaCloud
     # Add default attributes [id and href] to class
     def base_object(c, model, response)
       obj = nil
-      Nokogiri::XML(response).xpath("#{model.to_s.singularize}").each do |item|
+      Nokogiri::XML(response).xpath("#{model.to_s.dc_singularize}").each do |item|
         c.instance_eval do
           attr_accessor :id
           attr_accessor :uri
@@ -472,7 +472,7 @@ class String
 
   # Create a class name from string
   def classify
-    self.singularize.camelize
+    self.dc_singularize.camelize
   end
 
   # Camelize converts strings to UpperCamelCase
@@ -481,7 +481,7 @@ class String
   end
 
   # Strip 's' character from end of string
-  def singularize
+  def dc_singularize
     self.gsub(/s$/, '')
   end
 
-- 
1.6.6.1

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to