From: Jan Provaznik <[email protected]>

---
 .../controllers/resources/instances_controller.rb  |   28 ++++++++++++++++++++
 src/app/views/resources/instances/_list.haml       |    4 +-
 src/config/routes.rb                               |    2 +-
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/app/controllers/resources/instances_controller.rb 
b/src/app/controllers/resources/instances_controller.rb
index 4bef66a..95dc34e 100644
--- a/src/app/controllers/resources/instances_controller.rb
+++ b/src/app/controllers/resources/instances_controller.rb
@@ -108,6 +108,34 @@ class Resources::InstancesController < 
ApplicationController
     redirect_to resources_instance_path(@instance)
   end
 
+  def stop
+    @instance = Instance.find((params[:ids] || []).first)
+    require_privilege(Privilege::INSTANCE_CONTROL,@instance.pool)
+    unless @instance.valid_action?('stop')
+      raise ActionError.new("stop is an invalid action.")
+    end
+
+    # not sure if task is used as everything goes through condor
+    #permissons check here
+    @task = @instance.queue_action(@current_user, 'stop')
+    unless @task
+      raise ActionError.new("stop cannot be performed on this instance.")
+    end
+    condormatic_instance_stop(@task)
+    flash[:notice] = "#[email protected]}: stop action was successfully 
queued."
+    redirect_to resources_instances_path
+  end
+
+  def remove_failed
+    @instance = Instance.find((params[:ids] || []).first)
+    require_privilege(Privilege::INSTANCE_CONTROL,@instance.pool)
+    raise ActionError.new("remove failed cannot be performed on this 
instance.") unless
+      @instance.state == Instance::STATE_ERROR
+    condormatic_instance_reset_error(@instance)
+    flash[:notice] = "#[email protected]}: remove failed action was 
successfully queued."
+    redirect_to resources_instances_path
+  end
+
   private
 
   def init_new_instance_attrs
diff --git a/src/app/views/resources/instances/_list.haml 
b/src/app/views/resources/instances/_list.haml
index 79c55ba..d0277ac 100644
--- a/src/app/views/resources/instances/_list.haml
+++ b/src/app/views/resources/instances/_list.haml
@@ -1,7 +1,7 @@
 - form_tag do
-  = restful_submit_tag 'Start', 'start', start_resources_instances_path, 'GET'
-  = restful_submit_tag 'Stop', 'start', stop_resources_instances_path, 'GET'
+  = restful_submit_tag 'Stop', 'stop', stop_resources_instances_path, 'GET'
   = restful_submit_tag 'Create', 'new', 
select_template_resources_instances_path, 'GET'
+  = restful_submit_tag 'Remove failed', 'remove_failed', 
remove_failed_resources_instances_path, 'GET'
 
   %p
     Select:&nbsp;
diff --git a/src/config/routes.rb b/src/config/routes.rb
index bfd6cac..99af504 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -34,7 +34,7 @@ ActionController::Routing::Routes.draw do |map|
 
   map.namespace 'resources' do |r|
     r.resources :pools, :deployments
-    r.resources :instances, :collection => {:start => :get, :stop => :get, 
:select_template => :get}, :member => {:key => :get}
+    r.resources :instances, :collection => {:start => :get, :stop => :get, 
:select_template => :get, :remove_failed => :get}, :member => {:key => :get}
   end
 
   map.namespace 'image_factory' do |r|
-- 
1.7.2.3

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to