deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [16/50] [abbrv] git commit: RHEV-M: Fixed bug in parsing state under 1.8
Date Mon, 30 Jul 2012 14:29:17 GMT
RHEV-M: Fixed bug in parsing state under 1.8

For some reason in Ruby 1.8 the state in RHEV-M
include '\' character, which makes all tests fail.
For now I think we can fix it using 'gsub' and then
investigate this more deeply in future.


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

Branch: refs/heads/master
Commit: 8264f280a81850b6d26fb83d54767b0c963f54fc
Parents: 020dde0
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Fri Jul 27 14:19:50 2012 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Fri Jul 27 14:24:58 2012 +0200

----------------------------------------------------------------------
 .../lib/deltacloud/drivers/rhevm/rhevm_driver.rb   |   21 +++++---------
 1 files changed, 8 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8264f280/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 b66e90e..c60f923 100644
--- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
+++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
@@ -278,19 +278,14 @@ class RhevmDriver < Deltacloud::BaseDriver
     unless state.respond_to?(:upcase)
       raise "State #{state.inspect} is not a string"
     end
-    case state.strip.upcase
-    when 'WAIT_FOR_LAUNCH', 'REBOOT_IN_PROGRESS', 'SAVING_STATE',
-      'RESTORING_STATE', 'POWERING_UP', 'IMAGE_LOCKED', 'SAVING_STATE' then
-      'PENDING'
-    when 'POWERING_DOWN' then
-      'STOPPING'
-    when 'UNASSIGNED', 'DOWN', 'PAUSED', 'NOT_RESPONDING', 'SUSPENDED', 'IMAGE_ILLEGAL',
'UNKNOWN' then
-      'STOPPED'
-    when 'UP', 'MIGRATING_TO', 'MIGRATING_FROM'
-      'RUNNING'
-    else
-      raise "Unexpected state '#{state}'"
-    end
+    state = state.gsub('\\', '').strip.upcase
+    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',
+                         'IMAGE_ILLEGAL', 'UNKNOWN'].include? state
+    return 'RUNNING' if ['UP', 'MIGRATING_TO', 'MIGRATING_FROM'].include? state
+    raise "Unexpected state '#{state}'"
   end
 
   def convert_volume(volume)


Mime
View raw message