From: Jan Provaznik <[email protected]>
---
.../controllers/resources/instances_controller.rb | 14 ++++++--------
src/app/views/resources/instances/_list.haml | 2 +-
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/src/app/controllers/resources/instances_controller.rb
b/src/app/controllers/resources/instances_controller.rb
index 1f915fd..03b7401 100644
--- a/src/app/controllers/resources/instances_controller.rb
+++ b/src/app/controllers/resources/instances_controller.rb
@@ -1,5 +1,6 @@
class Resources::InstancesController < ApplicationController
before_filter :require_user
+ before_filter :instance, :only => [:show, :remove_failed, :key, :stop]
def new
@instance = Instance.new(params[:instance])
@@ -63,8 +64,6 @@ class Resources::InstancesController < ApplicationController
end
def show
- @instance = Instance.find((params[:id] || []).first)
- require_privilege(Privilege::INSTANCE_CONTROL,@instance.pool)
end
def index
@@ -86,8 +85,6 @@ class Resources::InstancesController < ApplicationController
end
def key
- @instance = Instance.find((params[:id] || []).first)
- require_privilege(Privilege::INSTANCE_CONTROL,@instance.pool)
unless @instance.instance_key.nil?
send_data @instance.instance_key.pem,
:filename => "#[email protected]_key.name}.pem",
@@ -99,8 +96,6 @@ class Resources::InstancesController < ApplicationController
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
@@ -117,8 +112,6 @@ class Resources::InstancesController < ApplicationController
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)
@@ -128,6 +121,11 @@ class Resources::InstancesController <
ApplicationController
private
+ def instance
+ @instance = Instance.find((params[:id] || []).first)
+ require_privilege(Privilege::INSTANCE_CONTROL,@instance.pool)
+ end
+
def init_new_instance_attrs
@pools = Pool.list_for_user(@current_user, Privilege::INSTANCE_MODIFY)
@realms = Realm.find(:all, :conditions => { :provider_id => nil })
diff --git a/src/app/views/resources/instances/_list.haml
b/src/app/views/resources/instances/_list.haml
index 1dd305d..d24e89d 100644
--- a/src/app/views/resources/instances/_list.haml
+++ b/src/app/views/resources/instances/_list.haml
@@ -15,7 +15,7 @@
%tr
%td
- selected = params[:select] == 'all'
- %input{:checked => selected, :name => 'ids', :type => 'checkbox',
:value => inst.id, :id => "inst_ids_#{inst.id}" }
+ %input{:checked => selected, :name => 'id', :type => 'checkbox',
:value => inst.id, :id => "inst_ids_#{inst.id}" }
= link_to inst.name, resources_instance_path(inst)
%td= inst.state
%td= inst.template.name
--
1.7.2.3
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel