foreman_resource_quota 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -6
  3. data/app/assets/javascripts/foreman_resource_quota/locale/bn/foreman_resource_quota.js +213 -0
  4. data/app/assets/javascripts/foreman_resource_quota/locale/bn_IN/foreman_resource_quota.js +214 -0
  5. data/app/assets/javascripts/foreman_resource_quota/locale/bqi/foreman_resource_quota.js +213 -0
  6. data/app/assets/javascripts/foreman_resource_quota/locale/ca/foreman_resource_quota.js +214 -0
  7. data/app/assets/javascripts/foreman_resource_quota/locale/cs_CZ/foreman_resource_quota.js +214 -0
  8. data/app/assets/javascripts/foreman_resource_quota/locale/de/foreman_resource_quota.js +214 -0
  9. data/app/assets/javascripts/foreman_resource_quota/locale/de_AT/foreman_resource_quota.js +213 -0
  10. data/app/assets/javascripts/foreman_resource_quota/locale/de_DE/foreman_resource_quota.js +214 -0
  11. data/app/assets/javascripts/foreman_resource_quota/locale/el/foreman_resource_quota.js +214 -0
  12. data/app/assets/javascripts/foreman_resource_quota/locale/en/foreman_resource_quota.js +214 -0
  13. data/app/assets/javascripts/foreman_resource_quota/locale/en_GB/foreman_resource_quota.js +214 -0
  14. data/app/assets/javascripts/foreman_resource_quota/locale/en_US/foreman_resource_quota.js +213 -0
  15. data/app/assets/javascripts/foreman_resource_quota/locale/es/foreman_resource_quota.js +214 -0
  16. data/app/assets/javascripts/foreman_resource_quota/locale/et_EE/foreman_resource_quota.js +213 -0
  17. data/app/assets/javascripts/foreman_resource_quota/locale/fr/foreman_resource_quota.js +214 -0
  18. data/app/assets/javascripts/foreman_resource_quota/locale/gl/foreman_resource_quota.js +214 -0
  19. data/app/assets/javascripts/foreman_resource_quota/locale/gu/foreman_resource_quota.js +214 -0
  20. data/app/assets/javascripts/foreman_resource_quota/locale/he_IL/foreman_resource_quota.js +213 -0
  21. data/app/assets/javascripts/foreman_resource_quota/locale/hi/foreman_resource_quota.js +214 -0
  22. data/app/assets/javascripts/foreman_resource_quota/locale/id/foreman_resource_quota.js +214 -0
  23. data/app/assets/javascripts/foreman_resource_quota/locale/it/foreman_resource_quota.js +214 -0
  24. data/app/assets/javascripts/foreman_resource_quota/locale/ja/foreman_resource_quota.js +214 -0
  25. data/app/assets/javascripts/foreman_resource_quota/locale/ka/foreman_resource_quota.js +214 -0
  26. data/app/assets/javascripts/foreman_resource_quota/locale/kn/foreman_resource_quota.js +214 -0
  27. data/app/assets/javascripts/foreman_resource_quota/locale/ko/foreman_resource_quota.js +214 -0
  28. data/app/assets/javascripts/foreman_resource_quota/locale/ml_IN/foreman_resource_quota.js +213 -0
  29. data/app/assets/javascripts/foreman_resource_quota/locale/mr/foreman_resource_quota.js +214 -0
  30. data/app/assets/javascripts/foreman_resource_quota/locale/nl_NL/foreman_resource_quota.js +214 -0
  31. data/app/assets/javascripts/foreman_resource_quota/locale/or/foreman_resource_quota.js +214 -0
  32. data/app/assets/javascripts/foreman_resource_quota/locale/pa/foreman_resource_quota.js +214 -0
  33. data/app/assets/javascripts/foreman_resource_quota/locale/pl/foreman_resource_quota.js +214 -0
  34. data/app/assets/javascripts/foreman_resource_quota/locale/pl_PL/foreman_resource_quota.js +213 -0
  35. data/app/assets/javascripts/foreman_resource_quota/locale/pt/foreman_resource_quota.js +213 -0
  36. data/app/assets/javascripts/foreman_resource_quota/locale/pt_BR/foreman_resource_quota.js +214 -0
  37. data/app/assets/javascripts/foreman_resource_quota/locale/ro/foreman_resource_quota.js +213 -0
  38. data/app/assets/javascripts/foreman_resource_quota/locale/ro_RO/foreman_resource_quota.js +213 -0
  39. data/app/assets/javascripts/foreman_resource_quota/locale/ru/foreman_resource_quota.js +214 -0
  40. data/app/assets/javascripts/foreman_resource_quota/locale/sl/foreman_resource_quota.js +214 -0
  41. data/app/assets/javascripts/foreman_resource_quota/locale/sv_SE/foreman_resource_quota.js +214 -0
  42. data/app/assets/javascripts/foreman_resource_quota/locale/ta/foreman_resource_quota.js +213 -0
  43. data/app/assets/javascripts/foreman_resource_quota/locale/ta_IN/foreman_resource_quota.js +214 -0
  44. data/app/assets/javascripts/foreman_resource_quota/locale/te/foreman_resource_quota.js +214 -0
  45. data/app/assets/javascripts/foreman_resource_quota/locale/tr/foreman_resource_quota.js +213 -0
  46. data/app/assets/javascripts/foreman_resource_quota/locale/vi/foreman_resource_quota.js +213 -0
  47. data/app/assets/javascripts/foreman_resource_quota/locale/vi_VN/foreman_resource_quota.js +213 -0
  48. data/app/assets/javascripts/foreman_resource_quota/locale/zh/foreman_resource_quota.js +213 -0
  49. data/app/assets/javascripts/foreman_resource_quota/locale/zh_CN/foreman_resource_quota.js +214 -0
  50. data/app/assets/javascripts/foreman_resource_quota/locale/zh_TW/foreman_resource_quota.js +214 -0
  51. data/app/controllers/foreman_resource_quota/api/v2/resource_quotas_controller.rb +17 -10
  52. data/app/controllers/foreman_resource_quota/concerns/api/v2/hosts_controller_extensions.rb +20 -0
  53. data/app/controllers/foreman_resource_quota/concerns/api/v2/usergroups_controller_extensions.rb +19 -0
  54. data/app/controllers/foreman_resource_quota/concerns/api/v2/users_controller_extensions.rb +22 -0
  55. data/app/models/concerns/foreman_resource_quota/host_managed_extensions.rb +9 -7
  56. data/app/views/foreman_resource_quota/api/v2/users/resource_quota.json.rabl +1 -1
  57. data/app/views/foreman_resource_quota/resource_quotas/index.html.erb +1 -1
  58. data/config/initializers/inflections.rb +1 -0
  59. data/lib/foreman_resource_quota/engine.rb +8 -1
  60. data/lib/foreman_resource_quota/register.rb +4 -2
  61. data/lib/foreman_resource_quota/version.rb +1 -1
  62. data/lib/tasks/foreman_resource_quota_tasks.rake +3 -3
  63. data/locale/Makefile +19 -6
  64. data/locale/bn/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  65. data/locale/bn/foreman_resource_quota.po +214 -0
  66. data/locale/bn_IN/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  67. data/locale/bn_IN/foreman_resource_quota.po +219 -0
  68. data/locale/bqi/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  69. data/locale/bqi/foreman_resource_quota.po +215 -0
  70. data/locale/ca/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  71. data/locale/ca/foreman_resource_quota.po +218 -0
  72. data/locale/cs_CZ/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  73. data/locale/cs_CZ/foreman_resource_quota.po +221 -0
  74. data/locale/de/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  75. data/locale/de/foreman_resource_quota.po +223 -0
  76. data/locale/de_AT/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  77. data/locale/de_AT/foreman_resource_quota.po +215 -0
  78. data/locale/de_DE/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  79. data/locale/de_DE/foreman_resource_quota.po +219 -0
  80. data/locale/el/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  81. data/locale/el/foreman_resource_quota.po +218 -0
  82. data/locale/en/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  83. data/locale/en/foreman_resource_quota.po +207 -9
  84. data/locale/en_GB/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  85. data/locale/en_GB/foreman_resource_quota.po +220 -0
  86. data/locale/en_US/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  87. data/locale/en_US/foreman_resource_quota.po +215 -0
  88. data/locale/es/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  89. data/locale/es/foreman_resource_quota.po +223 -0
  90. data/locale/et_EE/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  91. data/locale/et_EE/foreman_resource_quota.po +215 -0
  92. data/locale/foreman_resource_quota.pot +322 -8
  93. data/locale/fr/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  94. data/locale/fr/foreman_resource_quota.po +222 -0
  95. data/locale/gl/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  96. data/locale/gl/foreman_resource_quota.po +218 -0
  97. data/locale/gu/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  98. data/locale/gu/foreman_resource_quota.po +218 -0
  99. data/locale/he_IL/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  100. data/locale/he_IL/foreman_resource_quota.po +216 -0
  101. data/locale/hi/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  102. data/locale/hi/foreman_resource_quota.po +218 -0
  103. data/locale/id/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  104. data/locale/id/foreman_resource_quota.po +218 -0
  105. data/locale/it/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  106. data/locale/it/foreman_resource_quota.po +221 -0
  107. data/locale/ja/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  108. data/locale/ja/foreman_resource_quota.po +219 -0
  109. data/locale/ka/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  110. data/locale/ka/foreman_resource_quota.po +218 -0
  111. data/locale/kn/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  112. data/locale/kn/foreman_resource_quota.po +218 -0
  113. data/locale/ko/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  114. data/locale/ko/foreman_resource_quota.po +220 -0
  115. data/locale/ml_IN/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  116. data/locale/ml_IN/foreman_resource_quota.po +215 -0
  117. data/locale/mr/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  118. data/locale/mr/foreman_resource_quota.po +218 -0
  119. data/locale/nl_NL/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  120. data/locale/nl_NL/foreman_resource_quota.po +223 -0
  121. data/locale/or/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  122. data/locale/or/foreman_resource_quota.po +218 -0
  123. data/locale/pa/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  124. data/locale/pa/foreman_resource_quota.po +219 -0
  125. data/locale/pl/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  126. data/locale/pl/foreman_resource_quota.po +221 -0
  127. data/locale/pl_PL/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  128. data/locale/pl_PL/foreman_resource_quota.po +217 -0
  129. data/locale/pt/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  130. data/locale/pt/foreman_resource_quota.po +215 -0
  131. data/locale/pt_BR/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  132. data/locale/pt_BR/foreman_resource_quota.po +222 -0
  133. data/locale/ro/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  134. data/locale/ro/foreman_resource_quota.po +215 -0
  135. data/locale/ro_RO/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  136. data/locale/ro_RO/foreman_resource_quota.po +216 -0
  137. data/locale/ru/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  138. data/locale/ru/foreman_resource_quota.po +222 -0
  139. data/locale/sl/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  140. data/locale/sl/foreman_resource_quota.po +219 -0
  141. data/locale/sv_SE/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  142. data/locale/sv_SE/foreman_resource_quota.po +221 -0
  143. data/locale/ta/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  144. data/locale/ta/foreman_resource_quota.po +214 -0
  145. data/locale/ta_IN/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  146. data/locale/ta_IN/foreman_resource_quota.po +219 -0
  147. data/locale/te/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  148. data/locale/te/foreman_resource_quota.po +218 -0
  149. data/locale/tr/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  150. data/locale/tr/foreman_resource_quota.po +214 -0
  151. data/locale/vi/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  152. data/locale/vi/foreman_resource_quota.po +214 -0
  153. data/locale/vi_VN/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  154. data/locale/vi_VN/foreman_resource_quota.po +215 -0
  155. data/locale/zh/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  156. data/locale/zh/foreman_resource_quota.po +214 -0
  157. data/locale/zh_CN/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  158. data/locale/zh_CN/foreman_resource_quota.po +221 -0
  159. data/locale/zh_TW/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  160. data/locale/zh_TW/foreman_resource_quota.po +220 -0
  161. data/package.json +10 -10
  162. data/webpack/components/ResourceQuotaEmptyState/__test__/ResourceQuotaEmptyState.test.js +35 -0
  163. data/webpack/components/ResourceQuotaEmptyState/__test__/__snapshots__/ResourceQuotaEmptyState.test.js.snap +80 -0
  164. data/webpack/components/ResourceQuotaEmptyState/index.js +20 -3
  165. data/webpack/components/ResourceQuotaForm/ResourceQuotaFormConstants.js +6 -6
  166. data/webpack/components/ResourceQuotaForm/components/Properties/TextInputField.js +1 -1
  167. data/webpack/components/ResourceQuotaForm/components/Properties/index.js +1 -1
  168. data/webpack/components/ResourceQuotaForm/components/Resource/UnitInputField.js +23 -21
  169. data/webpack/components/ResourceQuotaForm/components/Resource/__test__/UnitInputField.test.js +108 -0
  170. data/webpack/components/ResourceQuotaForm/components/Resource/__test__/__snapshots__/UnitInputField.test.js.snap +155 -0
  171. data/webpack/components/ResourceQuotaForm/components/Resource/index.js +1 -1
  172. data/webpack/components/ResourceQuotaForm/components/Submit.js +1 -1
  173. data/webpack/test_helper.js +49 -0
  174. metadata +158 -7
