deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@redhat.com
Subject [PATCH 07/10] CIMI (machine): make sure memory is reported as an integer
Date Thu, 08 Nov 2012 04:05:33 GMT
From: David Lutterkort <lutter@redhat.com>

---
 server/lib/cimi/models/machine.rb     |    2 +-
 tests/cimi/machine_collection_test.rb |    6 ++++++
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/server/lib/cimi/models/machine.rb b/server/lib/cimi/models/machine.rb
index fbf25dd..9358c18 100644
--- a/server/lib/cimi/models/machine.rb
+++ b/server/lib/cimi/models/machine.rb
@@ -157,7 +157,7 @@ class CIMI::Model::Machine < CIMI::Model::Base
   def self.convert_instance_memory(profile, context)
     machine_conf = CIMI::Model::MachineConfiguration.find(profile.name, context)
     memory_override = profile.overrides.find { |p, v| p == :memory }
-    memory_override.nil? ? machine_conf.memory : context.to_kibibyte(memory_override[1].to_i,"MB")
+    memory_override.nil? ? machine_conf.memory.to_i : context.to_kibibyte(memory_override[1].to_i,"MB")
   end
 
   def self.convert_instance_addresses(instance)
diff --git a/tests/cimi/machine_collection_test.rb b/tests/cimi/machine_collection_test.rb
index a5ad3f4..c6b5b7b 100644
--- a/tests/cimi/machine_collection_test.rb
+++ b/tests/cimi/machine_collection_test.rb
@@ -33,4 +33,10 @@ class MachineCollectionBehavior < CIMI::Test::Spec
     machines.wont_be_nil      # Make sure we talk to the server
     last_response.json["resourceURI"].must_equal RESOURCE_URI
   end
+
+  it "should report integer values for memory" do
+    machines.entries.each do |machine|
+      machine.memory.to_s.must_match /^[0-9]+$/
+    end
+  end
 end
-- 
1.7.7.6


Mime
View raw message