On 08/07/10 06:24 -0400, Tomas Sedovic wrote:
>ACK
>
>Works with the latest Core.
>
>Note that when you set up a mock provider, add a mockuser/mockpassword cloud 
>account, and click on the Realms tab, you will see two realms with the name 
>"Europe" instead of one "Europe" and one "United States".
>
>However, that is an issue with the deltacloud-client library and Michal Fojtik 
>is already looking into it. You can push this patch.

Confirming this bug. Patch is on the way ;-)

-- Michal

>----- Original Message -----
>From: [email protected]
>To: [email protected]
>Sent: Wednesday, July 7, 2010 6:05:16 PM GMT +01:00 Amsterdam / Berlin / Bern 
>/ Rome / Stockholm / Vienna
>Subject: [deltacloud-devel] [PATCH aggregator] Core and Aggregator 
>compatibility
>
>From: Jan Provaznik <[email protected]>
>
>  * HardwareProfileProperty 'kind' chnaged to symbol
>  * allowed float format for CPU amount
>  * HardwareProfile.name is generated from API 'id' attribute
>  * added two simple CPU amount tests
>
>(this patch replaces aggregator_Update-for-client-changes.patch,
>core part of patch is already pushed in repository)
>---
> src/app/models/hardware_profile.rb              |    6 ++--
> src/app/models/hardware_profile_property.rb     |   21 ++++---------
> src/app/models/property_enum_entry.rb           |    8 ++---
> src/app/models/provider.rb                      |    4 +--
> src/spec/factories/hardware_profile_property.rb |   36 +++++++++++-----------
> src/spec/models/hardware_profile_spec.rb        |   14 +++++++++
> 6 files changed, 45 insertions(+), 44 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..0717484 100644
>--- a/src/app/models/hardware_profile_property.rb
>+++ b/src/app/models/hardware_profile_property.rb
>@@ -26,9 +26,9 @@ class HardwareProfileProperty < ActiveRecord::Base
>   CPU          = "cpu"
>   ARCHITECTURE = "architecture"
>
>-  FIXED = "fixed"
>-  RANGE = "range"
>-  ENUM  = "enum"
>+  FIXED = :fixed
>+  RANGE = :range
>+  ENUM  = :enum
>
>   UNIT_MB = "MB"
>   UNIT_GB = "GB"
>@@ -48,22 +48,14 @@ class HardwareProfileProperty < ActiveRecord::Base
>   validates_presence_of :unit
>   validates_presence_of :value
>   validates_numericality_of :value, :greater_than => 0,
>-                :if => Proc.new{|p| p.name == MEMORY or p.name == STORAGE }
>-  validates_numericality_of :value, :greater_than => 0,
>-                :if => Proc.new{|p| p.name == CPU }, :only_integer => true
>+                :if => Proc.new{|p| p.name == MEMORY or p.name == STORAGE or 
>p.name == CPU}
>
>   validates_numericality_of :range_first, :greater_than => 0,
>-                :if => Proc.new{|p| (p.name == MEMORY or p.name == STORAGE) 
>and
>+                :if => Proc.new{|p| (p.name == MEMORY or p.name == STORAGE or 
>p.name == CPU) and
>                                      p.kind == RANGE}
>   validates_numericality_of :range_last, :greater_than => 0,
>-                :if => Proc.new{|p| (p.name == MEMORY or p.name == STORAGE) 
>and
>+                :if => Proc.new{|p| (p.name == MEMORY or p.name == STORAGE or 
>p.name == CPU) and
>                                      p.kind == RANGE}
>-  validates_numericality_of :range_first, :greater_than => 0,
>-                :if => Proc.new{|p| (p.name == CPU) and
>-                                     p.kind == RANGE}, :only_integer => true
>-  validates_numericality_of :range_last, :greater_than => 0,
>-                :if => Proc.new{|p| (p.name == CPU) and
>-                                     p.kind == RANGE}, :only_integer => true
>   validates_associated :property_enum_entries
>   def validate
>     case name
>@@ -104,7 +96,6 @@ class HardwareProfileProperty < ActiveRecord::Base
>                    "Range ending must only be specified for range properties")
>       end
>     end
>-
>   end
> end
>
>diff --git a/src/app/models/property_enum_entry.rb 
>b/src/app/models/property_enum_entry.rb
>index eb246ff..ff497ef 100644
>--- a/src/app/models/property_enum_entry.rb
>+++ b/src/app/models/property_enum_entry.rb
>@@ -29,9 +29,7 @@ class PropertyEnumEntry < ActiveRecord::Base
>                 :if => Proc.new{|p| p.hardware_profile_property.name ==
>                                     HardwareProfileProperty::MEMORY or
>                                  p.hardware_profile_property.name ==
>-                                     HardwareProfileProperty::STORAGE }
>-  validates_numericality_of :value, :greater_than => 0, :only_integer => true,
>-                :if => Proc.new{|p| p.hardware_profile_property.name ==
>-                                     HardwareProfileProperty::CPU }
>-
>+                                     HardwareProfileProperty::STORAGE or
>+                                 p.hardware_profile_property.name ==
>+                                   HardwareProfileProperty::CPU }
> end
>diff --git a/src/app/models/provider.rb b/src/app/models/provider.rb
>index 0a0120f..e439520 100644
>--- a/src/app/models/provider.rb
>+++ b/src/app/models/provider.rb
>@@ -56,9 +56,7 @@ class Provider < ActiveRecord::Base
>       hardware_profiles.each do |hardware_profile|
>         ar_hardware_profile = HardwareProfile.new(:external_key =>
>                                                   hardware_profile.id,
>-                                                  :name => 
>hardware_profile.name ?
>-                                                           
>hardware_profile.name :
>-                                                           
>hardware_profile.id,
>+                                                  :name => 
>hardware_profile.id,
>                                                   :provider_id => id)
>         ar_hardware_profile.add_properties(hardware_profile)
>         ar_hardware_profile.save!
>diff --git a/src/spec/factories/hardware_profile_property.rb 
>b/src/spec/factories/hardware_profile_property.rb
>index 7f470f6..0a2447d 100644
>--- a/src/spec/factories/hardware_profile_property.rb
>+++ b/src/spec/factories/hardware_profile_property.rb
>@@ -3,35 +3,35 @@ end
>
> Factory.define :mock_hwp1_memory, :parent => :hardware_profile_property do |p|
>   p.name 'memory'
>-  p.kind 'fixed'
>+  p.kind :fixed
>   p.unit 'MB'
>   p.value 1740.8
> end
>
> Factory.define :mock_hwp1_storage, :parent => :hardware_profile_property do 
> |p|
>   p.name 'storage'
>-  p.kind 'fixed'
>+  p.kind :fixed
>   p.unit 'GB'
>   p.value 160
> end
>
> Factory.define :mock_hwp1_cpu, :parent => :hardware_profile_property do |p|
>   p.name 'cpu'
>-  p.kind 'fixed'
>+  p.kind :fixed
>   p.unit 'count'
>-  p.value 1
>+  p.value 1.0
> end
>
> Factory.define :mock_hwp1_arch, :parent => :hardware_profile_property do |p|
>   p.name 'architecture'
>-  p.kind 'fixed'
>+  p.kind :fixed
>   p.unit 'label'
>   p.value 'i386'
> end
>
> Factory.define :mock_hwp2_memory, :parent => :hardware_profile_property do |p|
>   p.name 'memory'
>-  p.kind 'range'
>+  p.kind :range
>   p.unit 'MB'
>   p.value 10240
>   p.range_first 7680
>@@ -40,7 +40,7 @@ end
>
> Factory.define :mock_hwp2_storage, :parent => :hardware_profile_property do 
> |p|
>   p.name 'storage'
>-  p.kind 'enum'
>+  p.kind :enum
>   p.unit 'GB'
>   p.value 850
> #  p.property_enum_entries { |p| [p.association(:mock_hwp2_storage_enum1),
>@@ -49,49 +49,49 @@ end
>
> Factory.define :mock_hwp2_cpu, :parent => :hardware_profile_property do |p|
>   p.name 'cpu'
>-  p.kind 'fixed'
>+  p.kind :fixed
>   p.unit 'count'
>-  p.value 2
>+  p.value 2.0
> end
>
> Factory.define :mock_hwp2_arch, :parent => :hardware_profile_property do |p|
>   p.name 'architecture'
>-  p.kind 'fixed'
>+  p.kind :fixed
>   p.unit 'label'
>   p.value 'x86_64'
> end
>
> Factory.define :agg_hwp1_memory, :parent => :hardware_profile_property do |p|
>   p.name 'memory'
>-  p.kind 'fixed'
>+  p.kind :fixed
>   p.unit 'MB'
>   p.value 1740.8
> end
>
> Factory.define :agg_hwp1_storage, :parent => :hardware_profile_property do |p|
>   p.name 'storage'
>-  p.kind 'fixed'
>+  p.kind :fixed
>   p.unit 'GB'
>   p.value 160
> end
>
> Factory.define :agg_hwp1_cpu, :parent => :hardware_profile_property do |p|
>   p.name 'cpu'
>-  p.kind 'fixed'
>+  p.kind :fixed
>   p.unit 'count'
>   p.value 1
> end
>
> Factory.define :agg_hwp1_arch, :parent => :hardware_profile_property do |p|
>   p.name 'architecture'
>-  p.kind 'fixed'
>+  p.kind :fixed
>   p.unit 'label'
>   p.value 'i386'
> end
>
> Factory.define :agg_hwp2_memory, :parent => :hardware_profile_property do |p|
>   p.name 'memory'
>-  p.kind 'range'
>+  p.kind :range
>   p.unit 'MB'
>   p.value 10240
>   p.range_first 7680
>@@ -100,7 +100,7 @@ end
>
> Factory.define :agg_hwp2_storage, :parent => :hardware_profile_property do |p|
>   p.name 'storage'
>-  p.kind 'enum'
>+  p.kind :enum
>   p.unit 'GB'
>   p.value 850
> #  p.property_enum_entries { |p| [p.association(:agg_hwp2_storage_enum1),
>@@ -109,14 +109,14 @@ end
>
> Factory.define :agg_hwp2_cpu, :parent => :hardware_profile_property do |p|
>   p.name 'cpu'
>-  p.kind 'fixed'
>+  p.kind :fixed
>   p.unit 'count'
>   p.value 2
> end
>
> Factory.define :agg_hwp2_arch, :parent => :hardware_profile_property do |p|
>   p.name 'architecture'
>-  p.kind 'fixed'
>+  p.kind :fixed
>   p.unit 'label'
>   p.value 'x86_64'
> end
>diff --git a/src/spec/models/hardware_profile_spec.rb 
>b/src/spec/models/hardware_profile_spec.rb
>index ab04fe1..8aa6557 100644
>--- a/src/spec/models/hardware_profile_spec.rb
>+++ b/src/spec/models/hardware_profile_spec.rb
>@@ -42,6 +42,20 @@ describe HardwareProfile do
>     end
>   end
>
>+  it "should require valid amount of CPU" do
>+    [nil, "hello", -1].each do |fail_value|
>+      @hp.cpu.value = fail_value
>+      @hp.should_not be_valid
>+    end
>+  end
>+
>+  it "should allow numerical amount of CPU" do
>+    [2, 2.2].each do |fail_value|
>+      @hp.cpu.value = fail_value
>+      @hp.should be_valid
>+    end
>+  end
>+
>   it "should allow Aggregator profiles only for provider profiles" do
>     @hp.provider = nil
>
>--
>1.7.0.1
>
>_______________________________________________
>deltacloud-devel mailing list
>[email protected]
>https://fedorahosted.org/mailman/listinfo/deltacloud-devel
>_______________________________________________
>deltacloud-devel mailing list
>[email protected]
>https://fedorahosted.org/mailman/listinfo/deltacloud-devel

-- 
--------------------------------------------------------
Michal Fojtik, [email protected], +420 532 294 4307
Ruby / Ruby On Rails Developer
Deltacloud API: http://deltacloud.org
--------------------------------------------------------
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to