deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@redhat.com
Subject [PATCH 2/3] CIMI - fix states for Machine and add 'create_image' action when supported
Date Mon, 12 Nov 2012 15:36:08 GMT
From: marios <marios@redhat.com>


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

diff --git a/server/lib/cimi/models/machine.rb b/server/lib/cimi/models/machine.rb
index c6865b6..e2594d1 100644
--- a/server/lib/cimi/models/machine.rb
+++ b/server/lib/cimi/models/machine.rb
@@ -149,7 +149,11 @@ class CIMI::Model::Machine < CIMI::Model::Base
   # which is defined in CIMI (p65)
   #
   def self.convert_instance_state(state)
-    ('RUNNING' == state) ? 'STARTED' : state
+    case state
+      when "RUNNING" then "STARTED"
+      when "PENDING" then "CREATING" #aruba only exception... could be "STARTING" here
+      else state
+    end
   end
 
   def self.convert_instance_properties(instance, context)
@@ -190,11 +194,13 @@ class CIMI::Model::Machine < CIMI::Model::Base
   end
 
   def self.convert_instance_actions(instance, context)
-    instance.actions.collect do |action|
+    actions = instance.actions.collect do |action|
       action = :destroy if action == :delete # In CIMI destroy operation become delete
       action = :restart if action == :reboot  # In CIMI reboot operation become restart
       { :href => context.send(:"#{action}_machine_url", instance.id), :rel => "http://schemas.dmtf.org/cimi/1/action/#{action}"
}
     end
+    actions <<  { :href => context.send(:"machine_images_url"), :rel => "http://schemas.dmtf.org/cimi/1/action/capture"
} if instance.can_create_image?
+    actions
   end
 
   def self.convert_storage_volumes(instance, context)
-- 
1.7.11.7


Mime
View raw message