@@ -0,0 +1,214 @@
1
+ locales['foreman_resource_quota'] = locales['foreman_resource_quota'] || {}; locales['foreman_resource_quota']['zh_TW'] = {
2
+ "domain": "foreman_resource_quota",
3
+ "locale_data": {
4
+ "foreman_resource_quota": {
5
+ "": {
6
+ "Project-Id-Version": "foreman_resource_quota 0.3.1",
7
+ "Report-Msgid-Bugs-To": "",
8
+ "PO-Revision-Date": "2025-01-07 14:34+0000",
9
+ "Last-Translator": "Bryan Kearney <bryan.kearney@gmail.com>, 2025",
10
+ "Language-Team": "Chinese (Taiwan) (https://app.transifex.com/foreman/teams/114/zh_TW/)",
11
+ "MIME-Version": "1.0",
12
+ "Content-Type": "text/plain; charset=UTF-8",
13
+ "Content-Transfer-Encoding": "8bit",
14
+ "Language": "zh_TW",
15
+ "Plural-Forms": "nplurals=1; plural=0;",
16
+ "lang": "zh_TW",
17
+ "domain": "foreman_resource_quota",
18
+ "plural_forms": "nplurals=1; plural=0;"
19
+ },
20
+ " ${response.response.data.error.full_messages}": [
21
+ ""
22
+ ],
23
+ "${label}": [
24
+ ""
25
+ ],
26
+ "${label} *": [
27
+ ""
28
+ ],
29
+ "${selectedUnit.symbol}": [
30
+ ""
31
+ ],
32
+ "Actions": [
33
+ "動作"
34
+ ],
35
+ "Apply": [
36
+ "套用"
37
+ ],
38
+ "CPU cores": [
39
+ ""
40
+ ],
41
+ "Click on \\\\\\\"Fetch quota utilization\\\\\\\": ": [
42
+ ""
43
+ ],
44
+ "Consumed resources": [
45
+ ""
46
+ ],
47
+ "Create a Resource Quota": [
48
+ ""
49
+ ],
50
+ "Create resource quota": [
51
+ ""
52
+ ],
53
+ "Define a Resource Quota here and apply it to users to guarantee a fair share of your resources.": [
54
+ ""
55
+ ],
56
+ "Define the Resource Quota this host counts to.": [
57
+ ""
58
+ ],
59
+ "Delete %s?": [
60
+ "刪除 %s?"
61
+ ],
62
+ "Delete a Resource Quota": [
63
+ ""
64
+ ],
65
+ "Description": [
66
+ "描述"
67
+ ],
68
+ "Description of the Resource Quota": [
69
+ ""
70
+ ],
71
+ "Disk space (GB)": [
72
+ ""
73
+ ],
74
+ "Edit": [
75
+ "編輯"
76
+ ],
77
+ "Edit Resource Quota %s": [
78
+ ""
79
+ ],
80
+ "Edit: ${quotaProperties[RESOURCE_IDENTIFIER_NAME]}": [
81
+ ""
82
+ ],
83
+ "Fetch quota utilization": [
84
+ ""
85
+ ],
86
+ "Foreman Plug-in to manage resource usage among users.": [
87
+ ""
88
+ ],
89
+ "Global Resource Quota no action": [
90
+ ""
91
+ ],
92
+ "It is optional for a user to assign a quota when creating new hosts": [
93
+ ""
94
+ ],
95
+ "List all Resource Quotas": [
96
+ ""
97
+ ],
98
+ "Make the assignment of a Resource Quota, during the host creation process, optional for\\n everyone. If this is true, user-specific \\\"optional assignment\\\" configurations are neglected.": [
99
+ ""
100
+ ],
101
+ "Maximum disk space in GiB": [
102
+ ""
103
+ ],
104
+ "Maximum memory in MiB": [
105
+ ""
106
+ ],
107
+ "Maximum number of CPU cores": [
108
+ ""
109
+ ],
110
+ "Memory (MB)": [
111
+ ""
112
+ ],
113
+ "Name": [
114
+ "名稱"
115
+ ],
116
+ "Name of the Resource Quota": [
117
+ ""
118
+ ],
119
+ "New Resource Quota": [
120
+ ""
121
+ ],
122
+ "New quota - no consumption to display.": [
123
+ ""
124
+ ],
125
+ "No consumption to display.": [
126
+ ""
127
+ ],
128
+ "No floating point for smallest unit (${units[0].symbol}).": [
129
+ ""
130
+ ],
131
+ "None provided": [
132
+ ""
133
+ ],
134
+ "Optional Assignment": [
135
+ ""
136
+ ],
137
+ "Properties": [
138
+ ""
139
+ ],
140
+ "Quota Limit": [
141
+ ""
142
+ ],
143
+ "Quotas from user groups": [
144
+ ""
145
+ ],
146
+ "Resource Quota": [
147
+ ""
148
+ ],
149
+ "Resource Quota ID.\\n This field is required if the setting `resource_quota_optional_assignment` is set to false.": [
150
+ ""
151
+ ],
152
+ "Resource Quota IDs to be associated with this user group. ": [
153
+ ""
154
+ ],
155
+ "Resource Quota IDs to be associated with this user. ": [
156
+ ""
157
+ ],
158
+ "Resource Quota optional assignment": [
159
+ ""
160
+ ],
161
+ "Resource Quotas": [
162
+ ""
163
+ ],
164
+ "Resource Quotas help admins to manage resources including CPUs, memory, and disk space among users or user groups.": [
165
+ ""
166
+ ],
167
+ "Resource Quota|Name": [
168
+ ""
169
+ ],
170
+ "Show Resource Quota": [
171
+ ""
172
+ ],
173
+ "Show hosts of a Resource Quota": [
174
+ ""
175
+ ],
176
+ "Show resources could not be determined when calculating utilization": [
177
+ ""
178
+ ],
179
+ "Show used resources of assigned hosts": [
180
+ ""
181
+ ],
182
+ "Show usergroups of a Resource Quota": [
183
+ ""
184
+ ],
185
+ "Show users of a Resource Quota": [
186
+ ""
187
+ ],
188
+ "Take no action when a Resource Quota is exceeded.": [
189
+ ""
190
+ ],
191
+ "The total amount of ${resourceTitle} for this quota.": [
192
+ ""
193
+ ],
194
+ "This can take some time since the resources of every host, assigned to this quota, must be requested.": [
195
+ ""
196
+ ],
197
+ "This group has no quotas": [
198
+ ""
199
+ ],
200
+ "Total ${resourceTitle} currently in use by all hosts assigned to this quota.": [
201
+ ""
202
+ ],
203
+ "Update a Resource Quota": [
204
+ ""
205
+ ],
206
+ "Value must be a natural number.": [
207
+ ""
208
+ ],
209
+ "When set to \\\"true\\\", it is optional for a user to assign a quota when creating new hosts.\\n The default value is \\\"false\\\".": [
210
+ ""
211
+ ]
212
+ }
213
+ }
214
+ };
@@ -11,19 +11,23 @@ module ForemanResourceQuota
11
11
  resource_id 'resource_quota'
