deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject git commit: Adds error state to state machine model (+openstack)
Date Thu, 20 Dec 2012 10:18:20 GMT
Updated Branches:
  refs/heads/master 4f0e6a3ea -> 2084b6bdd


Adds error state to state machine model (+openstack)


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

Branch: refs/heads/master
Commit: 2084b6bddf1a9cbce642d881cd0b76845b2cfdbe
Parents: 4f0e6a3
Author: marios <marios@redhat.com>
Authored: Wed Dec 19 19:23:00 2012 +0200
Committer: marios <marios@redhat.com>
Committed: Thu Dec 20 12:17:00 2012 +0200

----------------------------------------------------------------------
 server/lib/deltacloud/drivers/base_driver.rb       |    2 +-
 .../drivers/openstack/openstack_driver.rb          |    3 ++-
 server/lib/deltacloud/models/state_machine.rb      |    8 ++++++++
 3 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/2084b6bd/server/lib/deltacloud/drivers/base_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/base_driver.rb b/server/lib/deltacloud/drivers/base_driver.rb
index f488f91..4496a46 100644
--- a/server/lib/deltacloud/drivers/base_driver.rb
+++ b/server/lib/deltacloud/drivers/base_driver.rb
@@ -27,7 +27,7 @@ module Deltacloud
     include Exceptions
 
     STATE_MACHINE_OPTS = {
-      :all_states => [:start, :pending, :running, :stopping, :stopped, :finish],
+      :all_states => [:start, :pending, :running, :stopping, :stopped, :finish, :error],
       :all_actions => [:create, :reboot, :stop, :start, :destroy]
     } unless defined?(STATE_MACHINE_OPTS)
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/2084b6bd/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
index ee9957a..6d0ae9c 100644
--- a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
+++ b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
@@ -40,6 +40,7 @@ module Deltacloud
           running.to( :stopping )       .on( :stop )
           stopping.to( :stopped )       .automatically
           stopped.to( :finish )         .automatically
+          error.from(:running, :pending, :stopping)
         end
 
         define_hardware_profile('default')
@@ -541,7 +542,7 @@ private
             when /build.*$/
               "PENDING"
             when /error.*/
-              "STOPPED"
+              "ERROR"
             when /active/
               "RUNNING"
             else

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/2084b6bd/server/lib/deltacloud/models/state_machine.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/state_machine.rb b/server/lib/deltacloud/models/state_machine.rb
index cbdaf4a..c03b6a4 100644
--- a/server/lib/deltacloud/models/state_machine.rb
+++ b/server/lib/deltacloud/models/state_machine.rb
@@ -81,6 +81,14 @@ module Deltacloud
         transition
       end
 
+      def from(*states)
+        states.each do |s|
+          initial = @machine.state(s)
+          trans = initial.to self.name
+          trans.automatically
+        end
+      end
+
     end
 
     class Transition


Mime
View raw message