[PATCH conductor] Adds 0 as a valid value for storage in Hardware Profile Properties

Matt Wagner matt.wagner at redhat.com
Tue May 1 18:41:27 UTC 2012


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
-- 
1.7.7.6




More information about the aeolus-devel mailing list