Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions BrainPortal/app/controllers/quotas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def new
def update #:nodoc:
id = params[:id].presence # can be nil if we create() a new quota object
@mode = params[:mode].to_s == 'cpu' ? :cpu : :disk

@quota = Quota.find(id) unless id.blank?
if @quota
# Set mode to sane version no matter what
Expand Down Expand Up @@ -421,4 +420,3 @@ def guess_time_units(timestring)
end

end

10 changes: 9 additions & 1 deletion BrainPortal/app/helpers/select_box_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ module SelectBoxHelper
# [selector] used for default selection. This can be a User object, a user id (String or Integer),
# or any model that has a user_id attribute.
# [users] the array of User objects used to build the select box. Defaults to +current_user.available_users+.
# [include_blank] - include blank value with specific label
# [special_label] - inject special value and label
def user_select(parameter_name = "user_id", options = {}, select_tag_options = {} )
options = { :selector => options } unless options.is_a?(Hash)
selector = options[:selector]
Expand All @@ -52,6 +54,13 @@ def user_select(parameter_name = "user_id", options = {}, select_tag_options = {
# Final HTML rendering of the options for select
user_by_lock_status = regroup_users_by_lock_status(users)
grouped_options = grouped_options_for_select user_by_lock_status, selected

special_label = select_tag_options.delete(:special_label) || options[:special_label]
if special_label
label, value = special_label
grouped_options = "<option value=\"#{value}\">#{h(label)}</option>".html_safe + grouped_options
end

blank_label = select_tag_options.delete(:include_blank) || options[:include_blank]
if blank_label
blank_label = "" if blank_label == true
Expand Down Expand Up @@ -617,4 +626,3 @@ def uploadable_data_providers(user=current_user)
end

end

7 changes: 7 additions & 0 deletions BrainPortal/app/models/cpu_quota.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ def is_for_user? #:nodoc:
self.user_id != 0
end

# currently only for total task cap for all the users
def is_for_total? #:nodoc:
self.user_id == Quota::ALL_USERS
end

def is_for_resource? #:nodoc:
self.remote_resource_id != 0
end
Expand Down Expand Up @@ -280,10 +285,12 @@ def limits_are_reasonable
# # - - y case 3
# # y y - case 4
# # - y y case 5
# #Quota::ALL_USERSy - case 6
def user_exec_group_are_reasonable #:nodoc:
uid = self.user_id || 0
rrid = self.remote_resource_id || 0
gid = self.group_id || 0
return true if uid == Quota::ALL_USERS && rrid > 0 && gid == 0 # case #6
return true if uid > 0 && gid == 0 # case 1 and 4
return true if gid > 0 && uid == 0 # case 3 and 5
return true if rrid > 0 && uid == 0 && gid == 0 # case 2
Expand Down
2 changes: 2 additions & 0 deletions BrainPortal/app/models/quota.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ class Quota < ApplicationRecord

cbrain_abstract_model! # objects of this class are not to be instantiated

ALL_USERS = -7 # indicate total quota for all the users togeter

end
6 changes: 6 additions & 0 deletions BrainPortal/app/views/quotas/_cpu_quotas_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
:sortable => true,
:filters => default_filters_for(@base_scope, User)
) do |cq|
if cq.is_for_total?
html_colorize("(Total for all user)", 'orange')
end
if ! cq.is_for_user?
if cq.is_for_group?
html_colorize("(For all users in project)", 'orange')
Expand All @@ -65,6 +68,9 @@
end
else
link_to_user_if_accessible(cq.user)
if cq.is_for_total?
html_colorize("(Total for all users)", 'orange')
end
end
end

Expand Down
16 changes: 12 additions & 4 deletions BrainPortal/app/views/quotas/_show_cpu_quota.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,25 @@

<% t.cell("User", :show_width => 2) do %>
<% if @quota.new_record? %>
<%= user_select("quota[user_id]", { :selector => @quota.user_id, :include_blank => '(Default For All Users)' }) %>

<%= user_select("quota[user_id]", { :selector => @quota.user_id,
:include_blank => '(Default For All Users)',
:special_label => ["Max for all users together", Quota::ALL_USERS ]
}) %>
<div class="field_explanation">
You can leave the user field blank and instead specify a project, below.
You can also leave them both blank.
</div>
<% else %>
<%= @quota.is_for_user? ?
<% if @quota.is_for_total? %>
<%= html_colorize("(Server-wide task total)", 'orange') %>
<% else %>
<%= @quota.is_for_user? ?
link_to_user_if_accessible(@quota.user) :
html_colorize("(Default for all users)", 'orange') %>
<% end %>
<% end %>

<% end %>

<% t.cell("Project", :show_width => 2) do %>
Expand Down Expand Up @@ -120,8 +129,7 @@
Leave blank to not set a limit. A value of zero will prevent any tasks from being launched.
Note that projects are ignored for these values, and that if several quota records apply
to a user and differ only by project, the minimum value found in that set will be used.
The core Admin account is used to set a maximum number of tasks IN TOTAL for an Execution
server (thus, no limit specific to that admin user can be specified here).
It is possible to define a maximum number of tasks IN TOTAL for an Execution server.
</div>
<% end %>

Expand Down