From: Jan Provaznik <[email protected]>
---
.../controllers/resources/instances_controller.rb | 34 ++++++++++++++++---
src/app/views/resources/instances/_list.haml | 1 +
src/config/routes.rb | 2 +-
3 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/src/app/controllers/resources/instances_controller.rb
b/src/app/controllers/resources/instances_controller.rb
index adad984..1f915fd 100644
--- a/src/app/controllers/resources/instances_controller.rb
+++ b/src/app/controllers/resources/instances_controller.rb
@@ -67,12 +67,6 @@ class Resources::InstancesController < ApplicationController
require_privilege(Privilege::INSTANCE_CONTROL,@instance.pool)
end
- def start
- end
-
- def stop
- end
-
def index
@header = [
{:name => 'VM NAME', :sort_attr => 'name'},
@@ -104,6 +98,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..1dd305d 100644
--- a/src/app/views/resources/instances/_list.haml
+++ b/src/app/views/resources/instances/_list.haml
@@ -2,6 +2,7 @@
= restful_submit_tag 'Start', 'start', start_resources_instances_path, 'GET'
= restful_submit_tag 'Stop', 'start', 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:
diff --git a/src/config/routes.rb b/src/config/routes.rb
index 827df84..575c883 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