You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2010/07/09 01:22:45 UTC

svn commit: r962098 - /incubator/deltacloud/trunk/drivers/mock/lib/mock_driver.rb

Author: lutter
Date: Thu Jul  8 23:22:44 2010
New Revision: 962098

URL: http://svn.apache.org/viewvc?rev=962098&view=rev
Log:
Wire up start/stop/reboot.

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=962098&r1=962097&r2=962098&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:22:44 2010
@@ -65,6 +65,9 @@ class MockDriver < DeltaCloud::BaseDrive
        :running=>:reboot,
        :terminated=>:stop
      } ],
+     [ :stopped, {
+       :running=>:start,
+     } ],
      [ :terminated, {
      } ],
   ] ) unless defined?( STATES )
@@ -166,9 +169,39 @@ class MockDriver < DeltaCloud::BaseDrive
     Instance.new( instance )
   end
 
+  def start_instance(credentials, id)
+    instance_file = "#{STORAGE_ROOT}/instances/#{id}.yml"
+    instance_yml  = YAML.load( File.read( instance_file ) )
+    instance_yml[:state] = 'RUNNING'
+    File.open( instance_file, 'w' ) do |f|
+      f << YAML.dump( instance_yml ) 
+    end
+    Instance.new( instance_yml )
+  end
+
   def reboot_instance(credentials, id)
+    instance_file = "#{STORAGE_ROOT}/instances/#{id}.yml"
+    instance_yml  = YAML.load( File.read( instance_file ) )
+    instance_yml[:state] = 'RUNNING'
+    File.open( instance_file, 'w' ) do |f|
+      f << YAML.dump( instance_yml ) 
+    end
+    Instance.new( instance_yml )
+  end
+
+  def stop_instance(credentials, id)
+    puts "STOP INSTANCE #{id}"
+    instance_file = "#{STORAGE_ROOT}/instances/#{id}.yml"
+    instance_yml  = YAML.load( File.read( instance_file ) )
+    instance_yml[:state] = 'STOPPED'
+    File.open( instance_file, 'w' ) do |f|
+      f << YAML.dump( instance_yml )
+    end
+    puts "returning #{instance_yml.inspect}"
+    Instance.new( instance_yml )
   end
 
+
   def destroy_instance(credentials, id)
     check_credentials( credentials )
     FileUtils.rm( "#{STORAGE_ROOT}/instances/#{id}.yml" )