12
12
  api_version 'v2'
13
13
  api_base_url '/foreman_resource_quota/api'
14
+ # resource quota are not bound to org/loc - so we remove the parameters from api here
15
+ # loc/org are inherited from the ::Api::V2::BaseController in Foreman
16
+ param :location_id, Integer, show: false
17
+ param :organization_id, Integer, show: false
14
18
  end
15
19
 
16
20
  before_action :find_resource, only: %i[show update destroy]
17
21
  before_action :custom_find_resource, only: %i[utilization missing_hosts hosts users usergroups]
18
22
 
19
- api :GET, '/resource_quotas', N_('List all resource quotas')
23
+ api :GET, '/resource_quotas', N_('List all Resource Quotas')
20
24
  param_group :search_and_pagination, ::Api::V2::BaseController
21
25
  add_scoped_search_description_for(ForemanResourceQuota::ResourceQuota)
22
26
  def index
23
27
  @resource_quotas = resource_scope_for_index
24
28
  end
25
29
 
26
- api :GET, '/resource_quotas/:id/', N_('Show resource quota')
30
+ api :GET, '/resource_quotas/:id/', N_('Show Resource Quota')
27
31
  param :id, :identifier, required: true
28
32
  def show
29
33
  end
@@ -39,23 +43,22 @@ module ForemanResourceQuota
39
43
  N_('Show resources could not be determined when calculating utilization')
