incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962086 - /incubator/deltacloud/trunk/drivers/mock/lib/mock_driver.rb
Date Thu, 08 Jul 2010 23:21:58 GMT
Author: lutter
Date: Thu Jul  8 23:21:57 2010
New Revision: 962086

URL: http://svn.apache.org/viewvc?rev=962086&view=rev
Log:
Rework instance-state SPI and action interrogation

Modified:
    incubator/deltacloud/trunk/drivers/mock/lib/mock_driver.rb

Modified: incubator/deltacloud/trunk/drivers/mock/lib/mock_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/drivers/mock/lib/mock_driver.rb?rev=962086&r1=962085&r2=962086&view=diff
==============================================================================
--- incubator/deltacloud/trunk/drivers/mock/lib/mock_driver.rb (original)
+++ incubator/deltacloud/trunk/drivers/mock/lib/mock_driver.rb Thu Jul  8 23:21:57 2010
@@ -57,6 +57,22 @@ class MockDriver < DeltaCloud::BaseDrive
     }),
   ] ) unless defined?( REALMS )
 
+  ( INSTANCE_STATES = [
+    [ :pending, {
+       :running=>:_auto_
+     } ],
+     [ :running, {
+       :running=>:reboot,
+       :terminated=>:stop
+     } ],
+     [ :terminated, {
+     } ],
+  ] ) unless defined?( STATES )
+
+
+  def instance_states()
+    return INSTANCE_STATES
+  end
 
   def flavors(credentials, opts=nil)
     return FLAVORS if ( opts.nil? )
@@ -107,7 +123,7 @@ class MockDriver < DeltaCloud::BaseDrive
       instance = YAML.load( File.read( instance_file ) )
       if ( instance[:owner_id] == credentials[:name] )
         instance[:id] = File.basename( instance_file, ".yml" )
-        instance[:actions] = [ :reboot ]
+        instance[:actions] = instance_actions_for( instance[:state] )
         instances << Instance.new( instance )
       end
     end
@@ -139,13 +155,9 @@ class MockDriver < DeltaCloud::BaseDrive
       :owner_id=>credentials[:name],
       :public_addresses=>["#{image_id}.#{next_id}.public.com"],
       :private_addresses=>["#{image_id}.#{next_id}.private.com"],
-<<<<<<< HEAD
-      :flavor_id=>opts[:flavor_id],
-=======
       :flavor_id=>flavor_id,
       :realm_id=>realm_id,
->>>>>>> Add realm support.
-      :actions=>[ :reboot ],
+      :actions=>instance_actions_for( 'RUNNING' )
     }
     File.open( "#{STORAGE_ROOT}/instances/#{next_id}.yml", 'w' ) {|f|
       YAML.dump( instance, f )



Mime
View raw message