[PATCH conductor] BZ 802847 - fix hwp matching when there are multiple values for architecture
Richard Su
rwsu at redhat.com
Sat Mar 17 01:01:47 UTC 2012
https://bugzilla.redhat.com/show_bug.cgi?id=802847
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=f5b4c017f6d681594d6c7c79c039278825b67d4c
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 | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/app/models/hardware_profile.rb b/src/app/models/hardware_profile.rb
index 087d2ae..7960f26 100644
--- a/src/app/models/hardware_profile.rb
+++ b/src/app/models/hardware_profile.rb
@@ -213,7 +213,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 +230,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 +254,8 @@ class HardwareProfile < ActiveRecord::Base
end
end
+ def self.is_numeric(value)
+ true if Float(value) rescue false
+ end
+
end
--
1.7.7.6
More information about the aeolus-devel
mailing list