40
44
  param :id, :identifier, required: true
41
45
  def missing_hosts
42
- @resource_quota.determine_utilization
43
46
  process_response @resource_quota
44
47
  end
45
48
 
46
- api :GET, '/resource_quotas/:id/hosts', N_('Show hosts of a resource quota')
49
+ api :GET, '/resource_quotas/:id/hosts', N_('Show hosts of a Resource Quota')
47
50
  param :id, :identifier, required: true
48
51
  def hosts
49
52
  process_response @resource_quota.hosts
50
53
  end
51
54
 
52
- api :GET, '/resource_quotas/:id/users', N_('Show users of a resource quota')
55
+ api :GET, '/resource_quotas/:id/users', N_('Show users of a Resource Quota')
53
56
  param :id, :identifier, required: true
54
57
  def users
55
58
  process_response @resource_quota.users
56
59
  end
57
60
 
58
- api :GET, '/resource_quotas/:id/usergroups', N_('Show usergroups of a resource quota')
61
+ api :GET, '/resource_quotas/:id/usergroups', N_('Show usergroups of a Resource Quota')
59
62
  param :id, :identifier, required: true
60
63
  def usergroups
61
64
  process_response @resource_quota.usergroups
@@ -63,25 +66,29 @@ module ForemanResourceQuota
63
66
 
