From: Tomas Sedovic <tsedovic(a)redhat.com>
The launch overview page shows how much of the total quota would the
deployment cost.
Previously the value was hard-coded, now it's computed properly.
---
src/app/controllers/deployments_controller.rb | 8 ++++++++
src/app/models/quota.rb | 6 +++---
src/app/views/deployments/_overview.html.haml | 2 +-
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/app/controllers/deployments_controller.rb
b/src/app/controllers/deployments_controller.rb
index e101386..6362e95 100644
--- a/src/app/controllers/deployments_controller.rb
+++ b/src/app/controllers/deployments_controller.rb
@@ -72,6 +72,7 @@ class DeploymentsController < ApplicationController
if @services.empty? or @services.all? {|s, a| s.parameters.empty?}
# we can skip the launch-time parameters screen
check_assemblies_for_errors
+ @additional_quota = count_additional_quota(@deployment)
render 'overview' and return
end
end
@@ -88,6 +89,8 @@ class DeploymentsController < ApplicationController
respond_to do |format|
if @deployment.accessible_and_valid_deployable_xml?(@deployable_url)
check_assemblies_for_errors
+ @additional_quota = count_additional_quota(@deployment)
+
format.html
format.js { render :partial => 'overview' }
format.json { render :json => @deployment }
@@ -341,6 +344,11 @@ class DeploymentsController < ApplicationController
)
end
+ def count_additional_quota(deployment)
+ assembly_count = deployment.deployable_xml.assemblies.count
+ @additional_quota = deployment.pool.quota.percentage_used(assembly_count)
+ end
+
def load_deployment
@deployment = Deployment.find(params[:id])
@pool = @deployment.pool
diff --git a/src/app/models/quota.rb b/src/app/models/quota.rb
index 883eb64..72fecd1 100644
--- a/src/app/models/quota.rb
+++ b/src/app/models/quota.rb
@@ -142,13 +142,13 @@ class Quota < ActiveRecord::Base
return quota_resources
end
- def percentage_used
- if Quota.no_limit(maximum_running_instances) || running_instances == 0
+ def percentage_used(count=running_instances)
+ if Quota.no_limit(maximum_running_instances) || count == 0
return 0
elsif maximum_running_instances == 0
return 100
else
- percentage_used = (running_instances.to_f / maximum_running_instances.to_f) * 100
+ percentage_used = (count.to_f / maximum_running_instances.to_f) * 100
return percentage_used
end
end
diff --git a/src/app/views/deployments/_overview.html.haml
b/src/app/views/deployments/_overview.html.haml
index 83ce81d..724df3b 100644
--- a/src/app/views/deployments/_overview.html.haml
+++ b/src/app/views/deployments/_overview.html.haml
@@ -16,7 +16,7 @@
%section.content-section.deployable_details
%header.confirmation
%h2= t('.header', :deployment => @deployment.name, :pool =>
@pool.name)
- %p= t('.confirmation', :deployment => @deployment.name, :pool =>
@pool.name, :quota => 10)
+ %p= t('.confirmation', :deployment => @deployment.name, :pool =>
@pool.name, :quota => number_to_percentage(@additional_quota, :precision => 0))
.content
%h3= t '.description'
--
1.7.6.4
_______________________________________________
aeolus-devel mailing list
aeolus-devel(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/aeolus-devel