deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject git commit: RHEV-M: Do not advertise :destroy operation when PAUSED (DTACLOUD-355)
Date Wed, 09 Jan 2013 10:33:34 GMT
Updated Branches:
  refs/heads/master 29a4ad3f2 -> bb1aee038


RHEV-M: Do not advertise :destroy operation when PAUSED (DTACLOUD-355)


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

Branch: refs/heads/master
Commit: bb1aee038c0f3dcd5534ff028ef54f3feb5f4922
Parents: 29a4ad3
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Tue Jan 8 13:46:03 2013 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Tue Jan 8 13:46:03 2013 +0100

----------------------------------------------------------------------
 .../lib/deltacloud/drivers/rhevm/rhevm_driver.rb   |   17 ++++++++++++--
 1 files changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/bb1aee03/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
index 322f9d3..69cc563 100644
--- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
+++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
@@ -254,7 +254,18 @@ class RhevmDriver < Deltacloud::BaseDriver
       public_addresses << InstanceAddress.new(inst.vnc[:address], :port => inst.vnc[:port],
:type => :vnc)
     end
 
+    # Remove 'destroy' operation from list of actions when RHEV-M instance
+    # is suspended or paused.
+    if state == 'PAUSED'
+      actions = instance_actions_for(state = 'STOPPED')
+      actions.delete(:destroy)
+    else
+      actions = instance_actions_for(state)
+      can_create_image = true
+    end
+
     Instance.new(
+      :actions=>actions,
       :id => inst.id,
       :name => inst.name,
       :state => state,
@@ -264,10 +275,9 @@ class RhevmDriver < Deltacloud::BaseDriver
       :launch_time => inst.creation_time,
       :instance_profile => profile,
       :hardware_profile_id => profile.id,
-      :actions=>instance_actions_for( state ),
       :public_addresses => public_addresses,
       :private_addresses => [],
-      :create_image => true
+      :create_image => can_create_image || false
     )
   end
 
@@ -286,9 +296,10 @@ class RhevmDriver < Deltacloud::BaseDriver
     return 'PENDING' if ['WAIT_FOR_LAUNCH', 'REBOOT_IN_PROGRESS', 'SAVING_STATE',
                         'RESTORING_STATE', 'POWERING_UP', 'IMAGE_LOCKED', 'SAVING_STATE'].include?
state
     return 'STOPPING' if state == 'POWERING_DOWN'
-    return 'STOPPED' if ['UNASSIGNED', 'DOWN', 'PAUSED', 'NOT_RESPONDING', 'SUSPENDED',
+    return 'STOPPED' if ['UNASSIGNED', 'DOWN', 'NOT_RESPONDING',
                          'IMAGE_ILLEGAL', 'UNKNOWN'].include? state
     return 'RUNNING' if ['UP', 'MIGRATING_TO', 'MIGRATING_FROM'].include? state
+    return 'PAUSED' if ['PAUSED', 'SUSPENDED'].include? state
     raise "Unexpected state '#{state}'"
   end
 


Mime
View raw message