On 08/17/2011 09:47 AM, jprovazn(a)redhat.com wrote:
From: Jan Provaznik<jprovazn(a)redhat.com>
These actions were used by condor plugins when choosing provider account,
now provider account is chosen on conductor side so it's not used anymore.
---
src/app/controllers/instances_controller.rb | 52 +--------------------------
src/config/routes.rb | 5 ---
src/features/api.feature | 40 --------------------
3 files changed, 1 insertions(+), 96 deletions(-)
delete mode 100644 src/features/api.feature
diff --git a/src/app/controllers/instances_controller.rb
b/src/app/controllers/instances_controller.rb
index a315db9..e0f5d13 100644
--- a/src/app/controllers/instances_controller.rb
+++ b/src/app/controllers/instances_controller.rb
@@ -1,5 +1,5 @@
class InstancesController< ApplicationController
- before_filter :require_user, :except => [:can_start, :can_create]
+ before_filter :require_user
before_filter :load_instance, :only => [:show, :key, :edit, :update]
before_filter :set_view_vars, :only => [:show, :index]
@@ -148,56 +148,6 @@ class InstancesController< ApplicationController
end
end
- def can_create
- respond_to do |format|
- begin
- provider_account = ProviderAccount.find(params[:provider_account_id])
- @instance = Instance.find(params[:id])
- @action_request = "can_create"
- @value = Quota.can_create_instance?(@instance, provider_account)
- format.html { render :partial => 'can_perform_state_change.xml' }
- format.xml { render :partial => 'can_perform_state_change.xml' }
- format.json { render :json => {:action_request => @action_request,
:instance_id => @instance.id, :value => @value} }
- rescue ActiveRecord::RecordNotFound
- format.html { head :not_found }
- format.json { render :json => {:error => 'Record not found'},
:status => :not_found }
- format.xml { render :xml => {:error => 'Record not found'},
:status => :not_found }
- rescue Exception
- format.html { head :internal_server_error }
- format.json { render :json => {:error => $!}, :status =>
:internal_server_error }
- format.xml { render :xml => {:error => $!}, :status =>
:internal_server_error }
- end
- end
- end
-
- def can_start
- respond_to do |format|
- begin
- provider_account = ProviderAccount.find(params[:provider_account_id])
- @instance = Instance.find(params[:id])
- @action_request = "can_start"
- @value = Quota.can_start_instance?(@instance, provider_account)
- format.html { render :partial => 'can_perform_state_change.xml' }
- format.xml { render :partial => 'can_perform_state_change.xml' }
- format.json { render :json => {:action_request => @action_request,
:instance_id => @instance.id, :value => @value} }
- rescue ActiveRecord::RecordNotFound => e
- format.html do
- puts e.inspect
- head :not_found
- end
- format.json { render :json => {:error => 'Record not found'},
:status => :not_found }
- format.xml { render :xml => {:error => 'Record not found'},
:status => :not_found }
- rescue Exception => e
- format.html do
- puts e.inspect
- head :internal_server_error
- end
- format.json { render :json => {:error => $!}, :status =>
:internal_server_error }
- format.xml { render :xml => {:error => $!}, :status =>
:internal_server_error }
- end
- end
- end
-
private
def load_instance
diff --git a/src/config/routes.rb b/src/config/routes.rb
index 1d6857e..c8b601c 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -95,15 +95,10 @@ Conductor::Application.routes.draw do
get 'remove_failed'
end
member do
- get 'can_start'
- get 'can_create'
get 'key'
end
end
- #map.can_start_instance
'/instances/:instance_id/can_start/:provider_account_id', :controller =>
'instances', :action => 'can_start', :conditions => { :method
=> :get }
- #map.can_create_instance
'/instances/:instance_id/can_create/:provider_account_id', :controller =>
'instances', :action => 'can_create', :conditions => { :method
=> :get }
-
resources :image_imports
resources :hardware_profiles do
diff --git a/src/features/api.feature b/src/features/api.feature
deleted file mode 100644
index 4ff624a..0000000
--- a/src/features/api.feature
+++ /dev/null
@@ -1,40 +0,0 @@
-Feature: User authentication
- In order to automatically manage my Cloud Engine environment
- As a client
- I must be able to access a Cloud Engine APU+I
-
- Background:
- Given I am an authorised user
- And I am logged in
-
- Scenario: Check can start instance
- Given there is a user "testuser"
- And there is a provider named "testprovider"
- And there is a provider account named "testaccount"
- And there are the following instances:
- | name | external_key | state | public_addresses | private_addresses |
- | mock | ext_mock | stopped | mock.public.address | mock.private.address |
- And user "testuser" owns instance "mock"
- When a client requests "can_start" for instance "mock" for
provider account "testaccount"
- Then the root element should be "result"
- And there should exist the following xpath: "/result/action_request"
- And this path should have the value "can_start"
- And there should exist the following xpath: "/result/instance_id"
- And there should exist the following xpath: "/result/value"
- And this path should have the value "true"
-
- Scenario: Check can create instance
- Given there is a user "testuser"
- And there is a provider named "testprovider"
- And there is a provider account named "testaccount"
- And there are the following instances:
- | name | external_key | state | public_addresses | private_addresses |
- | mock | ext_mock | stopped | mock.public.address | mock.private.address |
- And user "testuser" owns instance "mock"
- When a client requests "can_create" for instance "mock" for
provider account "testaccount"
- Then the root element should be "result"
- And there should exist the following xpath: "/result/action_request"
- And this path should have the value "can_create"
- And there should exist the following xpath: "/result/instance_id"
- And there should exist the following xpath: "/result/value"
- And this path should have the value "true"
ACK