From: martyntaylor <mtaylor(a)redhat.com>
---
src/app/controllers/instance_controller.rb | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/app/controllers/instance_controller.rb
b/src/app/controllers/instance_controller.rb
index ad90404..a81af6a 100644
--- a/src/app/controllers/instance_controller.rb
+++ b/src/app/controllers/instance_controller.rb
@@ -98,16 +98,22 @@ class InstanceController < ApplicationController
Pool.find((a)instance.pool_id))
#FIXME: This should probably be in a transaction
if @instance.save!
-
- @task = InstanceTask.new({:user => current_user,
- :task_target => @instance,
- :action => InstanceTask::ACTION_CREATE})
- if @task.save
- condormatic_instance_create(@task)
- flash[:notice] = "Instance added."
- redirect_to :action => 'index'
+ if Quota.can_start_instance?(@instance, nil)
+ @task = InstanceTask.new({:user => current_user,
+ :task_target => @instance,
+ :action => InstanceTask::ACTION_CREATE})
+ if @task.save
+ condormatic_instance_create(@task)
+ flash[:notice] = "Instance added."
+ redirect_to :action => 'index'
+ else
+ @pool = @instance.pool
+ render :action => 'configure'
+ end
else
- @pool = @instance.pool
+ @instance.destroy
+ flash[:notice] = "Quota Exceeded: Could not create instance"
+ @hardware_profiles = HardwareProfile.all
render :action => 'configure'
end
else
--
1.7.2.3
Show replies by date