64
67
  def_param_group :resource_quota do
65
68
  param :resource_quota, Hash, required: true, action_aware: true do
66
- param :name, String, required: true
69
+ param :name, String, required: true, desc: N_('Name of the Resource Quota')
70
+ param :description, String, required: false, desc: N_('Description of the Resource Quota')
71
+ param :cpu_cores, Integer, required: false, desc: N_('Maximum number of CPU cores')
72
+ param :memory_mb, Integer, required: false, desc: N_('Maximum memory in MiB')
73
+ param :disk_gb, Integer, required: false, desc: N_('Maximum disk space in GiB')
67
74
  end
68
75
  end
69
76
 
70
- api :POST, '/resource_quotas/', N_('Create a resource quota')
77
+ api :POST, '/resource_quotas/', N_('Create a Resource Quota')
71
78
  param_group :resource_quota, as: :create
72
79
  def create
73
80
  @resource_quota = ForemanResourceQuota::ResourceQuota.new(resource_quota_params)
74
81
  process_response @resource_quota.save
75
82
  end
76
83
 
77
- api :PUT, '/resource_quotas/:id/', N_('Update a resource quota')
84
+ api :PUT, '/resource_quotas/:id/', N_('Update a Resource Quota')
78
85
  param :id, :identifier, required: true
