Skip to content

Commit

Permalink
Fix naming to use Resource Quota consistently
Browse files Browse the repository at this point in the history
Settings, error messages, API definitions, and views use occasionally
"Resource quota" or "resource quota" instead of "Resource Quota".
  • Loading branch information
bastian-src committed Feb 7, 2025
1 parent b99cc58 commit 0a0918f
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Foreman Resource Quota

Foreman plugin to allow resource management with resource quotas among users and usergroups.
Foreman plugin to allow resource management with Resource Quotas among users and usergroups.
For more information, see [Limiting host resources](https://docs.theforeman.org/nightly/Administering_Project/index-katello.html#limiting-host-resources).

## Installation
Expand All @@ -21,11 +21,11 @@ For more information, see [Limiting host resources](https://docs.theforeman.org/

_TODO_ Still under development: Official documentation will be added soon.

When several users share a compute resource or infrastructure, there is a concern that some users could use more than its fair share of resources. Resource quotas are a tool for administrators to address this concern. They limit access to the shared resource in order to guarantee a fair collaboration.
When several users share a compute resource or infrastructure, there is a concern that some users could use more than its fair share of resources. Resource Quotas are a tool for administrators to address this concern. They limit access to the shared resource in order to guarantee a fair collaboration.

In the context of Foreman, multiple users or groups usually share a fixed number of resources (limitation of compute resources like CPU cores, memory, and disk space). As of now, a user cannot be limited when allocating resources. They can create hosts with as many resources as they want. This could lead to over-usage or unequal balancing of resources under the users.

This plugin introduces the configuration of resource quotas. A quota limits specific resources and can be applied to a user or a user group. If a user belongs to a user group, the group’s quota is automatically applied to the user as well. When deploying a new host, a user has to choose a resource quota that the host counts to.
This plugin introduces the configuration of Resource Quotas. A quota limits specific resources and can be applied to a user or a user group. If a user belongs to a user group, the group’s quota is automatically applied to the user as well. When deploying a new host, a user has to choose a Resource Quota that the host counts to.

A user is hindered from deploying new hosts, if the new host would exceed the corresponding quota limits. In case, a user belongs to multiple user group with quota, the user can determine which quota new hosts belong to.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ class ResourceQuotasController < ::Api::V2::BaseController
before_action :find_resource, only: %i[show update destroy]
before_action :custom_find_resource, only: %i[utilization missing_hosts hosts users usergroups]

api :GET, '/resource_quotas', N_('List all resource quotas')
api :GET, '/resource_quotas', N_('List all Resource Quotas')
param_group :search_and_pagination, ::Api::V2::BaseController
add_scoped_search_description_for(ForemanResourceQuota::ResourceQuota)
def index
@resource_quotas = resource_scope_for_index
end

api :GET, '/resource_quotas/:id/', N_('Show resource quota')
api :GET, '/resource_quotas/:id/', N_('Show Resource Quota')
param :id, :identifier, required: true
def show
end
Expand All @@ -46,49 +46,49 @@ def missing_hosts
process_response @resource_quota
end

api :GET, '/resource_quotas/:id/hosts', N_('Show hosts of a resource quota')
api :GET, '/resource_quotas/:id/hosts', N_('Show hosts of a Resource Quota')
param :id, :identifier, required: true
def hosts
process_response @resource_quota.hosts
end

api :GET, '/resource_quotas/:id/users', N_('Show users of a resource quota')
api :GET, '/resource_quotas/:id/users', N_('Show users of a Resource Quota')
param :id, :identifier, required: true
def users
process_response @resource_quota.users
end

api :GET, '/resource_quotas/:id/usergroups', N_('Show usergroups of a resource quota')
api :GET, '/resource_quotas/:id/usergroups', N_('Show usergroups of a Resource Quota')
param :id, :identifier, required: true
def usergroups
process_response @resource_quota.usergroups
end

def_param_group :resource_quota do
param :resource_quota, Hash, required: true, action_aware: true do
param :name, String, required: true, desc: N_('Name of the resource quota')
param :description, String, required: false, desc: N_('Description of the resource quota')
param :name, String, required: true, desc: N_('Name of the Resource Quota')
param :description, String, required: false, desc: N_('Description of the Resource Quota')
param :cpu_cores, Integer, required: false, desc: N_('Maximum number of CPU cores')
param :memory_mb, Integer, required: false, desc: N_('Maximum memory in MiB')
param :disk_gb, Integer, required: false, desc: N_('Maximum disk space in GiB')
end
end

api :POST, '/resource_quotas/', N_('Create a resource quota')
api :POST, '/resource_quotas/', N_('Create a Resource Quota')
param_group :resource_quota, as: :create
def create
@resource_quota = ForemanResourceQuota::ResourceQuota.new(resource_quota_params)
process_response @resource_quota.save
end

api :PUT, '/resource_quotas/:id/', N_('Update a resource quota')
api :PUT, '/resource_quotas/:id/', N_('Update a Resource Quota')
param :id, :identifier, required: true
param_group :resource_quota
def update
process_response @resource_quota.update(resource_quota_params)
end

api :DELETE, '/resource_quotas/:id/', N_('Delete a resource quota')
api :DELETE, '/resource_quotas/:id/', N_('Delete a Resource Quota')
param :id, :identifier, required: true
def destroy
process_response @resource_quota.destroy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module HostsControllerExtensions
update_api(:create, :update) do
param :host, Hash do
param :resource_quota_id, :number, required: false,
desc: N_('Resource quota ID.
desc: N_('Resource Quota ID.
This field is required if the setting `resource_quota_optional_assignment` is set to false.')
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module UsergroupsControllerExtensions
update_api(:create, :update) do
param :usergroup, Hash do
param :resource_quota_ids, Array, of: :number, required: false,
desc: N_('Resource quota IDs to be associated with this user group. ')
desc: N_('Resource Quota IDs to be associated with this user group. ')
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ module UsersControllerExtensions
update_api(:create, :update) do
param :user, Hash do
param :resource_quota_ids, Array, of: :number, required: false,
desc: N_('Resource quota IDs to be associated with this user. ')
desc: N_('Resource Quota IDs to be associated with this user. ')
param :resource_quota_is_optional, :bool,
desc: N_('When set to "true", it is optional for a user to assign a quota when creating new hosts.
The default value is "false".')
The default value is "false".')
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ def verify_resource_quota
rescue ResourceQuotaException => e
handle_error('resource_quota_id',
e.bare_message,
format('An error occured while checking the resource quota capacity: %s', e))
format('An error occured while checking the Resource Quota capacity: %s', e))
rescue Foreman::Exception => e
handle_error(:base,
e.bare_message,
format('An unexpected Foreman error occured while checking the resource quota capacity: %s', e))
format('An unexpected Foreman error occured while checking the Resource Quota capacity: %s', e))
rescue StandardError => e
handle_error(:base,
e.message,
format('An unknown error occured while checking the resource quota capacity: %s', e))
format('An unknown error occured while checking the Resource Quota capacity: %s', e))
end

def resource_quota_id
Expand Down Expand Up @@ -124,8 +124,8 @@ def formulate_resource_inconsistency_error(quota_name, resource_type, quota_util
end

def formulate_quota_inconsistency_error(quota_name)
N_("An error occured adapting the resource quota utilization of '#{quota_name}' " \
"while processing host '#{name}'. The resource quota utilization values might be inconsistent.")
N_("An error occured adapting the Resource Quota utilization of '#{quota_name}' " \
"while processing host '#{name}'. The Resource Quota utilization values might be inconsistent.")
end

def early_return?(quota)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<%= webpacked_plugins_css_for :foreman_resource_quota %>
<% end %>

<% title _('Resource quotas') %>
<% title _('Resource Quotas') %>

<%= title_actions react_component('CreateResourceQuotaModal') %>

Expand Down
4 changes: 2 additions & 2 deletions lib/foreman_resource_quota/register.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@
type: :boolean,
default: false,
full_name: N_('Resource Quota optional assignment'),
description: N_('Make the assignment of a Resource quota, during the host creation process, optional for
description: N_('Make the assignment of a Resource Quota, during the host creation process, optional for
everyone. If this is true, user-specific "optional assignment" configurations are neglected.')
setting 'resource_quota_global_no_action',
type: :boolean,
default: true,
full_name: N_('Global Resource Quota no action'),
description: N_('Take no action when a resource quota is exceeded.')
description: N_('Take no action when a Resource Quota is exceeded.')
# Future: Overwrite quota-specific "out of resource"-action and take no ..
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/resource_quotas_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ResourceQuotasControllerTest < ActionController::TestCase
test 'should get index' do
get :index, session: set_session_user
assert_response :success
assert_select 'title', 'Resource quotas'
assert_select 'title', 'Resource Quotas'
end

test 'should destroy quota' do
Expand Down

0 comments on commit 0a0918f

Please sign in to comment.