deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@redhat.com
Subject [PATCH] CIMI: Adds guards in conversion of hardware_profile to machineConfig
Date Thu, 28 Jun 2012 10:10:17 GMT
From: marios <marios@redhat.com>

CIMI spec allows for non-existent cpu and disks (provider/consumer
support optional) - as demonstrated by FGCP cloud.

Addresses JIRA DTACLOUD_245 - thanks Dies Kopper for reporting.

https://issues.apache.org/jira/browse/DTACLOUD-245

Signed-off-by: marios <marios@redhat.com>
---
 server/lib/cimi/models/machine_configuration.rb |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/server/lib/cimi/models/machine_configuration.rb b/server/lib/cimi/models/machine_configuration.rb
index f9d98f2..28bf3ab 100644
--- a/server/lib/cimi/models/machine_configuration.rb
+++ b/server/lib/cimi/models/machine_configuration.rb
@@ -52,16 +52,16 @@ class CIMI::Model::MachineConfiguration < CIMI::Model::Base
     # We accept just profiles with all properties set
     return unless profile.memory or profile.cpu or profile.storage
     memory = profile.memory.value || profile.memory.default
-    cpu = profile.cpu.value || profile.cpu.default
-    storage = profile.storage.value || profile.storage.default
+    cpu = (profile.cpu ? (profile.cpu.value || profile.cpu.default) : nil )
+    storage = (profile.storage ? (profile.storage.value || profile.storage.default) :  nil
)
     machine_hash = {
       :name => profile.name,
       :description => "Machine Configuration with #{memory} #{profile.memory.unit} "+
         "of memory and #{cpu} CPU",
-      :cpu => cpu,
+      :cpu => ( cpu if cpu ) ,
       :created => Time.now.to_s,  # FIXME: DC hardware_profile has no mention about created_at
       :memory => { :quantity => profile.memory.value || profile.memory.default, :units
=> profile.memory.unit },
-      :disks => [ { :capacity => { :quantity => profile.storage.value || profile.storage.default,
:units => profile.storage.unit } } ],
+      :disks => (  [ { :capacity => { :quantity => profile.storage.value || profile.storage.default,
:units => profile.storage.unit } } ] if storage ),
       :id => context.machine_configuration_url(profile.name)
     }
     self.new(machine_hash)
-- 
1.7.6.5


Mime
View raw message