79
86
  param_group :resource_quota
80
87
  def update
81
88
  process_response @resource_quota.update(resource_quota_params)
82
89
  end
83
90
 
84
- api :DELETE, '/resource_quotas/:id/', N_('Delete a resource quota')
91
+ api :DELETE, '/resource_quotas/:id/', N_('Delete a Resource Quota')
85
92
  param :id, :identifier, required: true
86
93
  def destroy
87
94
  process_response @resource_quota.destroy
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanResourceQuota
4
+ module Concerns
5
+ module Api
6
+ module V2
7
+ module HostsControllerExtensions
8
+ extend ::Apipie::DSL::Concern
9
+ update_api(:create, :update) do
10
+ param :host, Hash do
11
+ param :resource_quota_id, :number, required: false,
12
+ desc: N_('Resource Quota ID.
13
+ This field is required if the setting `resource_quota_optional_assignment` is set to false.')
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanResourceQuota
4
+ module Concerns
5
+ module Api
6
+ module V2
7
+ module UsergroupsControllerExtensions
8
+ extend ::Apipie::DSL::Concern
9
+ update_api(:create, :update) do
10
+ param :usergroup, Hash do
11
+ param :resource_quota_ids, Array, of: :number, required: false,
12
+ desc: N_('Resource Quota IDs to be associated with this user group. ')
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanResourceQuota
4
+ module Concerns
5
+ module Api
6
+ module V2
7
+ module UsersControllerExtensions
8
+ extend ::Apipie::DSL::Concern
9
+ update_api(:create, :update) do
10
+ param :user, Hash do
11
+ param :resource_quota_ids, Array, of: :number, required: false,
12
+ desc: N_('Resource Quota IDs to be associated with this user. ')
13
+ param :resource_quota_is_optional, :bool,
14
+ desc: N_('When set to "true", it is optional for a user to assign a quota when creating new hosts.
15
+ The default value is "false".')
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -19,7 +19,7 @@ module ForemanResourceQuota
19
19
 
20
20
  # A host shall always have a .host_resources attribute
21
21
  before_validation :build_host_resources, unless: -> { host_resources.present? }
22
- after_save :save_host_resources, if: -> { host_resources.changed? }
22
+ after_save :save_host_resources, if: -> { host_resources&.changed? }
23
23
  end
24
24
 
25
25
  def verify_resource_quota
@@ -28,15 +28,15 @@ module ForemanResourceQuota
28
28
  rescue ResourceQuotaException => e
29
29
  handle_error('resource_quota_id',
30
30
  e.bare_message,
31
- format('An error occured while checking the resource quota capacity: %s', e))
31
+ format('An error occured while checking the Resource Quota capacity: %s', e))
32
32
  rescue Foreman::Exception => e
33
33
  handle_error(:base,
34
34
  e.bare_message,
35
- format('An unexpected Foreman error occured while checking the resource quota capacity: %s', e))
35
+ format('An unexpected Foreman error occured while checking the Resource Quota capacity: %s', e))
36
36
  rescue StandardError => e
37
37
  handle_error(:base,
38
38
  e.message,
39
- format('An unknown error occured while checking the resource quota capacity: %s', e))
39
+ format('An unknown error occured while checking the Resource Quota capacity: %s', e))
40
40
  end
41
41
 
42
42
  def resource_quota_id
