[PATCH conductor] Adds 0 as a valid value for storage in Hardware Profile Properties
Martyn Taylor
mtaylor at redhat.com
Wed May 2 10:45:35 UTC 2012
On 05/01/2012 07:41 PM, Matt Wagner wrote:
> While we have encouraged the use of "nil" to mean "No storage," some
> providers may report 0 GB. Currently, the code rejects this as invalid.
> Instead, we should treat this as valid. We still do not allow 0 for
> memory or CPU count, since those would not result in a system that
> can run -- but a system with no local storage may still be valid.
> ---
> src/app/models/hardware_profile_property.rb | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/src/app/models/hardware_profile_property.rb b/src/app/models/hardware_profile_property.rb
> index 4f883eb..2b5fd4e 100644
> --- a/src/app/models/hardware_profile_property.rb
> +++ b/src/app/models/hardware_profile_property.rb
> @@ -63,7 +63,9 @@ class HardwareProfileProperty< ActiveRecord::Base
>
> validates_presence_of :unit
> validates_numericality_of :value, :greater_than => 0,
> - :if => Proc.new{|p| (p.name == MEMORY or p.name == STORAGE or p.name == CPU) and p.value.present?}
> + :if => Proc.new{|p| (p.name == MEMORY or p.name == CPU) and p.value.present?}
> + validates_numericality_of :value, :greater_than_or_equal_to => 0,
> + :if => Proc.new{|p| p.name == STORAGE and p.value.present?}
>
> validates_numericality_of :range_first, :greater_than => 0,
> :if => Proc.new{|p| (p.name == MEMORY or p.name == STORAGE or p.name == CPU) and
We should feed these types of inconsistencies back to deltacloud. It's
possible that nil and 0GB mean different things, though I suspect really
that these values should be transformed in DC Core.
More information about the aeolus-devel
mailing list