incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962048 - in /incubator/deltacloud/trunk/framework: app/controllers/instances_controller.rb config/routes.rb lib/deltacloud/base_driver.rb
Date Thu, 08 Jul 2010 23:19:19 GMT
Author: lutter
Date: Thu Jul  8 23:19:19 2010
New Revision: 962048

URL: http://svn.apache.org/viewvc?rev=962048&view=rev
Log:
Add start and stop methods to instances, and add all instance actions to the root class.

Modified:
    incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb
    incubator/deltacloud/trunk/framework/config/routes.rb
    incubator/deltacloud/trunk/framework/lib/deltacloud/base_driver.rb

Modified: incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb?rev=962048&r1=962047&r2=962048&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb (original)
+++ incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb Thu Jul 
8 23:19:19 2010
@@ -10,9 +10,9 @@ class InstancesController < ApplicationC
     @instances = driver.instances( credentials, @filter )
 
     respond_to do |format|
-      format.html 
+      format.html
       format.json
-      format.xml { 
+      format.xml {
         render :xml=>convert_to_xml( :instance, @instances )
       }
     end
@@ -26,18 +26,13 @@ class InstancesController < ApplicationC
         render :text=>'resource not found', :status=>404 and return unless @instance
       }
       format.json
-      format.xml { 
+      format.xml {
         render :nothing=>true, :status=>404 and return unless @instance
         render :xml=>convert_to_xml( :instance, @instance )
       }
     end
   end
 
-  def destroy
-    driver.delete_instance( credentials, params[:id] )
-    redirect_to :action=>:show
-  end
-
   def new
     @instance = Instance.new( {
                   :id=>params[:id],
@@ -58,7 +53,7 @@ class InstancesController < ApplicationC
                         :id=>params[:id],
                         :image_id=>params[:image_id],
                       } )
-          render :action=>:new and return 
+          render :action=>:new and return
         end
         instance = driver.create_instance( credentials, @image.id, params[:flavor_id] )
         redirect_to instance_url( instance.id )
@@ -73,9 +68,20 @@ class InstancesController < ApplicationC
 
   ##
 
+  def start
+    driver.start_instance(credentials, params[:id])
+    redirect_to :action=>:show
+  end
+
   def stop
+    driver.stop_instance(credentials, params[:id])
+    redirect_to :action=>:show
   end
 
+  def destroy
+    driver.delete_instance( credentials, params[:id] )
+    redirect_to :action=>:show
+  end
 
   def reboot
     driver.reboot_instance( credentials, params[:id] )

Modified: incubator/deltacloud/trunk/framework/config/routes.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/config/routes.rb?rev=962048&r1=962047&r2=962048&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/config/routes.rb (original)
+++ incubator/deltacloud/trunk/framework/config/routes.rb Thu Jul  8 23:19:19 2010
@@ -4,14 +4,16 @@ ActionController::Routing::Routes.draw d
 
   map.root :controller=>'root'
 
-  map.resource :api, :controller=>'Api' 
+  map.resource :api, :controller=>'Api'
 
   map.resources :flavors, :path_prefix=>'api'
 
   map.resources :images, :path_prefix=>'api'
   map.resources :instances, :path_prefix=>'api',
-    :member=>{ 
-      :stop=>:put,
+    :member=>{
+      :delete=>:post,
+      :stop=>:post,
+      :start=>:post,
       :reboot=>:post,
     }
   map.resource :storage, :path_prefix=>'api' do |s|
@@ -38,7 +40,7 @@ ActionController::Routing::Routes.draw d
 
   # Sample resource route with sub-resources:
   #   map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
-  
+
   # Sample resource route with more complex sub-resources
   #   map.resources :products do |products|
   #     products.resources :comments

Modified: incubator/deltacloud/trunk/framework/lib/deltacloud/base_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/lib/deltacloud/base_driver.rb?rev=962048&r1=962047&r2=962048&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/lib/deltacloud/base_driver.rb (original)
+++ incubator/deltacloud/trunk/framework/lib/deltacloud/base_driver.rb Thu Jul  8 23:19:19
2010
@@ -22,13 +22,20 @@ module DeltaCloud
       return images.first unless images.empty?
       nil
     end
-    
+
     def instance(credentials, opts)
       instances = instances(credentials, opts)
       return instances.first unless instances.empty?
       nil
     end
 
+    def start_instance(credentials, id)
+    end
+    def stop_instance(credentials, id)
+    end
+    def reboot_instance(credentials, id)
+    end
+
     def volume(credentials, opts)
       volumes = volumes(credentials, opts)
       return volumes.first unless volumes.empty?



Mime
View raw message