@@ -124,8 +124,8 @@ module ForemanResourceQuota
124
124
  end
125
125
 
126
126
  def formulate_quota_inconsistency_error(quota_name)
127
- N_("An error occured adapting the resource quota utilization of '#{quota_name}' " \
128
- "while processing host '#{name}'. The resource quota utilization values might be inconsistent.")
127
+ N_("An error occured adapting the Resource Quota utilization of '#{quota_name}' " \
128
+ "while processing host '#{name}'. The Resource Quota utilization values might be inconsistent.")
129
129
  end
130
130
 
131
131
  def early_return?(quota)
@@ -139,7 +139,9 @@ module ForemanResourceQuota
139
139
  end
140
140
 
141
141
  def quota_assigment_optional?
142
- owner.resource_quota_is_optional || Setting[:resource_quota_optional_assignment]
142
+ return true if Setting[:resource_quota_optional_assignment]
143
+ return true if owner.respond_to?(:resource_quota_is_optional) && owner.resource_quota_is_optional
144
+ false
143
145
  end
144
146
 
145
147
  def save_host_resources
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- attribute :resource_quota_ids, :resource_quota_names
3
+ attributes :resource_quota_ids, :resource_quota_names, :resource_quota_is_optional
@@ -5,7 +5,7 @@
5
5
  <%= webpacked_plugins_css_for :foreman_resource_quota %>
6
6
  <% end %>
7
7
 
8
- <% title _('Resource quotas') %>
8
+ <% title _('Resource Quotas') %>
9
9
 
10
10
  <%= title_actions react_component('CreateResourceQuotaModal') %>
11
11
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  ActiveSupport::Inflector.inflections do |inflect|
4
4
  inflect.irregular 'resource_quota', 'resource_quotas'
5
+ inflect.irregular 'ResourceQuota', 'ResourceQuotas'
5
6
  inflect.irregular 'host_resources', 'hosts_resources'
6
7
  inflect.irregular 'HostResources', 'HostsResources'
7
8
  end
@@ -40,12 +40,19 @@ module ForemanResourceQuota
40
40
  ::User.include ForemanResourceQuota::UserExtensions
41
41
  ::Usergroup.include ForemanResourceQuota::UsergroupExtensions
42
42
  ::Host::Managed.include ForemanResourceQuota::HostManagedExtensions
43
+
44
+ # Api controller extensions
45
+ ::Api::V2::HostsController.include ForemanResourceQuota::Concerns::Api::V2::HostsControllerExtensions
46
+ ::Api::V2::UsersController.include ForemanResourceQuota::Concerns::Api::V2::UsersControllerExtensions
47
+ ::Api::V2::UsergroupsController.include ForemanResourceQuota::Concerns::Api::V2::UsergroupsControllerExtensions
43
48
  rescue StandardError => e
44
49
  Rails.logger.warn "ForemanResourceQuota: skipping engine hook (#{e})"
45
50
  end
46
51
 
47
52
  # Register ForemanTasks-based recurring logic/scheduled tasks
48
- initializer 'foreman_resource_quota.register_scheduled_tasks', before: :finisher_hook do |_app|
53
+ initializer 'foreman_resource_quota.register_scheduled_tasks',
54
+ before: :finisher_hook,
55
+ after: :build_middleware_stack do |_app| # ForemanTasks::Task becomes only available after this hook
49
56
  action_paths = [ForemanResourceQuota::Engine.root.join('lib/foreman_resource_quota/async')]
50
57
  ::ForemanTasks.dynflow.config.eager_load_paths.concat(action_paths)
51
58
 
@@ -7,6 +7,8 @@ Foreman::Plugin.register :foreman_resource_quota do
7
7
  apipie_documented_controllers ["#{ForemanResourceQuota::Engine.root}" \
8
8
  '/app/controllers/foreman_resource_quot/api/v2/*.rb']
9
9
 
10
+ register_gettext
11
+
10
12
  # Add permissions
11
13
  security_block :foreman_resource_quota do
12
14
  permission :view_resource_quotas,
@@ -93,13 +95,13 @@ Foreman::Plugin.register :foreman_resource_quota do
93
95
  type: :boolean,
94
96
  default: false,
95
97
  full_name: N_('Resource Quota optional assignment'),
