You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by ma...@apache.org on 2012/11/12 17:33:26 UTC

[2/3] git commit: CIMI - fix states for Machine and add 'create_image' action when supported

CIMI - fix states for Machine and add 'create_image' action when supported


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/2b46c453
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/2b46c453
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/2b46c453

Branch: refs/heads/master
Commit: 2b46c453a00a4aef81d85f7a1d3ab2f41ffba38a
Parents: 1cf35c7
Author: marios <ma...@redhat.com>
Authored: Mon Nov 12 17:33:29 2012 +0200
Committer: marios <ma...@redhat.com>
Committed: Mon Nov 12 17:33:29 2012 +0200

----------------------------------------------------------------------
 server/lib/cimi/models/machine.rb |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/2b46c453/server/lib/cimi/models/machine.rb
----------------------------------------------------------------------
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)