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
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.
On Wed, May 02, 2012 at 11:45:35AM +0100, Martyn Taylor wrote:
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.
<snip>
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.
After a lot of discussion* in #aeolus with Conductor and Deltacloud folks, we concluded that 0 should indeed be a valid value for storage, to expressly indicate that there is no storage. This patch implements that, if anyone is able to review.
-- Matt
* Literally a conversation about nothing -- nil vs. 0.
aeolus-devel@lists.fedorahosted.org