96
- description: N_('Make the assignment of a Resource quota, during the host creation process, optional for
98
+ description: N_('Make the assignment of a Resource Quota, during the host creation process, optional for
97
99
  everyone. If this is true, user-specific "optional assignment" configurations are neglected.')
98
100
  setting 'resource_quota_global_no_action',
99
101
  type: :boolean,
100
102
  default: true,
101
103
  full_name: N_('Global Resource Quota no action'),
102
- description: N_('Take no action when a resource quota is exceeded.')
104
+ description: N_('Take no action when a Resource Quota is exceeded.')
103
105
  # Future: Overwrite quota-specific "out of resource"-action and take no ..
104
106
  end
105
107
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanResourceQuota
4
- VERSION = '0.3.1'
4
+ VERSION = '0.4.0'
5
5
  end
@@ -16,10 +16,10 @@ end
16
16
  namespace :test do
17
17
  desc 'Test ForemanResourceQuota'
18
18
  Rake::TestTask.new(:foreman_resource_quota) do |t|
19
- test_dir = File.expand_path('../../test', __dir__)
20
- t.libs << 'test'
21
- t.libs << test_dir
19
+ test_dir = File.join(__dir__, '..', '..', 'test')
20
+ t.libs << ['test', test_dir]
22
21
  t.pattern = "#{test_dir}/**/*_test.rb"
22
+ t.test_files = [Rails.root.join('test/unit/foreman/access_permissions_test.rb')]
23
23
  t.verbose = true
24
24
  t.warning = false
25
25
  end
data/locale/Makefile CHANGED
@@ -6,14 +6,15 @@
6
6
  # make tx-update - download and merge translations from Transifex
7
7
  # make clean - clean everything
8
8
  #
9
- DOMAIN = foreman_resource_quota
10
- VERSION = $(shell ruby -e 'require "rubygems";spec = Gem::Specification::load(Dir.glob("../*.gemspec")[0]);puts spec.version')
9
+ DOMAIN = $(shell ruby -rrubygems -e 'puts Gem::Specification::load(Dir.glob("../*.gemspec")[0]).name')
10
+ VERSION = $(shell ruby -rrubygems -e 'puts Gem::Specification::load(Dir.glob("../*.gemspec")[0]).version')
11
11
  POTFILE = $(DOMAIN).pot
12
12
  MOFILE = $(DOMAIN).mo
13
13
  POFILES = $(shell find . -name '$(DOMAIN).po')
14
14
  MOFILES = $(patsubst %.po,%.mo,$(POFILES))
15
15
  POXFILES = $(patsubst %.po,%.pox,$(POFILES))
16
16
  EDITFILES = $(patsubst %.po,%.edit.po,$(POFILES))
17
+ JSFILES = $(shell find ../app/assets/javascripts/*/locale -name '$(DOMAIN).js')
17
18
 
18
19
  %.mo: %.po
19
20
  mkdir -p $(shell dirname $@)/LC_MESSAGES
@@ -30,9 +31,16 @@ all-mo: $(MOFILES)
30
31
  cat $@
31
32
  ! grep -q msgid $@
32
33
 
33
- %.edit.po:
34
+ %.edit.po: %.po.time_stamp
34
35
  touch $@
35
36
 
37
+ # gettext will trash the .edit.po file if the time stamp doesn't exist or is older than the po file
38
+ %.po.time_stamp: %.po
39
+ touch --reference $< $@
40
+
41
+ # Prevent make from treating this as an intermediate file to be cleaned up
42
+ .PRECIOUS: %.po.time_stamp
43
+
36
44
  check: $(POXFILES)
37
45
 
38
46
  # Unify duplicate translations
@@ -42,18 +50,23 @@ uniq-po:
42
50
  done
43
51
 
44
52
  tx-pull: $(EDITFILES)
45
- tx pull -f
53
+ # Initialize new languages
54
+ cd .. && tx pull -f --all --minimum-perc 50
55
+ # Force update all existing languages
56
+ cd .. && tx pull -f --minimum-perc 0
46
57
  for f in $(EDITFILES) ; do \
47
58
  sed -i 's/^\("Project-Id-Version: \).*$$/\1$(DOMAIN) $(VERSION)\\n"/' $$f; \
48
59
  done
49
60
 
50
61
  tx-update: tx-pull
51
62
  @echo
52
- @echo Run rake plugin:gettext[$(DOMAIN)] from the Foreman installation, then make -C locale mo-files to finish
63
+ @echo Run rake plugin:gettext[$(DOMAIN)] from the Foreman installation
64
+ @echo then run rake plugin:po_to_json[$(DOMAIN)] from the Foreman installation
65
+ @echo then run make -C locale mo-files to finish
53
66
  @echo
54
67
 
55
68
  mo-files: $(MOFILES)
56
- git add $(POFILES) $(POTFILE) ../locale/*/LC_MESSAGES
69
+ git add $(POFILES) $(POTFILE) $(JSFILES) ../locale/*/LC_MESSAGES
57
70
  git commit -m "i18n - pulling from tx"
58
71
  @echo
59
72
  @echo Changes commited!