deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <di...@fast.au.fujitsu.com>
Subject [PATCH] CIMI: return cimi standard state where known. Also, return image name as name if set. https://issues.apache.org/jira/browse/DTACLOUD-538
Date Sun, 07 Apr 2013 12:15:36 GMT
From: Dies Koper <diesk@fast.au.fujitsu.com>

---
 server/lib/cimi/service/machine_image.rb | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/server/lib/cimi/service/machine_image.rb b/server/lib/cimi/service/machine_image.rb
index 17d9220..2232ddd 100644
--- a/server/lib/cimi/service/machine_image.rb
+++ b/server/lib/cimi/service/machine_image.rb
@@ -27,11 +27,20 @@ class CIMI::Service::MachineImage < CIMI::Service::Base
   end
 
   def self.from_image(image, context)
+    # convert to equivalent cimi states for known mappings
+    state = case image.state
+      when 'ACTIVE' then 'AVAILABLE' # openstack
+      when 'PENDING' then 'CREATING' # ec2, fgcp
+      when 'PREPARING' then 'CREATING' # rackspace
+      when 'SAVING' then 'CREATING' # openstack
+      when 'FAILED' then 'ERROR' # ec2, rackspace
+      else image.state || 'UNKNOWN'
+    end
     self.new(context, :values => {
       :id => context.machine_image_url(image.id),
-      :name => image.id,
+      :name => image.name || image.id,
       :description => image.description,
-      :state => image.state || 'UNKNOWN',
+      :state => state,
       :type => "IMAGE",
       :created => image.creation_time.nil? ?
       Time.now.xmlschema : Time.parse(image.creation_time.to_s).xmlschema
-- 
1.8.0.msysgit.0



Mime
View raw message