I've not managed to do a proper full end to end test, since (on my setup anyway) when using the Mock Driver and Mock Target for building images, when I start an instance, the instance never goes into the state "Running", this means the Quotas are not updated, in addition Image Builder fails to build for EC2 on my box, every time.
I have tested this on users when Quotas are set to 0 and it works fine. Please could someone with full end to end using EC2 or a working Mock setup, please try this out :) Since the Quota checking is now done in the CloudEngine, we should be able to write a Cuke test. However, I'm not sure if starting instances, using Cuke is possible? Since we have an external dependency on Image Builder, unless its possible to Mock all the objects we need??? I am on PTO for the rest of this week, but I will be checking my mail, so feel free to drop me a line Thanks Martyn ----- Original Message ----- From: [email protected] To: [email protected] Cc: "martyntaylor" <[email protected]> Sent: Thursday, October 28, 2010 10:34:10 AM GMT +00:00 GMT Britain, Ireland, Portugal Subject: [PATCH aggregator] Added check for Quota before creating instance From: martyntaylor <[email protected]> --- 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(@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 _______________________________________________ deltacloud-devel mailing list [email protected] https://fedorahosted.org/mailman/listinfo/deltacloud-devel
