Skip to content

Commit

Permalink
Limit host resources via Hammer CLI
Browse files Browse the repository at this point in the history
* Add command to install Hammer CLI plugin for foreman_resource_quota
* Use Hammer CLI to assign resource quotes to users
* Use Hammer CLI to manage resource quotas

Refs PR 97 in foreman_resource_quota on GitHub
Refs https://github.com/ATIX-AG/hammer-cli-foreman-resource-quota/
  • Loading branch information
maximiliankolb committed Jan 17, 2025
1 parent debb06a commit 570ebdf
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,34 @@

You can assign resource quotas to a user group to limit the resource consumption of that {Project} user group.
All users of the user group share the pool of resources.
To use the CLI instead of the {ProjectWebUI}, see the xref:cli-assigning-resource-quotas-to-a-user-group[].

.Procedure
. In the {ProjectWebUI}, navigate to *Administer* > *User Groups*.
. On the *Resource Quota* tab, assign resource quotas to the user group.
. Click *Submit* to assign resource quotas to a user group.

[id="cli-assigning-resource-quotas-to-a-user-group"]
.CLI procedure
. Optional: List all {Project} user groups:
+
[options="nowrap", subs="verbatim,quotes,attributes"]
----
$ hammer user-group list --fields id,name
----
. Optional: List all resource quotas:
+
[options="nowrap", subs="verbatim,quotes,attributes"]
----
$ hammer resource-quota list --fields id,name
----
. Assign resource quotas to a user group:
+
[options="nowrap", subs="verbatim,quotes,attributes"]
----
$ hammer user-group update \
--id _My_User_Group_ID_ \
--resource-quota-ids _My_Resource_Quota_IDs_
----
+
For all options, see `hammer user-group --help`.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
= Assigning resource quotas to a user

You can assign resource quotas to a user to limit the resource consumption of that {Project} user.
To use the CLI instead of the {ProjectWebUI}, see the xref:cli-assigning-resource-quotas-to-a-user[].

.Procedure
. In the {ProjectWebUI}, navigate to *Administer* > *Users*.
Expand All @@ -11,3 +12,29 @@ You can assign resource quotas to a user to limit the resource consumption of th
+
This means that {Project} will not prevent users from consuming more resources than their assigned quota.
. Click *Submit* to assign resource quotas to a user.

[id="cli-assigning-resource-quotas-to-a-user"]
.CLI procedure
. Optional: List all {Project} users:
+
[options="nowrap", subs="verbatim,quotes,attributes"]
----
$ hammer user list --fields id,login
----
. Optional: List all resource quotas:
+
[options="nowrap", subs="verbatim,quotes,attributes"]
----
$ hammer resource-quota list --fields id,name
----
. Assign resource quotas to a user:
+
[options="nowrap", subs="verbatim,quotes,attributes"]
----
$ hammer user update \
--id _My_User_ID_ \
--resource-quota-ids _My_Resource_Quota_IDs_ \
--resource-quota-is-optional _{true|false}_
----
+
For all options, see `hammer user --help`.
16 changes: 16 additions & 0 deletions guides/common/modules/proc_creating-a-resource-quota.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,25 @@
= Creating a resource quota

Create a resource quota to limit the resource consumption of {Project} users.
To use the CLI instead of the {ProjectWebUI}, see the xref:cli-creating-a-resource-quota[].

.Procedure
. In the {ProjectWebUI}, navigate to *Configure* > *Resource Quotas*.
. Click *Create resource quota*.
. Specify the name, CPU cores, memory, and disk space.
. Click *Create resource quota* to submit the resource quota to {Project}.

[id="cli-creating-a-resource-quota"]
.CLI procedure
* Create a resource quota:
+
[options="nowrap", subs="verbatim,quotes,attributes"]
----
$ hammer resource-quota create \
--cpu-cores _My_CPU_Cores_ \
--disk-space _My_Disk_Space_in_GiB_ \
--memory _My_Memory_in_MiB_ \
--name "_My_Resource_Quota_Name_"
----
+
For all options, see `hammer resource-quota create --help`.
18 changes: 18 additions & 0 deletions guides/common/modules/proc_deleting-a-resource-quota.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,25 @@
= Deleting a resource quota

You can delete a resource quota from {Project}.
To use the CLI instead of the {ProjectWebUI}, see the xref:cli-deleting-a-resource-quota[].

.Procedure
. In the {ProjectWebUI}, navigate to *Configure* > *Resource Quotas*.
. In the *Actions* column, click *Delete* for your resource quota.

[id="cli-deleting-a-resource-quota"]
.CLI procedure
. Optional: List all resource quotas:
+
[options="nowrap", subs="verbatim,quotes,attributes"]
----
$ hammer resource-quota list --fields id,name
----
. Delete a resource quota:
+
[options="nowrap", subs="verbatim,quotes,attributes"]
----
$ hammer resource-quota delete --id _My_Resource_Quota_ID_
----
+
For all options, see `hammer resource-quota delete --help`.
26 changes: 26 additions & 0 deletions guides/common/modules/proc_editing-a-resource-quota.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,35 @@
= Editing a resource quota

You can edit a resource quota to adjust available resources to {Project} users.
To use the CLI instead of the {ProjectWebUI}, see the xref:cli-editing-a-resource-quota[].

.Procedure
. In the {ProjectWebUI}, navigate to *Configure* > *Resource Quotas*.
. Select your resource quota.
. Adjust the *CPU cores*, *Memory*, or *Disk space* and click *Apply* to submit your changes to {Project}.
. Click *Create resource quota* to submit the resource quota to {Project}.

[id="cli-editing-a-resource-quota"]
.CLI procedure
. Optional: List all resource quotas:
+
[options="nowrap", subs="verbatim,quotes,attributes"]
----
$ hammer resource-quota list --fields id,name
----
. Edit a resource quota:
+
[options="nowrap", subs="verbatim,quotes,attributes"]
----
$ hammer resource-quota update \
--cpu-cores _My_CPU_Cores_ \
--disk-space _My_Disk_Space_in_GiB_ \
--id _My_Resource_Quota_ID_ \
--memory _My_Memory_in_MiB_ \
--name "_My_Resource_Quota_Name_"
----
+
If you set the value to `0`, users cannot consume any resource at all.
To reset resource quotas, you can use `--remove-cpu-core-limit`, `--remove-disk-space-limit`, and `--remove-memory-limit`.
+
For all options, see `hammer resource-quota update --help`.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@
To limit host resources for your {Project} users, install the Resource Quota plugin.

.Procedure
* Install the plugin on your {ProjectServer}:
. Install the plugin on your {ProjectServer}:
+
[options="nowrap", subs="+quotes,verbatim,attributes"]
----
# {foreman-installer} --enable-foreman-plugin-resource-quota
----
// TODO: As soon as you can install this via foreman-installer:
// # {foreman-installer} --enable-foreman-cli-resource-quota
. Optional: Install the Hammer CLI plugin on your {ProjectServer}:
+
[options="nowrap", subs="+quotes,verbatim,attributes"]
----
# {project-package-install} rubygem-hammer_cli_foreman_resource_quota
----

0 comments on commit 570ebdf

Please sign in to comment.