https://bugzilla.redhat.com/show_bug.cgi?id=802847
The first element of the matched results was being returned. It should use the sorted
results. This is why we are seeing xlarge as the matched hardware profile instead of large
even though memory is specified as 512m which matches both.
When there multiple architectures defined in a provider hardware profile. The matching
logic only uses the first listed value. This means it would only see i386 and not x86_64
when architecture is specified as ['i386', 'x86_64'].
We will begin to see multiple architectures defined for ec2 once this patch in deltacloud
is released:
https://git-wip-us.apache.org/repos/asf?p=deltacloud.git;a=commitdiff;h=f...
Fixed the matching logic to consider all options that may be listed in architecture.
Once both conductor and deltacloud changes are in. m1.small will be usable and matched
when memory is specified as 512m and architecture is specified as x86_64.
---
src/app/models/hardware_profile.rb | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/app/models/hardware_profile.rb b/src/app/models/hardware_profile.rb
index 087d2ae..2a574fe 100644
--- a/src/app/models/hardware_profile.rb
+++ b/src/app/models/hardware_profile.rb
@@ -144,7 +144,8 @@ class HardwareProfile < ActiveRecord::Base
# of hw profile)
hardware_profiles.sort do |hw1, hw2|
BigDecimal.new(hw1.memory.sort_value(false).to_s) <=>
BigDecimal.new(hw2.memory.sort_value(false).to_s)
- end.first
+ end
+ hardware_profiles.first
end
def self.generate_override_property_values(front_end_hwp, back_end_hwp)
@@ -213,7 +214,7 @@ class HardwareProfile < ActiveRecord::Base
match_hardware_profile_property(front_end_hwp.memory, back_end_hwp.memory)
&&
match_hardware_profile_property(front_end_hwp.cpu, back_end_hwp.cpu) &&
match_hardware_profile_property(front_end_hwp.storage, back_end_hwp.storage)
&&
- front_end_hwp.architecture.value == back_end_hwp.architecture.value
+ match_hardware_profile_property(front_end_hwp.architecture,
back_end_hwp.architecture)
end
def self.match_hardware_profile_property(front_end_property, back_end_property)
@@ -230,10 +231,16 @@ class HardwareProfile < ActiveRecord::Base
match = BigDecimal.new(back_end_property.range_last.to_s) >=
BigDecimal.new(front_end_property.value.to_s) ? true : false
when "enum"
create_array_from_property(back_end_property).each do |value|
- if front_end_property.value.nil? or BigDecimal.new(value) >=
BigDecimal.new(front_end_property.value.to_s)
+ if front_end_property.value.nil?
+ match = true
+ elsif !is_numeric(front_end_property.value) || !is_numeric(value)
+ if front_end_property.value == value
match = true
end
+ elsif BigDecimal.new(value) >= BigDecimal.new(front_end_property.value.to_s)
+ match = true
end
+ end
end
return match
end
@@ -248,4 +255,8 @@ class HardwareProfile < ActiveRecord::Base
end
end
+ def self.is_numeric(value)
+ true if Float(value) rescue false
+ end
+
end
--
1.7.7.6