hammer_cli_foreman_resource_quota 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 187e58e0253c31ae050e968e2db0383c2b2a653a66e4c4891320ba8c69a83912
4
- data.tar.gz: 37b0ad55ea93acea85ce902bd59698431e3d1e90c4dc4b2d7602381e2e46f52f
3
+ metadata.gz: e90527b47b5267b58ca2ca6622b361d946dd1bccfa50a68fc381109815006817
4
+ data.tar.gz: b8e74e0e528333cc6e8202062d359b5c4122ed1f518be32416b8302f717f14dc
5
5
  SHA512:
6
- metadata.gz: 876479005613a1ff47bd37a839a73e7135952910dac0cfebdf0238b0e00243e4a3b930fa4079e2b5aae102ff528275f50b0acf84dad1ff7d4bd1a5463490b5ee
7
- data.tar.gz: 3c9d60c8e8e32be9f123ef28253975bba69f110b79428b603daf3b6ee073f976e190636fe485668d293cd2e79b057bab4116ebdec6eaac187af6216141b11d88
6
+ metadata.gz: a0b442e82b6ef3693a16d82ffe74e1a066b02c52ca5e33c1682c8118cf2879fac46f3f631a178ac9de44a4fe1098be7031f8b00ff4f3a72d56325920795af181
7
+ data.tar.gz: 3c19d5863472d1c13937ab3ac335a055d4c8ad0fde287a727c90fb995812bb6d441f65cf46605575d1349b27f659bf5561be302680e64de70f88a360cfc718f9
@@ -48,8 +48,8 @@ module HammerCLIForemanResourceQuota
48
48
  success_message _('Resource quota created.')
49
49
  failure_message _('Could not create resource quota')
50
50
 
51
- option '--memory', "Memory", _('Maximum memory in MiB'), attribute_name: :memory_mb, format: HammerCLI::Options::Normalizers::Number.new
52
- option '--disk-space', "Disk space", _('Maximum disk space in GiB'), attribute_name: :disk_gb, format: HammerCLI::Options::Normalizers::Number.new
51
+ option '--memory', "Memory", _('Maximum memory in MiB'), attribute_name: :option_memory_mb, format: HammerCLI::Options::Normalizers::Number.new
52
+ option '--disk-space', "Disk space", _('Maximum disk space in GiB'), attribute_name: :option_disk_gb, format: HammerCLI::Options::Normalizers::Number.new
53
53
 
54
54
  build_options do |o|
55
55
  o.without('memory_mb', 'disk_gb')
@@ -57,18 +57,41 @@ module HammerCLIForemanResourceQuota
57
57
  end
58
58
 
59
59
  class DeleteCommand < HammerCLIForeman::DeleteCommand
60
- success_message _('Resource quota [%{name}] was deleted.')
60
+ success_message _('Resource quota "%{name}" was deleted.')
61
61
  failure_message _('Could not delete the resource quota')
62
62
 
63
63
  build_options
64
64
  end
65
65
 
66
66
  class UpdateCommand < HammerCLIForeman::UpdateCommand
67
- success_message _('Resource quota [%{name}] updated.')
67
+ success_message _('Resource quota "%{name}" updated.')
68
68
  failure_message _('Could not update the resource quota')
69
69
 
70
- option '--memory', "Memory", _('Maximum memory in MiB'), attribute_name: :memory_mb, format: HammerCLI::Options::Normalizers::Number.new
71
- option '--disk-space', "Disk space", _('Maximum disk space in GiB'), attribute_name: :disk_gb, format: HammerCLI::Options::Normalizers::Number.new
70
+ option '--memory', "Memory", _('Maximum memory in MiB'), attribute_name: :option_memory_mb, format: HammerCLI::Options::Normalizers::Number.new
71
+ option '--disk-space', "Disk space", _('Maximum disk space in GiB'), attribute_name: :option_disk_gb, format: HammerCLI::Options::Normalizers::Number.new
72
+ option '--remove-memory-limit', :flag, _('Remove quota limit for memory')
73
+ option '--remove-disk-space-limit', :flag, _('Remove quota limit for disk space')
74
+ option '--remove-cpu-cores-limit', :flag, _('Remove quota limit for CPU cores')
75
+
76
+ validate_options do
77
+ if option(:option_remove_memory_limit).exist? && option(:option_memory_mb).exist?
78
+ raise ArgumentError, _("You cannot set '--remove-memory-limit' and '--memory' options at the same time")
79
+ end
80
+ if option(:option_remove_disk_space_limit).exist? && option(:option_disk_gb).exist?
81
+ raise ArgumentError, _("You cannot set '--remove-disk-space-limit' and '--disk-space' options at the same time")
82
+ end
83
+ if option(:option_remove_cpu_cores_limit).exist? && option(:option_cpu_cores).exist?
84
+ raise ArgumentError, _("You cannot set '--remove-cpu-cores-limit' and '--cpu-cores' options at the same time")
85
+ end
86
+ end
87
+
88
+ def request_params
89
+ super.tap do |opts|
90
+ opts['resource_quota']['memory_mb'] = nil if option_remove_memory_limit?
91
+ opts['resource_quota']['disk_gb'] = nil if option_remove_disk_space_limit?
92
+ opts['resource_quota']['cpu_cores'] = nil if option_remove_cpu_cores_limit?
93
+ end
94
+ end
72
95
 
73
96
  build_options do |o|
74
97
  o.without('memory_mb', 'disk_gb')
@@ -2,6 +2,6 @@
2
2
 
3
3
  module HammerCLIForemanResourceQuota
4
4
  def self.version
5
- @version ||= Gem::Version.new '0.1.0'
5
+ @version ||= Gem::Version.new '0.2.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_foreman_resource_quota
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ATIX AG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-16 00:00:00.000000000 Z
11
+ date: 2025-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hammer_cli_foreman